diff options
author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2013-07-26 23:47:42 -0400 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2013-08-20 14:45:50 -0400 |
commit | 458fb381eacdd23366cfa2fbdf5a467848683e3a (patch) | |
tree | 2e99312defa53ba0576e303021a0a2bf62b664b8 | |
parent | 5361471437a97cf493c2aa7d881bbedc9c248415 (diff) |
rcu: Simplify _rcu_barrier() processing
This commit drops an unneeded ACCESS_ONCE() and simplifies an "our work
is done" check in _rcu_barrier(). This applies feedback from Linus
(https://lkml.org/lkml/2013/7/26/777) that he gave to similar code
in an unrelated patch.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
[ paulmck: Fix comment to match code, reported by Lai Jiangshan. ]
-rw-r--r-- | kernel/rcutree.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/kernel/rcutree.c b/kernel/rcutree.c index c6a064abd6a0..a4a04f311cfb 100644 --- a/kernel/rcutree.c +++ b/kernel/rcutree.c | |||
@@ -2817,9 +2817,20 @@ static void _rcu_barrier(struct rcu_state *rsp) | |||
2817 | * transition. The "if" expression below therefore rounds the old | 2817 | * transition. The "if" expression below therefore rounds the old |
2818 | * value up to the next even number and adds two before comparing. | 2818 | * value up to the next even number and adds two before comparing. |
2819 | */ | 2819 | */ |
2820 | snap_done = ACCESS_ONCE(rsp->n_barrier_done); | 2820 | snap_done = rsp->n_barrier_done; |
2821 | _rcu_barrier_trace(rsp, "Check", -1, snap_done); | 2821 | _rcu_barrier_trace(rsp, "Check", -1, snap_done); |
2822 | if (ULONG_CMP_GE(snap_done, ((snap + 1) & ~0x1) + 2)) { | 2822 | |
2823 | /* | ||
2824 | * If the value in snap is odd, we needed to wait for the current | ||
2825 | * rcu_barrier() to complete, then wait for the next one, in other | ||
2826 | * words, we need the value of snap_done to be three larger than | ||
2827 | * the value of snap. On the other hand, if the value in snap is | ||
2828 | * even, we only had to wait for the next rcu_barrier() to complete, | ||
2829 | * in other words, we need the value of snap_done to be only two | ||
2830 | * greater than the value of snap. The "(snap + 3) & ~0x1" computes | ||
2831 | * this for us (thank you, Linus!). | ||
2832 | */ | ||
2833 | if (ULONG_CMP_GE(snap_done, (snap + 3) & ~0x1)) { | ||
2823 | _rcu_barrier_trace(rsp, "EarlyExit", -1, snap_done); | 2834 | _rcu_barrier_trace(rsp, "EarlyExit", -1, snap_done); |
2824 | smp_mb(); /* caller's subsequent code after above check. */ | 2835 | smp_mb(); /* caller's subsequent code after above check. */ |
2825 | mutex_unlock(&rsp->barrier_mutex); | 2836 | mutex_unlock(&rsp->barrier_mutex); |