Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 14: Kernel Activities


From a more abstract view, software interrupts can therefore be described as a form of kernel activity
that is deferred to a later point in time. However, despite the clear similarities between hardware and
software interrupts, they are not always comparable.

The central component of the softIRQ mechanism is a table with 32 entries to hold elements of the
softirq_actiontype. This data type has a very simple structure and consists of two elements only:

<interrupt.h>
struct softirq_action
{
void (*action)(struct softirq_action *);
void *data;
};

Whereasactionis a pointer to the handler routine executed by the kernel when a software interrupt
occurs,dataaccepts a nonspecified pointer to private data of the handler function.

The definition of the data structure is architecture-independent, as is the complete implementation of
the softIRQ mechanism. With the exception of processing activation, no processor-specific functions or
features are deployed; this is in clear contrast to normal interrupts.

Software interrupts must be registered before the kernel can execute them. Theopen_softirqfunction is
provided for this purpose. It writes the new softIRQ at the desired position in thesoftirq_vectable:

kernel/softirq.c
void open_softirq(int nr, void (*action)(struct softirq_action*), void *data)
{
softirq_vec[nr].data = data;
softirq_vec[nr].action = action;
}

datais used as a parameter each time theactionsoftIRQ handler is called.

The fact that each softIRQ has a unique number immediately suggests that softIRQs are relatively scarce
resources that may not be used randomly by all manner of device drivers and kernel parts but must be
used judiciously. By default, only 32 softIRQs may be used on a system. However, this limit is not too
restrictive because softIRQs act as a basis for implementing other mechanisms that also defer work and
are better adapted to the needs of device drivers. The corresponding techniques (tasklets, work queues,
and kernel timers) are discussed below.

Only the central kernel code uses software interrupts. SoftIRQs are used at a few points only, but these
are all the more important:

<interrupt.h>
enum
{
HI_SOFTIRQ=0,
TIMER_SOFTIRQ,
NET_TX_SOFTIRQ,
NET_RX_SOFTIRQ,
BLOCK_SOFTIRQ,
Free download pdf