Skip to content

Commit 844a378

Browse files
committed
srcu: Apply *_ONCE() to ->srcu_last_gp_end
The ->srcu_last_gp_end field is accessed from any CPU at any time by synchronize_srcu(), so non-initialization references need to use READ_ONCE() and WRITE_ONCE(). This commit therefore makes that change. Reported-by: [email protected] Acked-by: Marco Elver <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 7441e76 commit 844a378

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

kernel/rcu/srcutree.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ static void srcu_gp_end(struct srcu_struct *ssp)
530530
idx = rcu_seq_state(ssp->srcu_gp_seq);
531531
WARN_ON_ONCE(idx != SRCU_STATE_SCAN2);
532532
cbdelay = srcu_get_delay(ssp);
533-
ssp->srcu_last_gp_end = ktime_get_mono_fast_ns();
533+
WRITE_ONCE(ssp->srcu_last_gp_end, ktime_get_mono_fast_ns());
534534
rcu_seq_end(&ssp->srcu_gp_seq);
535535
gpseq = rcu_seq_current(&ssp->srcu_gp_seq);
536536
if (ULONG_CMP_LT(ssp->srcu_gp_seq_needed_exp, gpseq))
@@ -762,6 +762,7 @@ static bool srcu_might_be_idle(struct srcu_struct *ssp)
762762
unsigned long flags;
763763
struct srcu_data *sdp;
764764
unsigned long t;
765+
unsigned long tlast;
765766

766767
/* If the local srcu_data structure has callbacks, not idle. */
767768
local_irq_save(flags);
@@ -780,9 +781,9 @@ static bool srcu_might_be_idle(struct srcu_struct *ssp)
780781

781782
/* First, see if enough time has passed since the last GP. */
782783
t = ktime_get_mono_fast_ns();
784+
tlast = READ_ONCE(ssp->srcu_last_gp_end);
783785
if (exp_holdoff == 0 ||
784-
time_in_range_open(t, ssp->srcu_last_gp_end,
785-
ssp->srcu_last_gp_end + exp_holdoff))
786+
time_in_range_open(t, tlast, tlast + exp_holdoff))
786787
return false; /* Too soon after last GP. */
787788

788789
/* Next, check for probable idleness. */

0 commit comments

Comments
 (0)