Skip to content

Commit e3d6718

Browse files
paulmckrcuFrederic Weisbecker
authored andcommitted
srcu: Introduce srcu_gp_is_expedited() helper function
Even though the open-coded expressions usually fit on one line, this commit replaces them with a call to a new srcu_gp_is_expedited() helper function in order to improve readability. Signed-off-by: Paul E. McKenney <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Andrii Nakryiko <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Kent Overstreet <[email protected]> Cc: <[email protected]> Reviewed-by: Neeraj Upadhyay <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]>
1 parent 5bc455f commit e3d6718

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

kernel/rcu/srcutree.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,16 @@ static void check_init_srcu_struct(struct srcu_struct *ssp)
418418
spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags);
419419
}
420420

421+
/*
422+
* Is the current or any upcoming grace period to be expedited?
423+
*/
424+
static bool srcu_gp_is_expedited(struct srcu_struct *ssp)
425+
{
426+
struct srcu_usage *sup = ssp->srcu_sup;
427+
428+
return ULONG_CMP_LT(READ_ONCE(sup->srcu_gp_seq), READ_ONCE(sup->srcu_gp_seq_needed_exp));
429+
}
430+
421431
/*
422432
* Returns approximate total of the readers' ->srcu_lock_count[] values
423433
* for the rank of per-CPU counters specified by idx.
@@ -622,7 +632,7 @@ static unsigned long srcu_get_delay(struct srcu_struct *ssp)
622632
unsigned long jbase = SRCU_INTERVAL;
623633
struct srcu_usage *sup = ssp->srcu_sup;
624634

625-
if (ULONG_CMP_LT(READ_ONCE(sup->srcu_gp_seq), READ_ONCE(sup->srcu_gp_seq_needed_exp)))
635+
if (srcu_gp_is_expedited(ssp))
626636
jbase = 0;
627637
if (rcu_seq_state(READ_ONCE(sup->srcu_gp_seq))) {
628638
j = jiffies - 1;
@@ -867,7 +877,7 @@ static void srcu_gp_end(struct srcu_struct *ssp)
867877
spin_lock_irq_rcu_node(sup);
868878
idx = rcu_seq_state(sup->srcu_gp_seq);
869879
WARN_ON_ONCE(idx != SRCU_STATE_SCAN2);
870-
if (ULONG_CMP_LT(READ_ONCE(sup->srcu_gp_seq), READ_ONCE(sup->srcu_gp_seq_needed_exp)))
880+
if (srcu_gp_is_expedited(ssp))
871881
cbdelay = 0;
872882

873883
WRITE_ONCE(sup->srcu_last_gp_end, ktime_get_mono_fast_ns());

0 commit comments

Comments
 (0)