Skip to content

Commit

Permalink
rcu: Apply ACCESS_ONCE() to rcu_boost() return value
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Paul E. McKenney authored and Paul E. McKenney committed Dec 11, 2011
1 parent 70321d4 commit 4f89b33
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions kernel/rcutiny_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down
3 changes: 2 additions & 1 deletion kernel/rcutree_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down

0 comments on commit 4f89b33

Please sign in to comment.