rcu: Apply ACCESS_ONCE() to rcu_boost() return value
authorPaul E. McKenney <paul.mckenney@linaro.org>
Fri, 9 Dec 2011 22:43:47 +0000 (14:43 -0800)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Sun, 11 Dec 2011 18:33:19 +0000 (10:33 -0800)
Both TINY_RCU's and TREE_RCU's implementations of rcu_boost() access
the ->boost_tasks and ->exp_tasks fields without preventing concurrent
changes to these fields.  This commit therefore applies ACCESS_ONCE in
order to prevent compiler mischief.

Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
kernel/rcutiny_plugin.h
kernel/rcutree_plugin.h

index dfa97cbb39106ef7e16753e56e3ebe551c034a57..9cb1ae4aabdd8bb894ab7ed7160a07cee5ec144f 100644 (file)
@@ -312,8 +312,8 @@ static int rcu_boost(void)
        rt_mutex_lock(&mtx);
        rt_mutex_unlock(&mtx);  /* Keep lockdep happy. */
 
-       return rcu_preempt_ctrlblk.boost_tasks != NULL ||
-              rcu_preempt_ctrlblk.exp_tasks != NULL;
+       return ACCESS_ONCE(rcu_preempt_ctrlblk.boost_tasks) != NULL ||
+              ACCESS_ONCE(rcu_preempt_ctrlblk.exp_tasks) != NULL;
 }
 
 /*
index f55f10ba01f548279e48f06459a61703391c569d..8bb35d73e1f9d210e95fc85ac330ebb3954577af 100644 (file)
@@ -1232,7 +1232,8 @@ static int rcu_boost(struct rcu_node *rnp)
        rt_mutex_lock(&mtx);  /* Side effect: boosts task t's priority. */
        rt_mutex_unlock(&mtx);  /* Keep lockdep happy. */
 
-       return rnp->exp_tasks != NULL || rnp->boost_tasks != NULL;
+       return ACCESS_ONCE(rnp->exp_tasks) != NULL ||
+              ACCESS_ONCE(rnp->boost_tasks) != NULL;
 }
 
 /*