Which CPU increments the jiffies in SMP?

linux-device-driver, linux-kernel, timer

Solution

There are two timer interrupts: The local timer interrupt (`LOC` in `/proc/interrupts`) fires once per jiffy on each CPU. The global timer interrupts (interrupt 0) fires once per jiffy, on any CPU. It increments `jiffies`.

Note that the "Tickless Kernel" configuration option (introduced in Linux 2.6.21, `CONFIG_NO_HZ`), removes these interrupts. With a tickless kernel, there's no periodic interrupt any more. Instead, when a process starts its quantum, Linux sets an "alarm clock" in the hardware to trigger an interrupt when the quantum is over.

Problem

As I read, the jiffies is incremented on every timer tick by the timer ISR. But in SMP, all CPUs will have their own timer interrupt and hence their own timer ISRs. So my question is: Is jiffies global across all CPUs? If so, how and which CPU increments it in its timer ISR? As per my understanding the jiffies can not be per CPU otherwise the same process when scheduled on different CPU will see different jiffy value.

Original source

Related problems