Chapter 14: Kernel Activities
Calling the Flow HandlerRoutine
How the flow handler routines are called differs from architecture to architecture; in the following,
how this is done is discussed for AMD64 and IA-32. Additionally, we also examine the old han-
dler mechanism that was the default before the IRQ subsystem rewrite, and is still used in some
places.
Processing on AMD64 Systems
Let us first turn our attention to howdo_IRQis implemented on AMD64 systems. This variant is simpler
as compared to IA-32, and many other modern architectures use a similar approach. The code flow
diagram is shown in Figure 14-9.
do_IRQ
set_irq_regs
set_irq_regs
irq_enter
generic_handle_irq
irq_exit
Figure 14-9: Code flow diagram
fordo_IRQ.on AMD64 systems.
The prototype of the function is as follows:
arch/x86/kernel/irq_64.c
asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
The low-level assembler code is responsible to passthe current state of the register set to the function,
and the first task ofdo_IRQis to save a pointer to them in a global per-CPU variable usingset_irq_regs
(the old pointer that was active before the interruptoccurred is preserved for later). Interrupt handlers
that require access to the register set can access them from there.
irq_enteris then responsible to update some statistics; for systems with dynamic ticks, the global
jiffiestime-keeping variable is updated if the system has been in a tickless state for some time
(more about dynamic ticks follows in Section 15.5.). Calling the ISRs registered for the IRQ in
question is then delegated to the architecture-independentfunctiongeneric_handle_irq, which calls
irq_desc[irq]->handle_irqto activate the flow control handler.
irq_exitis then responsible for some statistics bookkeeping, but also calls (assuming the kernel is not
still in interrupt mode because it is processing a nested interrupt)do_softirqto service any pend-
ing software IRQs. This mechanism is discussed in more detail in Section 14.2. Finally, another call to
set_irq_regsrestores the pointer tostruct regsto the setting that was active before the call. This
ensures that nested handlers work correctly.