[bootlin/training-materials updates] master: kernel: RCU: Fix example (ac87fac6)

Miquel Raynal miquel.raynal at bootlin.com
Thu Nov 2 16:48:09 CET 2023


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

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

commit ac87fac6fc3bcad031b004a70c42d9deffa4e195
Author: Miquel Raynal <miquel.raynal at bootlin.com>
Date:   Thu Nov 2 16:48:08 2023 +0100

    kernel: RCU: Fix example
    
    Reported-by: Paul Kocialkowski <paul.kocialkowski at bootlin.com>
    Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>


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

ac87fac6fc3bcad031b004a70c42d9deffa4e195
 .../kernel-driver-development-concurrency.tex                       | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

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 4d56db15..adec5fc0 100644
--- a/slides/kernel-driver-development-concurrency/kernel-driver-development-concurrency.tex
+++ b/slides/kernel-driver-development-concurrency/kernel-driver-development-concurrency.tex
@@ -274,7 +274,7 @@ struct myconf { int a, b; } *shared_conf; /* initialized */
 unsafe_get(int *cur_a, int *cur_b)
 {
         *cur_a = shared_conf->a;
-        /* What if *current_conf gets updated now? The assignement is inconsistent! */
+        /* What if *shared_conf gets updated now? The assignement is inconsistent! */
         *cur_b = shared_conf->b;
 };
 
@@ -310,10 +310,10 @@ safe_set(int new_a, int new_b)
         struct myconf *newconf = kmalloc(...);
         struct myconf *oldconf;
 
-        oldconf = rcu_dereference(current_conf);
+        oldconf = rcu_dereference(shared_conf);
         newconf->a = new_a;
         newconf->b = new_b;
-        rcu_assign_pointer(current_conf, newconf);
+        rcu_assign_pointer(shared_conf, newconf);
         /* Readers might still have a reference over the old struct here... */
         synchronize_rcu();
         /* ...but not here! No more readers of the old struct, kfree() is safe! */




More information about the training-materials-updates mailing list