Chapter 14: Kernel Activities
enabled. This allows the original bitmap to be modified at any time during processing of the softIRQ
handlers.
Theactionfunctions insoftirq_vecare invoked in awhileloop for each enabled softIRQ.
local_softirq_pendung and restart limit not reached? Restart processing
New softIRQs activated? wakeup_softirqd
do_softirq
local_softirq_pending
__do_softirq
h->action
Figure 14-11: Code flow diagram fordo_softirq.
Once all marked softIRQs have been serviced, the kernel checks whether new softIRQs have been marked
in the original bitmap in the meantime. At least one softIRQ not serviced in the previous cycle must
remain, and the number of restarts must not exceedMAX_SOFTIRQ_RESTART(usually set to 10). If this is
the case, the marked softIRQs are again processed in sequence. This operation is repeated until no new
unprocessed softIRQs remain after execution of all handlers.
Should softIRQs still remain after theMAX_SOFTIRQ_RESTARTtime of restarting the processing,
wakeup_softirqdis called to wake up the softIRQ daemon:
14.2.2 The SoftIRQ Daemon
The task of the softIRQ daemon is to execute softIRQsasynchronously to remaining kernel code. To this
end, each system processor is allocated its own daemon namedksoftirqd.
wakeup_softirqdis invoked at two points in the kernel to wake up the daemon:
❑ Indo_softirq, as just mentioned.
❑ At the end ofraise_softirq_irqoff. This funtion is called byraise_softirqinternally, and
can also be used directly if the kernel has interrupts turned off at the moment.
The wake-up function itself can be dealt with in a few lines. A pointer to thetask_structof the softIRQ
daemon is read from a per-CPU variable by means of a few macros. If the current task state is not
alreadyTASK_RUNNING, it is put back in the list of processes ready to run by means ofwake_up_process
(see Chapter 2). Although this does not immediately start servicing of all pending software inter-
rupts, the daemon (which runs with priority 19) is selected as soon as the scheduler has nothing
better to do.