Skip to content

Commit a41a967

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 2232257 commit a41a967

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lkmpg.tex

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,11 +1985,20 @@ \subsection{Detecting button presses}
19851985
\subsection{Bottom Half}
19861986
\label{sec:bottom_half}
19871987
Suppose you want to do a bunch of stuff inside of an interrupt routine.
1988-
A common way to do that without rendering the interrupt unavailable for a significant duration is to combine it with a tasklet.
1988+
A common way to avoid blocking the interrupt for a significant duration
1989+
is to defer the time-consuming part to a workqueue.
19891990
This pushes the bulk of the work off into the scheduler.
1991+
This approach helps speed up the interrupt handling process itself,
1992+
allowing the system to respond to the next hardware interrupt more quickly.
19901993

1991-
The example below modifies the previous example to also run an additional task when an interrupt is triggered.
1994+
Kernel developers generally discourage using tasklets due to their design limitations,
1995+
such as memory management issues and unpredictable latencies.
1996+
Instead, they recommend more robust mechanisms like workqueues or softirqs.
1997+
To address tasklet shortcomings, Linux contributors introduced the BH workqueue,
1998+
activated with the WQ_BH flag. This workqueue retains critical features,
1999+
such as execution in atomic (softirq) context on the same CPU and the inability to sleep.
19922000

2001+
The example below extends the previous code to include an additional task executed in process context when an interrupt is triggered.
19932002
\samplec{examples/bottomhalf.c}
19942003

19952004
\subsection{Threaded IRQ}

0 commit comments

Comments
 (0)