Commit a542d116 authored by Paul E. McKenney's avatar Paul E. McKenney Committed by Uladzislau Rezki (Sony)

rcu: Mark writes to rcu_sync ->gp_count field

The rcu_sync structure's ->gp_count field is updated under the protection
of ->rss_lock, but read locklessly, and KCSAN noted the data race.
This commit therefore uses WRITE_ONCE() to do this update to clearly
document its racy nature.
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: default avatarUladzislau Rezki (Sony) <urezki@gmail.com>
parent c90b9e49
...@@ -122,7 +122,7 @@ void rcu_sync_enter(struct rcu_sync *rsp) ...@@ -122,7 +122,7 @@ void rcu_sync_enter(struct rcu_sync *rsp)
* we are called at early boot time but this shouldn't happen. * we are called at early boot time but this shouldn't happen.
*/ */
} }
rsp->gp_count++; WRITE_ONCE(rsp->gp_count, rsp->gp_count + 1);
spin_unlock_irq(&rsp->rss_lock); spin_unlock_irq(&rsp->rss_lock);
if (gp_state == GP_IDLE) { if (gp_state == GP_IDLE) {
...@@ -151,11 +151,15 @@ void rcu_sync_enter(struct rcu_sync *rsp) ...@@ -151,11 +151,15 @@ void rcu_sync_enter(struct rcu_sync *rsp)
*/ */
void rcu_sync_exit(struct rcu_sync *rsp) void rcu_sync_exit(struct rcu_sync *rsp)
{ {
int gpc;
WARN_ON_ONCE(READ_ONCE(rsp->gp_state) == GP_IDLE); WARN_ON_ONCE(READ_ONCE(rsp->gp_state) == GP_IDLE);
WARN_ON_ONCE(READ_ONCE(rsp->gp_count) == 0); WARN_ON_ONCE(READ_ONCE(rsp->gp_count) == 0);
spin_lock_irq(&rsp->rss_lock); spin_lock_irq(&rsp->rss_lock);
if (!--rsp->gp_count) { gpc = rsp->gp_count - 1;
WRITE_ONCE(rsp->gp_count, gpc);
if (!gpc) {
if (rsp->gp_state == GP_PASSED) { if (rsp->gp_state == GP_PASSED) {
WRITE_ONCE(rsp->gp_state, GP_EXIT); WRITE_ONCE(rsp->gp_state, GP_EXIT);
rcu_sync_call(rsp); rcu_sync_call(rsp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment