Skip to contentSkip to conversation

selftests/bpf: Add ABBCCA case for rqspinlock stress test

PATCH In review Kumar Kartikeya Dwivedi 3 participants 4 messages Oct 22, 2025 – Oct 24, 2025

Subsystems (3)
lore
Share & tools
lore

Kumar Kartikeya Dwivedi

author maintainer
#0 lore raw

PATCH 1/1 selftests/bpf: Add ABBCCA case for rqspinlock stress test

Introduce a new mode for the rqspinlock stress test that exercises a deadlock that won't be detected by the AA and ABBA checks, such that we always reliably trigger the timeout fallback. We need 4 CPUs for this particular case, as CPU 0 is untouched, and three participant CPUs for triggering the ABBCCA case.

Refactor the lock acquisition paths in the module to better reflect the three modes and choose the right lock depending on the context.

---
 .../selftests/bpf/prog_tests/res_spin_lock.c  | 11 ++-
 .../bpf/test_kmods/bpf_test_rqspinlock.c      | 85 ++++++++++++++-----
 2 files changed, 72 insertions(+), 24 deletions(-)
tools/testing/selftests/bpf/prog_tests/res_spin_lock.c +10 -1
index 8c6c2043a432..f566d89f85ea 100644
@@ -111,7 +111,16 @@ void serial_test_res_spin_lock_stress(void)
 	sleep(5);
 	unload_module("bpf_test_rqspinlock", false);
 
-	ASSERT_OK(load_module_params("bpf_test_rqspinlock.ko", "test_ab=1", false), "load module ABBA");
+	ASSERT_OK(load_module_params("bpf_test_rqspinlock.ko", "test_mode=1", false), "load module ABBA");
+	sleep(5);
+	unload_module("bpf_test_rqspinlock", false);
+
+	if (libbpf_num_possible_cpus() < 4) {
+		test__skip();
+		return;
+	}
+
+	ASSERT_OK(load_module_params("bpf_test_rqspinlock.ko", "test_mode=2", false), "load module ABBCCA");
 	sleep(5);
 	unload_module("bpf_test_rqspinlock", false);
 }
tools/testing/selftests/bpf/test_kmods/bpf_test_rqspinlock.c +62 -23

140 lines not on this page · raw message

--
2.51.0

maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Kumar Kartikeya Dwivedi

Introduce a new mode for the rqspinlock stress test that exercises a deadlock that won't be detected by the AA and ABBA checks, such that we always reliably trigger the timeout fallback. We need 4 CPUs for this particular case, as CPU 0 is untouched, and three participant CPUs for triggering the ABBCCA case.

Refactor the lock acquisition paths in the module to better reflect the three modes and choose the right lock depending on the context.

---

The overhaul makes sense to me and the code is easy to follow. The only nit I have is that test does not fail if deadlock is not detected. E.g. if I remove raw_res_spin_unlock_irqrestore() call in nmi_cb(), there are stall splats in dmesg, but test harness reports success. I suggest adding some signal that all kthreads terminated successfully.

[...]

Reviewed-by
#2 lore raw
Quoted 14 lines · Eduard Zingerman
Quoted 11 lines · Kumar Kartikeya Dwivedi

Introduce a new mode for the rqspinlock stress test that exercises a deadlock that won't be detected by the AA and ABBA checks, such that we always reliably trigger the timeout fallback. We need 4 CPUs for this particular case, as CPU 0 is untouched, and three participant CPUs for triggering the ABBCCA case.

Refactor the lock acquisition paths in the module to better reflect the three modes and choose the right lock depending on the context.

---

Quoted 8 lines

The overhaul makes sense to me and the code is easy to follow. The only nit I have is that test does not fail if deadlock is not detected. E.g. if I remove raw_res_spin_unlock_irqrestore() call in nmi_cb(), there are stall splats in dmesg, but test harness reports success. I suggest adding some signal that all kthreads terminated successfully.

Maybe it should be another way around? The test must and should have triggered deadlocks, so if we count how many times the return of raw_res_spin_lock_irqrestore == -EDEADLK or -EITMEDOUT, the number should be non-zero.

The test looks good to me otherwise.

Quoted 2 lines

[...]

maintainer
#3 lore raw
Quoted 21 lines · Amery Hung
Quoted 20 lines · Eduard Zingerman
Quoted 11 lines · Kumar Kartikeya Dwivedi

Introduce a new mode for the rqspinlock stress test that exercises a deadlock that won't be detected by the AA and ABBA checks, such that we always reliably trigger the timeout fallback. We need 4 CPUs for this particular case, as CPU 0 is untouched, and three participant CPUs for triggering the ABBCCA case.

Refactor the lock acquisition paths in the module to better reflect the three modes and choose the right lock depending on the context.

---

The overhaul makes sense to me and the code is easy to follow. The only nit I have is that test does not fail if deadlock is not detected. E.g. if I remove raw_res_spin_unlock_irqrestore() call in nmi_cb(), there are stall splats in dmesg, but test harness reports success. I suggest adding some signal that all kthreads terminated successfully.

Quoted 7 lines
Quoted 2 lines

Maybe it should be another way around? The test must and should have triggered deadlocks, so if we count how many times the return of raw_res_spin_lock_irqrestore == -EDEADLK or -EITMEDOUT, the number should be non-zero.

+1, that would be a good thing to check.

Quoted 4 lines

The test looks good to me otherwise.