Commit 4fc5b755 authored by Iulia Manda's avatar Iulia Manda Committed by Paul E. McKenney

rcu: Protect uses of jiffies_stall field with ACCESS_ONCE()

Some of the uses of the rcu_state structure's ->jiffies_stall field
do not use ACCESS_ONCE(), despite there being unprotected accesses.
This commit therefore uses the ACCESS_ONCE() macro to protect this field.
Signed-off-by: default avatarIulia Manda <iulia.manda21@gmail.com>
Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: default avatarJosh Triplett <josh@joshtriplett.org>
parent 9b67122a
...@@ -865,7 +865,7 @@ static void record_gp_stall_check_time(struct rcu_state *rsp) ...@@ -865,7 +865,7 @@ static void record_gp_stall_check_time(struct rcu_state *rsp)
rsp->gp_start = j; rsp->gp_start = j;
smp_wmb(); /* Record start time before stall time. */ smp_wmb(); /* Record start time before stall time. */
j1 = rcu_jiffies_till_stall_check(); j1 = rcu_jiffies_till_stall_check();
rsp->jiffies_stall = j + j1; ACCESS_ONCE(rsp->jiffies_stall) = j + j1;
rsp->jiffies_resched = j + j1 / 2; rsp->jiffies_resched = j + j1 / 2;
} }
...@@ -904,12 +904,12 @@ static void print_other_cpu_stall(struct rcu_state *rsp) ...@@ -904,12 +904,12 @@ static void print_other_cpu_stall(struct rcu_state *rsp)
/* Only let one CPU complain about others per time interval. */ /* Only let one CPU complain about others per time interval. */
raw_spin_lock_irqsave(&rnp->lock, flags); raw_spin_lock_irqsave(&rnp->lock, flags);
delta = jiffies - rsp->jiffies_stall; delta = jiffies - ACCESS_ONCE(rsp->jiffies_stall);
if (delta < RCU_STALL_RAT_DELAY || !rcu_gp_in_progress(rsp)) { if (delta < RCU_STALL_RAT_DELAY || !rcu_gp_in_progress(rsp)) {
raw_spin_unlock_irqrestore(&rnp->lock, flags); raw_spin_unlock_irqrestore(&rnp->lock, flags);
return; return;
} }
rsp->jiffies_stall = jiffies + 3 * rcu_jiffies_till_stall_check() + 3; ACCESS_ONCE(rsp->jiffies_stall) = jiffies + 3 * rcu_jiffies_till_stall_check() + 3;
raw_spin_unlock_irqrestore(&rnp->lock, flags); raw_spin_unlock_irqrestore(&rnp->lock, flags);
/* /*
...@@ -992,8 +992,8 @@ static void print_cpu_stall(struct rcu_state *rsp) ...@@ -992,8 +992,8 @@ static void print_cpu_stall(struct rcu_state *rsp)
dump_stack(); dump_stack();
raw_spin_lock_irqsave(&rnp->lock, flags); raw_spin_lock_irqsave(&rnp->lock, flags);
if (ULONG_CMP_GE(jiffies, rsp->jiffies_stall)) if (ULONG_CMP_GE(jiffies, ACCESS_ONCE(rsp->jiffies_stall)))
rsp->jiffies_stall = jiffies + ACCESS_ONCE(rsp->jiffies_stall) = jiffies +
3 * rcu_jiffies_till_stall_check() + 3; 3 * rcu_jiffies_till_stall_check() + 3;
raw_spin_unlock_irqrestore(&rnp->lock, flags); raw_spin_unlock_irqrestore(&rnp->lock, flags);
...@@ -1077,7 +1077,7 @@ void rcu_cpu_stall_reset(void) ...@@ -1077,7 +1077,7 @@ void rcu_cpu_stall_reset(void)
struct rcu_state *rsp; struct rcu_state *rsp;
for_each_rcu_flavor(rsp) for_each_rcu_flavor(rsp)
rsp->jiffies_stall = jiffies + ULONG_MAX / 2; ACCESS_ONCE(rsp->jiffies_stall) = jiffies + ULONG_MAX / 2;
} }
/* /*
......
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