diff options
author | Paul E. McKenney <paulmck@kernel.org> | 2020-02-03 14:20:00 -0800 |
---|---|---|
committer | Paul E. McKenney <paulmck@kernel.org> | 2020-02-20 15:58:23 -0800 |
commit | faa059c397dec8a452c79e9dba64419113ea64e2 (patch) | |
tree | 14e7cbd40cf86f678ff2e373323cfe0469939d26 /kernel/rcu | |
parent | 92c0b889f2ff6898710d49458b6eae1de50895c6 (diff) | |
download | linux-stable-faa059c397dec8a452c79e9dba64419113ea64e2.tar.gz linux-stable-faa059c397dec8a452c79e9dba64419113ea64e2.tar.bz2 linux-stable-faa059c397dec8a452c79e9dba64419113ea64e2.zip |
rcu: Optimize and protect atomic_cmpxchg() loop
This commit reworks the atomic_cmpxchg() loop in rcu_eqs_special_set()
to do only the initial read from the current CPU's rcu_data structure's
->dynticks field explicitly. On subsequent passes, this value is instead
retained from the failing atomic_cmpxchg() operation.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'kernel/rcu')
-rw-r--r-- | kernel/rcu/tree.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 4a4a975503e5..6c624814ee2d 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -342,14 +342,17 @@ bool rcu_eqs_special_set(int cpu) { int old; int new; + int new_old; struct rcu_data *rdp = &per_cpu(rcu_data, cpu); + new_old = atomic_read(&rdp->dynticks); do { - old = atomic_read(&rdp->dynticks); + old = new_old; if (old & RCU_DYNTICK_CTRL_CTR) return false; new = old | RCU_DYNTICK_CTRL_MASK; - } while (atomic_cmpxchg(&rdp->dynticks, old, new) != old); + new_old = atomic_cmpxchg(&rdp->dynticks, old, new); + } while (new_old != old); return true; } |