user249060
user249060

Reputation: 33

Does Linux drop into the kernel on all cores?

For a multi-core computer running Linux 2.6.x, what happens when a thread makes a system call? Does it drop into the kernel only on the core that the thread is running on, or does it drop into the kernel on all cores (sorry if this is a newbie question).

Is this behaviour (whichever is the correct one) the same when receiving interrupts in general? If not, what are the differences?

Upvotes: 3

Views: 505

Answers (2)

Michael
Michael

Reputation: 55445

Ony one core handles a system call, and only one core handles an interrupt.

I don't have any references off hand for exactly how interrupts are routed - perhaps Intel's System Programming Guide would be helpful here.

But, imagine if all cores were interrupted by every system call or interrupt. Linux is designed to scale to many cores. This would kill that scalability - on a massive server every disk I/O, timer interrupt, etc., would effectively stall every single core in the system, preventing them from doing useful work.

Upvotes: 1

Nikolai Fetissov
Nikolai Fetissov

Reputation: 84239

Only the thread that does the syscall enters the kernel. All scheduling in Linux is done on thread granularity. As for interrupts - they are routed to one core, i.e. only one processor is interrupted for each given hardware event. Then interrupts could be manually assigned to specific cores. This is done with a mask in /proc/irq/IRQ-NUMBER/smp_affinity. You can see which CPUs receive what hardware interrupts in /proc/interrupts.

Upvotes: 6

Related Questions