Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting cpu affinity for linux kernel, not process [closed]

I am having a hard time finding information about how to set cpu affinity for linux kernel (with all of its loaded modules), NOT for a specific process.

This is because I want the kernel to run on CPU 0 all the time to handle I/O stuff, and not do any switches to run on other 3 CPUs because it may pollute L1 and L2 caches.

Thanks in advance.

Nulik

like image 628
Nulik Avatar asked Sep 19 '11 20:09

Nulik


2 Answers

Kernel work on behalf of processes will always happen on the CPU that makes the request. You can steer interrupts, though. Look at /proc/interrupts to identify the interrupts you want to move (say everything matching eth0) and set the affinity by echoing a hexadecimal mask to /proc/irq/XXX/smp_affinity.

like image 102
Ben Jackson Avatar answered Nov 15 '22 17:11

Ben Jackson


You should be able to disable the other cores via a kernel command-line option.

Not having the kernel run on a core implies that nothing else can run on that core either. No kernel scheduler and no TLB setup -> no code executing.

like image 24
Ben Voigt Avatar answered Nov 15 '22 16:11

Ben Voigt