]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rcutorture: Make srcu_lockdep.sh check reader-conflict handling
authorPaul E. McKenney <paulmck@kernel.org>
Wed, 22 Jan 2025 23:59:30 +0000 (15:59 -0800)
committerJoel Fernandes <joelagnelf@nvidia.com>
Tue, 8 Apr 2025 18:55:38 +0000 (14:55 -0400)
Mixing different flavors of RCU readers is forbidden, for example, you
should not use srcu_read_lock() and srcu_read_lock_nmisafe() on the same
srcu_struct structure.  There are checks for this, but these checks are
not tested on a regular basis.  This commit therefore adds such tests
to srcu_lockdep.sh.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh

index b94f6d3445c6c621c0d29bdd5add8237cc94a293..208be7d09a612ac15b5d20a145083afbd5c9971d 100755 (executable)
@@ -79,6 +79,37 @@ do
        done
 done
 
+# Test lockdep-enabled testing of mixed SRCU readers.
+for val in 0x1 0xf
+do
+       err=
+       tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 5s --configs "SRCU-P" --kconfig "CONFIG_FORCE_NEED_SRCU_NMI_SAFE=y" --bootargs "rcutorture.reader_flavor=$val" --trust-make --datestamp "$ds/$val" > "$T/kvm.sh.out" 2>&1
+       ret=$?
+       mv "$T/kvm.sh.out" "$RCUTORTURE/res/$ds/$val"
+       if ! grep -q '^CONFIG_PROVE_LOCKING=y' .config
+       then
+               echo "rcu_torture_init_srcu_lockdep:Error: CONFIG_PROVE_LOCKING disabled in rcutorture SRCU-P scenario"
+               nerrs=$((nerrs+1))
+               err=1
+       fi
+       if test "$val" -eq 0xf && test "$ret" -eq 0
+       then
+               err=1
+               echo -n Unexpected success for > "$RCUTORTURE/res/$ds/$val/kvm.sh.err"
+       fi
+       if test "$val" -eq 0x1 && test "$ret" -ne 0
+       then
+               err=1
+               echo -n Unexpected failure for > "$RCUTORTURE/res/$ds/$val/kvm.sh.err"
+       fi
+       if test -n "$err"
+       then
+               grep "rcu_torture_init_srcu_lockdep: test_srcu_lockdep = " "$RCUTORTURE/res/$ds/$val/SRCU-P/console.log" | sed -e 's/^.*rcu_torture_init_srcu_lockdep://' >> "$RCUTORTURE/res/$ds/$val/kvm.sh.err"
+               cat "$RCUTORTURE/res/$ds/$val/kvm.sh.err"
+               nerrs=$((nerrs+1))
+       fi
+done
+
 # Set up exit code.
 if test "$nerrs" -ne 0
 then