Add testtypes 4 (atomic SRCU same-type deadlock) and 5 (atomic SRCU
+ raw_spinlock dependency cycle) to the deadlock-detection loop.
Add a separate loop for testtype 6 (rcu_read_lock() →
synchronize_srcu_atomic()), which also verifies via console.log that
no lockdep warning is triggered.

Co-developed-by: Zqiang <[email protected]>
Signed-off-by: Zqiang <[email protected]>
Signed-off-by: Kunwu Chan <[email protected]>
---
 .../selftests/rcutorture/bin/srcu_lockdep.sh  | 39 ++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh 
b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
index 4e98c697def4..72791499dd96 100755
--- a/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
+++ b/tools/testing/selftests/rcutorture/bin/srcu_lockdep.sh
@@ -44,7 +44,7 @@ nerrs=0
 # Test lockdep's handling of deadlocks.
 for d in 0 1
 do
-       for t in 0 1 2
+       for t in 0 1 2 4 5
        do
                for c in 1 2 3
                do
@@ -79,6 +79,43 @@ do
        done
 done
 
+# Verify that synchronize_srcu_atomic() does not trigger lockdep
+# warnings when called inside rcu_read_lock().
+for c in 1 2 3
+do
+       err=
+       val=$((6*10+c))
+       tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 5s \
+               --configs "SRCU-P" \
+               --kconfig "CONFIG_FORCE_NEED_SRCU_NMI_SAFE=y" \
+               --bootargs "rcutorture.test_srcu_lockdep=$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"
+               err=1
+       fi
+       if test "$ret" -ne 0
+       then
+               err=1
+               echo -n Unexpected failure for > 
"$RCUTORTURE/res/$ds/$val/kvm.sh.err"
+       elif grep -qE "WARNING: possible (recursive locking|circular locking 
dependency)" \
+               "$RCUTORTURE/res/$ds/$val/SRCU-P/console.log"
+       then
+               err=1
+               echo -n Unexpected lockdep warning 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
+
 # Test lockdep-enabled testing of mixed SRCU readers.
 for val in 0x1 0xf
 do
-- 
2.43.0


Reply via email to