All is in the title. Any links to good documentations are welcome.
4 Answers
The local timer interrupt is a timer implemented on the APIC that interrupts only a particular CPU instead of raising an interrupt that can be handled by any CPU. It's discussed in Bovet & Cesati's "Understanding the Linux Kernel". A snippet:
The local APIC present in recent 80x86 microprocessors (see the section “Interrupts and Exceptions” in Chapter 4) provides yet another time-measuring device: the CPU local timer.
The CPU local timer is a device similar to the Programmable Interval Timer just described that can issue one-shot or periodic interrupts. There are, however, a few differences:
- The APIC’s timer counter is 32 bits long, while the PIT’s timer counter is 16 bits long; therefore, the local timer can be programmed to issue interrupts at very low frequencies (the counter stores the number of ticks that must elapse before the interrupt is issued).
- The local APIC timer sends an interrupt only to its processor, while the PIT raises a global interrupt, which may be handled by any CPU in the system.
- The APIC’s timer is based on the bus clock signal (or the APIC bus signal, in older machines). It can be programmed in such a way to decrease the timer counter every 1, 2, 4, 8, 16, 32, 64, or 128 bus clock signals. Conversely, the PIT, which makes use of its own clock signals, can be programmed in a more flexible way.

- 333,147
- 50
- 533
- 760
-
1Thanks for the answer. I have this book, but the version of the kernel 2.2 :-( One more question, how does the kernel use these interrupts ? Which purpose, is it related to scheduling ? to other things ? – Manuel Selva May 12 '12 at 21:49
-
1Yes, scheduling is related to timers. – Basile Starynkevitch May 13 '12 at 07:04
-
1@Manuel: I really don't know too much detail about the kernel's use of these times. The 3rd edition of the book covers the 2.6 kernel and seems to have pretty good coverage of the topic along with specific function names that you could use to zero in on the relevant source code. I think it would be worth borrowing a copy of the 3rd edition to see if it has the level of detail information you're looking for. – Michael Burr May 13 '12 at 07:19
-
1In fact, you may be able to get what you need by browsing the contents O'Reilly makes available on their page selling the book - click the "Browse Contents" item above the image of the book: http://shop.oreilly.com/product/9780596005658.do and search for "timekeeping architecture" – Michael Burr May 13 '12 at 07:21
-
1Thanks for the answer, I read the chapter online but didn't find so much answers .. Regarding to scheduling there is also a line called Rescheduling interrupts in /proc/interrupts with a lot of interrupts, aren't the interrupts for scheduling ? – Manuel Selva May 13 '12 at 19:33
-
@Manuel: I'm sorry, but you're pushing beyond my realm of knowledge. – Michael Burr May 13 '12 at 23:47
-
@MichaelBurr Is it possible to use a source other than the local APIC timer for timer interrupts in Linux scheduling? I am writing a Linux kernel module and I want to send interrupts using the local APIC timer (since I need high resolution). I tried setting the clocksource to `hpet` but it still seems something else in Linux is using the local APIC timer. Any values I write to the local APIC timer registers are overwritten soon after and the watchdog detects lockups. – Jack Humphries Feb 15 '19 at 07:52
A less technical answer than Michael Burr's:
Some things need to be done every jiffy, doesn't matter on which CPU.
Other things need to be done every jiffy on each CPU. For example, checking if we need to switch to another process.
The local timer interrupt exists for the second type - whenever it's executed, we check them and do what's needed.

- 16,023
- 3
- 35
- 65
-
3Thanks for the answer, but regarding to scheduling there is also a line called Rescheduling interrupts in /proc/interrupts with a lot of interrupts, aren't the interrupts for scheduling ? – Manuel Selva May 13 '12 at 19:32
On SMP systems apic timer is used for scheduler / rescheduling threads.
On UP system pit timer is used for scheduler / rescheduling threads.
Normaly the PIT is no longer used anymore in SMP systems.

- 11
- 1
I feel the local timers are used for handling the IPI related functionality. I might be wrong in this guess, need t look at the code on what they are configured for and what the handler contains. But I feel the system timer and the jiffies are linked to one of the GP Timers and hence in SMP ARM for example, the interrupt from this timer is associated with one single core through the GIC affinity registration. Will get back wit more on the local timers.