Skip to content

Commit 5f2417b

Browse files
paulmckrcuNeeraj Upadhyay (AMD)
authored andcommitted
rcutorture: Make Trivial RCU ignore onoff_interval and shuffle_interval
Trivial RCU is a textbook implementation that is not used in the Linux kernel, but tested to keep textbooks (and presentations) honest. It is so trivial that it cannot deal with either CPU hotplug or external migration from one CPU to another. This commit therefore splats whenever onoff_interval or shuffle_interval are non-zero, and then sets them to zero in order to avoid false-positive failures. Those wishing to set these module parameters in order to force failures in Trivial RCU are free to revert this commit. Just don't expect me to be sympathetic to any resulting bug reports! Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-lkp/[email protected] Signed-off-by: Paul E. McKenney <[email protected]> Signed-off-by: Neeraj Upadhyay (AMD) <[email protected]>
1 parent f32367d commit 5f2417b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

kernel/rcu/rcutorture.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,8 @@ static struct rcu_torture_ops busted_srcud_ops = {
969969

970970
/*
971971
* Definitions for trivial CONFIG_PREEMPT=n-only torture testing.
972-
* This implementation does not necessarily work well with CPU hotplug.
972+
* This implementation does not work well with CPU hotplug nor
973+
* with rcutorture's shuffling.
973974
*/
974975

975976
static void synchronize_rcu_trivial(void)
@@ -982,6 +983,16 @@ static void synchronize_rcu_trivial(void)
982983
}
983984
}
984985

986+
static void rcu_sync_torture_init_trivial(void)
987+
{
988+
rcu_sync_torture_init();
989+
// if (onoff_interval || shuffle_interval) {
990+
if (WARN_ONCE(onoff_interval || shuffle_interval, "%s: Non-zero onoff_interval (%d) or shuffle_interval (%d) breaks trivial RCU, resetting to zero", __func__, onoff_interval, shuffle_interval)) {
991+
onoff_interval = 0;
992+
shuffle_interval = 0;
993+
}
994+
}
995+
985996
static int rcu_torture_read_lock_trivial(void)
986997
{
987998
preempt_disable();
@@ -995,7 +1006,7 @@ static void rcu_torture_read_unlock_trivial(int idx)
9951006

9961007
static struct rcu_torture_ops trivial_ops = {
9971008
.ttype = RCU_TRIVIAL_FLAVOR,
998-
.init = rcu_sync_torture_init,
1009+
.init = rcu_sync_torture_init_trivial,
9991010
.readlock = rcu_torture_read_lock_trivial,
10001011
.read_delay = rcu_read_delay, /* just reuse rcu's version. */
10011012
.readunlock = rcu_torture_read_unlock_trivial,

0 commit comments

Comments
 (0)