[bootlin/training-materials updates] master: kernel: concurrency: Improve the first spinlock slide (bce0912f)

Miquel Raynal miquel.raynal at bootlin.com
Tue Oct 18 15:51:43 CEST 2022


Repository : https://github.com/bootlin/training-materials
On branch  : master
Link       : https://github.com/bootlin/training-materials/commit/bce0912fa2797b5ffe8e45d4cdc381851511016d

>---------------------------------------------------------------

commit bce0912fa2797b5ffe8e45d4cdc381851511016d
Author: Miquel Raynal <miquel.raynal at bootlin.com>
Date:   Tue Oct 18 15:46:59 2022 +0200

    kernel: concurrency: Improve the first spinlock slide
    
    Change a little bit the text of the picture just to mention that with
    preemption we may end up in a deadlock, but this is not 100%
    guaranteed. Of course, not disabling preemption is a bug and should be
    considered very bad practice, the goal is just to be a little bit more
    accurate, more details can be given orally if the audience already has
    an advanced understanding of the problem.
    
    While on this slide, update a bit the text to reflect where we use it as
    well (not only in process context, that's the whole point).
    
    Also mention the prevention of the migration which is implied when
    disabling the preemption.
    
    Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>


>---------------------------------------------------------------

bce0912fa2797b5ffe8e45d4cdc381851511016d
 common/spinlock-deadlock-with-preemption.dia                  |  6 +++---
 .../kernel-driver-development-concurrency.tex                 | 11 +++++++----
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/common/spinlock-deadlock-with-preemption.dia b/common/spinlock-deadlock-with-preemption.dia
index 495ecbd5..03cff457 100644
--- a/common/spinlock-deadlock-with-preemption.dia
+++ b/common/spinlock-deadlock-with-preemption.dia
@@ -363,15 +363,15 @@ spinlock A#</dia:string>
         <dia:point val="30.4125,8.88609"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="30.4125,8.365;33.35,11.2834"/>
+        <dia:rectangle val="30.4125,8.34848;33.864,11.3164"/>
       </dia:attribute>
       <dia:attribute name="text">
         <dia:composite type="text">
           <dia:attribute name="string">
             <dia:string>#Tries to acquire
 spinlock A, but
-waits forever in
-an endless loop
+might wait forever
+in an endless loop
 ("deadlock")#</dia:string>
           </dia:attribute>
           <dia:attribute name="font">
diff --git a/slides/kernel-driver-development-concurrency/kernel-driver-development-concurrency.tex b/slides/kernel-driver-development-concurrency/kernel-driver-development-concurrency.tex
index d770590d..855b5665 100644
--- a/slides/kernel-driver-development-concurrency/kernel-driver-development-concurrency.tex
+++ b/slides/kernel-driver-development-concurrency/kernel-driver-development-concurrency.tex
@@ -137,13 +137,16 @@
   \item \mint{c}+void spin_unlock(spinlock_t *lock);+
     \begin{itemize}
     \item Used for locking in process context (critical sections
-          in which you do not want to sleep).
+      in which you do not want to sleep) as well as atomic
+      sections.
     \item Kernel preemption on the local CPU is disabled. We need
-          to avoid deadlocks because of preemption from processes
-	  that want to get the same lock:
+      to avoid deadlocks (and unbounded latencies) because of preemption
+      from processes that want to get the same lock:
+      \includegraphics[width=0.8\textwidth]{common/spinlock-deadlock-with-preemption.pdf}
+    \item Disabling kernel preemption also disables migration to avoid
+      the same kind of issue as pictured above from happening.
     \end{itemize}
   \end{itemize}
-  \includegraphics[width=0.8\textwidth]{common/spinlock-deadlock-with-preemption.pdf}
 \end{frame}
 
 \begin{frame}[fragile]




More information about the training-materials-updates mailing list