Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 14: Kernel Activities


23:0000IO-APIC-fasteoi uhci_hcd:usb4, ehci_hcd:usb8
NMI: 0 0 0 0 Non-maskable interrupts
LOC: 2307075 2266433 2220704 2208597 Local timer interrupts
RES: 22037 18253 33530 35156 Rescheduling interrupts
CAL: 363 373 394 184 function call interrupts
TLB: 3355 3729 1919 1630 TLB shootdowns
TRM: 0 0 0 0 Thermal event interrupts
THR: 0 0 0 0 Threshold APIC interrupts
SPU: 0 0 0 0 Spurious interrupts
ERR: 0


Note that the chip name is concatenated with the flow handler name, which results, for instance,
in ‘‘IO-APIC-edge.’’ Besides listing all registered IRQs, the file also provides some statistics at
the bottom.

HandlerFunctionRepresentation


An instance of theirqactionstructure defined as follows exists for each handler function:

<interrupt.h>
struct irqaction {
irq_handler_t handler;
unsigned long flags;
const char *name;
void *dev_id;
struct irqaction *next;
}

The most important element in the structure is the handler function itself, which takes the form of the
handlerpointer and is located at the beginning of the structure. The handler function is invoked by
the kernel when a device has requested a system interrupt and the interrupt controller has forwarded
this to the processor by raising an interrupt. We will look more closely at the meaning of the arguments
when we consider how to register handler functions. Note, however, that the typeirq_handler_tclearly
distinguishes this handler type from flow handlers that are of typeirq_flow_handler_t!

nameanddev_iduniquely identify an interrupt handler. Whilenameis a short string used to identify the
device (e.g., ‘‘e100,’’ ‘‘ncr53c8xx,’’ etc.),dev_idis a pointer to any data structure that uniquely identifies
the device among all kernel data structures — for example, thenet_deviceinstance of a network card.
This information is needed when removing a handler function if several devices share an IRQ and the
IRQ number alone is not sufficient to identify the device.

flagsis a flag variable that describes some features of the IRQ (and associated interrupt) with the help
of a bitmap whose individual elements can, as usual, be accessed via predefined constants. The following
constants are defined in<interrupt.h>:

❑ IRQF_SHAREDis set forshared IRQsand signals that more than one device is using an IRQ line.
❑ IRQF_SAMPLE_RANDOMis set when the IRQ contributes to the kernel entropy pool.^9
❑ IRQF_DISABLEDindicates that the IRQ handler must be executed with interruptsdisabled.
❑ IRQF_TIMERdenotes a timer interrupt.

(^9) This information is used to generate relatively secure random numbers for/dev/randomand/dev/urandom.

Free download pdf