Skip to content

Commit 4fc5b75

Browse files
dotmndpaulmck
authored andcommitted
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: Iulia Manda <iulia.manda21@gmail.com> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
1 parent 9b67122 commit 4fc5b75

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎kernel/rcu/tree.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ static void record_gp_stall_check_time(struct rcu_state *rsp)
865865
rsp->gp_start = j;
866866
smp_wmb(); /* Record start time before stall time. */
867867
j1 = rcu_jiffies_till_stall_check();
868-
rsp->jiffies_stall = j + j1;
868+
ACCESS_ONCE(rsp->jiffies_stall) = j + j1;
869869
rsp->jiffies_resched = j + j1 / 2;
870870
}
871871

@@ -904,12 +904,12 @@ static void print_other_cpu_stall(struct rcu_state *rsp)
904904
/* Only let one CPU complain about others per time interval. */
905905

906906
raw_spin_lock_irqsave(&rnp->lock, flags);
907-
delta = jiffies - rsp->jiffies_stall;
907+
delta = jiffies - ACCESS_ONCE(rsp->jiffies_stall);
908908
if (delta < RCU_STALL_RAT_DELAY || !rcu_gp_in_progress(rsp)) {
909909
raw_spin_unlock_irqrestore(&rnp->lock, flags);
910910
return;
911911
}
912-
rsp->jiffies_stall = jiffies + 3 * rcu_jiffies_till_stall_check() + 3;
912+
ACCESS_ONCE(rsp->jiffies_stall) = jiffies + 3 * rcu_jiffies_till_stall_check() + 3;
913913
raw_spin_unlock_irqrestore(&rnp->lock, flags);
914914

915915
/*
@@ -992,8 +992,8 @@ static void print_cpu_stall(struct rcu_state *rsp)
992992
dump_stack();
993993

994994
raw_spin_lock_irqsave(&rnp->lock, flags);
995-
if (ULONG_CMP_GE(jiffies, rsp->jiffies_stall))
996-
rsp->jiffies_stall = jiffies +
995+
if (ULONG_CMP_GE(jiffies, ACCESS_ONCE(rsp->jiffies_stall)))
996+
ACCESS_ONCE(rsp->jiffies_stall) = jiffies +
997997
3 * rcu_jiffies_till_stall_check() + 3;
998998
raw_spin_unlock_irqrestore(&rnp->lock, flags);
999999

@@ -1077,7 +1077,7 @@ void rcu_cpu_stall_reset(void)
10771077
struct rcu_state *rsp;
10781078

10791079
for_each_rcu_flavor(rsp)
1080-
rsp->jiffies_stall = jiffies + ULONG_MAX / 2;
1080+
ACCESS_ONCE(rsp->jiffies_stall) = jiffies + ULONG_MAX / 2;
10811081
}
10821082

10831083
/*

0 commit comments

Comments
 (0)