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

2

9

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

Fiddler answered 19/9, 2011 at 20:6 Comment(5)
I believe it may already do this - at least interrupt handlers always seem to run on core 0.Cinereous
I read in an article that kernel may run in different cores, and when I checked some source files there were many 'spin-lock' calls, i.e. it locks because the kernel code may be executed in parallel on different CPUsFiddler
@Nulik: System calls made by user threads will cause the kernel to run on many different cores. That's very different from parallel interrupt handling, though.Outsoar
Do not know why the question is closed. Setting affinity has fully programming intention. Voted for reopen.Portent
I don't think this is an off-topic question.Sarre
M
8

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.

Metacarpus answered 19/9, 2011 at 20:59 Comment(0)
O
1

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.

Outsoar answered 19/9, 2011 at 20:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.