selftests/bpf: Add ABBCCA case for rqspinlock stress test
Subsystems (3)
Kumar Kartikeya Dwivedi
maintainerPATCH 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
@@ -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
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.
Signed-off-by Kumar Kartikeya Dwivedi <[email protected]>---
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.
[...]
Amery Hung
Reviewed-byQuoted 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.
Signed-off-by Kumar Kartikeya Dwivedi <[email protected]>---
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 innmi_cb(), there are stall splats in dmesg, but test harness reports success. I suggest adding some signal that all kthreads terminated successfully.Acked-by Eduard Zingerman <[email protected]>
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
[...]
Eduard Zingerman
maintainerQuoted 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.
Signed-off-by Kumar Kartikeya Dwivedi <[email protected]>---
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 innmi_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
Acked-by Eduard Zingerman <[email protected]>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==-EDEADLKor-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.
Reviewed-by Amery Hung <[email protected]>