Skip to contentSkip to conversation

selftests/bpf: skip the timer_lockup test for single-CPU nodes

PATCH Applied Viktor Malik 4 participants 4 messages Nov 7, 2024 – Nov 9, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: skip the timer_lockup test for single-CPU nodes

The timer_lockup test needs 2 CPUs to work, on single-CPU nodes it fails to set thread affinity to CPU 1 since it doesn't exist:

    # ./test_progs -t test_lockup
    test_timer_lockup:PASS:timer_lockup__open_and_load 0 nsec
    test_timer_lockup:PASS:pthread_create thread1 0 nsec
    test_timer_lockup:PASS:pthread_create thread2 0 nsec
    timer_lockup_thread:PASS:cpu affinity 0 nsec
    timer_lockup_thread:FAIL:cpu affinity unexpected error: 22 (errno 0)
    test_timer_lockup:PASS: 0 nsec
    #406     timer_lockup:FAIL

Skip the test if only 1 CPU is available.

Fixes 50bd5a0c658d1 ("selftests/bpf: Add timer lockup selftest")
---
 tools/testing/selftests/bpf/prog_tests/timer_lockup.c | 6 ++++++
 1 file changed, 6 insertions(+)
tools/testing/selftests/bpf/prog_tests/timer_lockup.c +6 -0
index 871d16cb95cf..1a2f99596916 100644
@@ -5,6 +5,7 @@
 #include <test_progs.h>
 #include <pthread.h>
 #include <network_helpers.h>
+#include <sys/sysinfo.h>
 
 #include "timer_lockup.skel.h"
 
@@ -52,6 +53,11 @@ void test_timer_lockup(void)
 	pthread_t thrds[2];
 	void *ret;
 
+	if (get_nprocs() < 2) {
+		test__skip();
+		return;
+	}
+
 	skel = timer_lockup__open_and_load();
 	if (!ASSERT_OK_PTR(skel, "timer_lockup__open_and_load"))
 		return;
Signature · 1 line
2.47.0
Tested-by on v1 1/1
#1 lore raw
Quoted 4 lines · Viktor Malik

The timer_lockup test needs 2 CPUs to work, on single-CPU nodes it fails to set thread affinity to CPU 1 since it doesn't exist:

     # ./test_progs -t test_lockup

nit: s/test_lockup/timer_lockup

Quoted 8 lines

test_timer_lockup:PASS:timer_lockup__open_and_load 0 nsec test_timer_lockup:PASS:pthread_create thread1 0 nsec test_timer_lockup:PASS:pthread_create thread2 0 nsec timer_lockup_thread:PASS:cpu affinity 0 nsec timer_lockup_thread:FAIL:cpu affinity unexpected error: 22 (errno 0) test_timer_lockup:PASS: 0 nsec
#406 timer_lockup:FAIL

Quoted 5 lines

Skip the test if only 1 CPU is available.

Fixes 50bd5a0c658d1 ("selftests/bpf: Add timer lockup selftest")

---

Can reproduce this issue and this patch solves it.

Cheers.

Signature · 1 line
Philo
maintainer Acked-by
#2 lore raw
Quoted 25 lines · Philo Lu
Quoted 4 lines · Viktor Malik

The timer_lockup test needs 2 CPUs to work, on single-CPU nodes it fails to set thread affinity to CPU 1 since it doesn't exist:

     # ./test_progs -t test_lockup

nit: s/test_lockup/timer_lockup

Quoted 13 lines

test_timer_lockup:PASS:timer_lockup__open_and_load 0 nsec test_timer_lockup:PASS:pthread_create thread1 0 nsec test_timer_lockup:PASS:pthread_create thread2 0 nsec timer_lockup_thread:PASS:cpu affinity 0 nsec timer_lockup_thread:FAIL:cpu affinity unexpected error: 22 (errno 0) test_timer_lockup:PASS: 0 nsec
#406 timer_lockup:FAIL

Skip the test if only 1 CPU is available.

Fixes 50bd5a0c658d1 ("selftests/bpf: Add timer lockup selftest")

---

Quoted 2 lines

[...]

#3 lore raw
In reply to Viktor Malik
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Quoted 12 lines · On Thu, 7 Nov 2024 12:52:31 +0100 you wrote:

The timer_lockup test needs 2 CPUs to work, on single-CPU nodes it fails to set thread affinity to CPU 1 since it doesn't exist:

    # ./test_progs -t test_lockup
    test_timer_lockup:PASS:timer_lockup__open_and_load 0 nsec
    test_timer_lockup:PASS:pthread_create thread1 0 nsec
    test_timer_lockup:PASS:pthread_create thread2 0 nsec
    timer_lockup_thread:PASS:cpu affinity 0 nsec
    timer_lockup_thread:FAIL:cpu affinity unexpected error: 22 (errno 0)
    test_timer_lockup:PASS: 0 nsec
    #406     timer_lockup:FAIL
Quoted 1 line

[...]

Here is the summary with links:
- [bpf-next] selftests/bpf: skip the timer_lockup test for single-CPU nodes

    https://git.kernel.org/bpf/bpf-next/c/5bfc4f22e0d7

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html