]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rcutorture: Make Trivial RCU ignore onoff_interval and shuffle_interval
authorPaul E. McKenney <paulmck@kernel.org>
Fri, 16 May 2025 21:20:46 +0000 (14:20 -0700)
committerNeeraj Upadhyay (AMD) <neeraj.upadhyay@kernel.org>
Wed, 25 Jun 2025 03:09:01 +0000 (08:39 +0530)
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 <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202505131651.af6e81d7-lkp@intel.com
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Neeraj Upadhyay (AMD) <neeraj.upadhyay@kernel.org>
kernel/rcu/rcutorture.c

index 470b5a117602b986cc3ae3f765a71a5f8993297f..7a07b2590c27e7ea51ee17b320db388f23a992e9 100644 (file)
@@ -969,7 +969,8 @@ static struct rcu_torture_ops busted_srcud_ops = {
 
 /*
  * Definitions for trivial CONFIG_PREEMPT=n-only torture testing.
- * This implementation does not necessarily work well with CPU hotplug.
+ * This implementation does not work well with CPU hotplug nor
+ * with rcutorture's shuffling.
  */
 
 static void synchronize_rcu_trivial(void)
@@ -982,6 +983,16 @@ static void synchronize_rcu_trivial(void)
        }
 }
 
+static void rcu_sync_torture_init_trivial(void)
+{
+       rcu_sync_torture_init();
+       // if (onoff_interval || shuffle_interval) {
+       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)) {
+               onoff_interval = 0;
+               shuffle_interval = 0;
+       }
+}
+
 static int rcu_torture_read_lock_trivial(void)
 {
        preempt_disable();
@@ -995,7 +1006,7 @@ static void rcu_torture_read_unlock_trivial(int idx)
 
 static struct rcu_torture_ops trivial_ops = {
        .ttype          = RCU_TRIVIAL_FLAVOR,
-       .init           = rcu_sync_torture_init,
+       .init           = rcu_sync_torture_init_trivial,
        .readlock       = rcu_torture_read_lock_trivial,
        .read_delay     = rcu_read_delay,  /* just reuse rcu's version. */
        .readunlock     = rcu_torture_read_unlock_trivial,