Signed-off-by: Junchang Wang <junchangwang@xxxxxxxxx> Reviewed-by: Akira Yokosawa <akiyks@xxxxxxxxx> --- CodeSamples/defer/rcu.c | 2 +- CodeSamples/defer/rcu.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CodeSamples/defer/rcu.c b/CodeSamples/defer/rcu.c index 4b868cc..66792e5 100644 --- a/CodeSamples/defer/rcu.c +++ b/CodeSamples/defer/rcu.c @@ -35,7 +35,7 @@ void synchronize_rcu(void) /* Advance to a new grace-period number, enforce ordering. */ - rcu_gp_ctr += 2; + WRITE_ONCE(rcu_gp_ctr, rcu_gp_ctr + 2); smp_mb(); /* diff --git a/CodeSamples/defer/rcu.h b/CodeSamples/defer/rcu.h index f493f8b..b49ab14 100644 --- a/CodeSamples/defer/rcu.h +++ b/CodeSamples/defer/rcu.h @@ -41,7 +41,7 @@ static inline void rcu_read_lock(void) * periodic per-thread processing.) */ - __get_thread_var(rcu_reader_gp) = rcu_gp_ctr + 1; + __get_thread_var(rcu_reader_gp) = READ_ONCE(rcu_gp_ctr) + 1; smp_mb(); } @@ -55,7 +55,7 @@ static inline void rcu_read_unlock(void) */ smp_mb(); - __get_thread_var(rcu_reader_gp) = rcu_gp_ctr; + __get_thread_var(rcu_reader_gp) = READ_ONCE(rcu_gp_ctr); } extern void synchronize_rcu(void); -- 2.7.4