Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 14: Kernel Activities


TASKLET_SOFTIRQ
SCHED_SOFTIRQ,
#ifdef CONFIG_HIGH_RES_TIMERS
HRTIMER_SOFTIRQ,
#endif
};

};

Two serve to implement tasklets (HI_SOFTIRQandTASKLET_SOFTIRQ), two are used for send and receive
operations in networks (NET_TX_SOFTIRQandNET_RX_SOFTIRQ, the source of the softIRQ mechanism
and its most important application), one is used by the block layer to implement asynchronous request
completions (BLOCK_SOFTIRQ), and one is used by the scheduler (SCHED_SOFTIRQ) to implement periodic
load balancing on SMP systems. When high-resolution timers are enabled, they also require a softIRQ
(HRTIMER_SOFTIRQ).

Numbering of the softIRQs produces a priority sequence, which does not affect the frequency of exe-
cution of individual handler routines or their priority with respect to other system activities, but does
define the sequence in which the routines are executed if several are marked as active or pending at the
same time.

raise_softirq(int nr)is used to raise a software interrupt (similarly to a normal interrupt). The num-
ber of the desired softIRQ is passed as a parameter.

This function sets the corresponding bit in the per-CPU variableirq_stat[smp_processor_id].__
softirq_pending. This marks the softIRQ for execution but defers execution. By using a processor-
specific bitmap, the kernel ensures that several softIRQs — even identical ones — can be executed on
different CPUs at the same time.

Providingraise_softirqwas not called in the interrupt context,wakeup_softirqdis called to wake
the softIRQ daemon; this is one of the two alternative ways of launching the processing of softIRQs. The
daemon is discussed in more detail in Section 14.2.2.

14.2.1 Starting SoftIRQ Processing


There are several ways of starting softIRQ processing, but all come down to invoking thedo_softirq
function. For this reason, let’s take a closer look atthis function. Figure 14-11 shows the corresponding
code flow diagram that presents the essential steps.

The function first ensures that it isnotin the interrupt context (meaning, of course, that a hardware
interrupt is involved). If it is, it terminates immediately. Because softIRQs are used to execute time-
uncritical parts of ISRs, the code itself must not be called within an interrupt handler.

With the help oflocal_softirq_pending, the bitmap of all softIRQs set on the current CPU is deter-
mined. If any softIRQ is waiting to be processed, then__do_softirqis called.

This function resets the original bitmap to 0; in otherwords, all softIRQs are deleted. Both actions take
place (on the current processor) with disabled interrupts to prevent modification of the bitmap as a
result of interference by other processes. Subsequent code, on the other hand, executes with interrupts
Free download pdf