rcutorture: Don't do need_resched() testing if ->sync is NULL
authorPaul E. McKenney <paulmck@kernel.org>
Sat, 10 Oct 2020 02:51:55 +0000 (19:51 -0700)
committerPaul E. McKenney <paulmck@kernel.org>
Sat, 7 Nov 2020 01:13:57 +0000 (17:13 -0800)
If cur_ops->sync is NULL, rcu_torture_fwd_prog_nr() will nevertheless
attempt to call through it.  This commit therefore flags cases where
neither need_resched() nor call_rcu() forward-progress testing
can be performed due to NULL function pointers, and also causes
rcu_torture_fwd_prog_nr() to take an early exit if cur_ops->sync()
is NULL.

Reported-by: Tom Rix <trix@redhat.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
kernel/rcu/rcutorture.c

index e7d52fded3cd03152a7bd8530e92d71510865bdf..4dfd113882aa0b5d717fd9ff16d7f787599e3731 100644 (file)
@@ -1923,7 +1923,9 @@ static void rcu_torture_fwd_prog_nr(struct rcu_fwd *rfp,
        unsigned long stopat;
        static DEFINE_TORTURE_RANDOM(trs);
 
-       if  (cur_ops->call && cur_ops->sync && cur_ops->cb_barrier) {
+       if (!cur_ops->sync)
+               return; // Cannot do need_resched() forward progress testing without ->sync.
+       if (cur_ops->call && cur_ops->cb_barrier) {
                init_rcu_head_on_stack(&fcs.rh);
                selfpropcb = true;
        }
@@ -2149,8 +2151,8 @@ static int __init rcu_torture_fwd_prog_init(void)
 
        if (!fwd_progress)
                return 0; /* Not requested, so don't do it. */
-       if (!cur_ops->stall_dur || cur_ops->stall_dur() <= 0 ||
-           cur_ops == &rcu_busted_ops) {
+       if ((!cur_ops->sync && !cur_ops->call) ||
+           !cur_ops->stall_dur || cur_ops->stall_dur() <= 0 || cur_ops == &rcu_busted_ops) {
                VERBOSE_TOROUT_STRING("rcu_torture_fwd_prog_init: Disabled, unsupported by RCU flavor under test");
                return 0;
        }