Skip to content

Commit 4d86b1e

Browse files
paulmckrcufbq
authored andcommitted
srcu: Add SRCU_READ_FLAVOR_SLOWGP to flag need for synchronize_rcu()
This commit switches from a direct test of SRCU_READ_FLAVOR_LITE to a new SRCU_READ_FLAVOR_SLOWGP macro to check for substituting synchronize_rcu() for smp_mb() in SRCU grace periods. Right now, SRCU_READ_FLAVOR_SLOWGP is exactly SRCU_READ_FLAVOR_LITE, but the addition of the _fast() flavor of SRCU will change that. 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]> Signed-off-by: Boqun Feng <[email protected]>
1 parent 780818a commit 4d86b1e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

include/linux/srcu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ int init_srcu_struct(struct srcu_struct *ssp);
4949
#define SRCU_READ_FLAVOR_LITE 0x4 // srcu_read_lock_lite().
5050
#define SRCU_READ_FLAVOR_ALL (SRCU_READ_FLAVOR_NORMAL | SRCU_READ_FLAVOR_NMI | \
5151
SRCU_READ_FLAVOR_LITE) // All of the above.
52+
#define SRCU_READ_FLAVOR_SLOWGP SRCU_READ_FLAVOR_LITE
53+
// Flavors requiring synchronize_rcu()
54+
// instead of smp_mb().
5255

5356
#ifdef CONFIG_TINY_SRCU
5457
#include <linux/srcutiny.h>

kernel/rcu/srcutree.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ static bool srcu_readers_lock_idx(struct srcu_struct *ssp, int idx, bool gp, uns
449449
}
450450
WARN_ONCE(IS_ENABLED(CONFIG_PROVE_RCU) && (mask & (mask - 1)),
451451
"Mixed reader flavors for srcu_struct at %ps.\n", ssp);
452-
if (mask & SRCU_READ_FLAVOR_LITE && !gp)
452+
if (mask & SRCU_READ_FLAVOR_SLOWGP && !gp)
453453
return false;
454454
return sum == unlocks;
455455
}
@@ -487,7 +487,7 @@ static bool srcu_readers_active_idx_check(struct srcu_struct *ssp, int idx)
487487
unsigned long unlocks;
488488

489489
unlocks = srcu_readers_unlock_idx(ssp, idx, &rdm);
490-
did_gp = !!(rdm & SRCU_READ_FLAVOR_LITE);
490+
did_gp = !!(rdm & SRCU_READ_FLAVOR_SLOWGP);
491491

492492
/*
493493
* Make sure that a lock is always counted if the corresponding
@@ -1205,7 +1205,7 @@ static bool srcu_should_expedite(struct srcu_struct *ssp)
12051205

12061206
check_init_srcu_struct(ssp);
12071207
/* If _lite() readers, don't do unsolicited expediting. */
1208-
if (this_cpu_read(ssp->sda->srcu_reader_flavor) & SRCU_READ_FLAVOR_LITE)
1208+
if (this_cpu_read(ssp->sda->srcu_reader_flavor) & SRCU_READ_FLAVOR_SLOWGP)
12091209
return false;
12101210
/* If the local srcu_data structure has callbacks, not idle. */
12111211
sdp = raw_cpu_ptr(ssp->sda);

0 commit comments

Comments
 (0)