Search code examples
linux-kernellinux-device-driverdevice-driver

change smp_affinity from linux device driver


If I examine the

cat /proc/interrupts 

command, all the IRQs are listed under cpu0 in SMP system. I can change the smp_affinity mask to tag the IRQ to particular CPU using following command.

 echo "4" > /proc/irq/230/smp_affinity

Above command sets the affinity mask of the interrupt 230 to CPU 2.

I would like achieve same from linux kernel module. How can I do this?
I see create_proc_entry method which allows to create new proc entry.
Is there any method which we can use to write existing proc entry?


Solution

  • In a kernel module you can just call the kernel API function irq_set_affinity(...) directly. No need to go through /proc. See: http://lxr.free-electrons.com/source/kernel/irq/manage.c#L189