Skip to content

Commit 6807fb9

Browse files
committed
Update documentation on bottom-half handling
Since commit 3682d9e ("Move bottom-half to workqueue for safe sleep") switched the implementation to workqueues, update the description accordingly to avoid confusion and reflect the modern approach to bottom-half handling. Explain the issues with tasklets and introduce the BH workqueue as the new, reliable alternative.
1 parent 7714f63 commit 6807fb9

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

lkmpg.tex

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,11 +2107,21 @@ \subsection{Detecting button presses}
21072107
\subsection{Bottom Half}
21082108
\label{sec:bottom_half}
21092109
Suppose you want to do a bunch of stuff inside of an interrupt routine.
2110-
A common way to do that without rendering the interrupt unavailable for a significant duration is to combine it with a tasklet.
2110+
A common way to avoid blocking the interrupt for a significant duration
2111+
is to defer the time-consuming part to a workqueue.
21112112
This pushes the bulk of the work off into the scheduler.
2112-
2113-
The example below modifies the previous example to also run an additional task when an interrupt is triggered.
2114-
2113+
This approach helps speed up the interrupt handling process itself,
2114+
allowing the system to respond to the next hardware interrupt more quickly.
2115+
2116+
Kernel developers generally discourage using tasklets due to their design limitations,
2117+
such as memory management issues and unpredictable latencies.
2118+
Instead, they recommend more robust mechanisms like workqueues or \textbf{softirqs}.
2119+
To address tasklet shortcomings, Linux contributors introduced the BH workqueue,
2120+
activated with the \cpp|WQ_BH| flag.
2121+
This workqueue retains critical features,
2122+
such as execution in atomic (\textbf{softirq}) context on the same CPU and the inability to sleep.
2123+
2124+
The example below extends the previous code to include an additional task executed in process context when an interrupt is triggered.
21152125
\samplec{examples/bottomhalf.c}
21162126

21172127
\subsection{Threaded IRQ}

0 commit comments

Comments
 (0)