Skip to contentSkip to conversation

selftests/bpf: skip perf hw events test if the setup disabled it

PATCH Applied Hangbin Liu 3 participants 3 messages Jan 17, 2020 – Jan 20, 2020

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

PATCH 1/1 selftests/bpf: skip perf hw events test if the setup disabled it

The same with commit 4e59afbbed96 ("selftests/bpf: skip nmi test when perf hw events are disabled"), it would make more sense to skip the test_stacktrace_build_id_nmi test if the setup (e.g. virtual machines) has disabled hardware perf events.

Fixes 13790d1cc72c ("bpf: add selftest for stackmap with build_id in NMI context")
---
 .../selftests/bpf/prog_tests/stacktrace_build_id_nmi.c    | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c +6 -2
index f62aa0eb959b..437cb93e72ac 100644
@@ -49,8 +49,12 @@ void test_stacktrace_build_id_nmi(void)
 	pmu_fd = syscall(__NR_perf_event_open, &attr, -1 /* pid */,
 			 0 /* cpu 0 */, -1 /* group id */,
 			 0 /* flags */);
-	if (CHECK(pmu_fd < 0, "perf_event_open",
-		  "err %d errno %d. Does the test host support PERF_COUNT_HW_CPU_CYCLES?\n",
+	if (pmu_fd < 0 && errno == ENOENT) {
+		printf("%s:SKIP:no PERF_COUNT_HW_CPU_CYCLES\n", __func__);
+		test__skip();
+		goto close_prog;
+	}
+	if (CHECK(pmu_fd < 0, "perf_event_open", "err %d errno %d\n",
 		  pmu_fd, errno))
 		goto close_prog;
 
Signature · 1 line
2.19.2
Acked-by on v1 1/1
#1 lore raw
Quoted 20 lines · Hangbin Liu

The same with commit 4e59afbbed96 ("selftests/bpf: skip nmi test when perf hw events are disabled"), it would make more sense to skip the test_stacktrace_build_id_nmi test if the setup (e.g. virtual machines) has disabled hardware perf events.

Fixes 13790d1cc72c ("bpf: add selftest for stackmap with build_id in NMI context")
---
 .../selftests/bpf/prog_tests/stacktrace_build_id_nmi.c    | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c +0 -1
index f62aa0eb959b..437cb93e72ac 100644
@@ -49,8 +49,12 @@ void test_stacktrace_build_id_nmi(void)
 	pmu_fd = syscall(__NR_perf_event_open, &attr, -1 /* pid */,
 			 0 /* cpu 0 */, -1 /* group id */,
 			 0 /* flags */);
-	if (CHECK(pmu_fd < 0, "perf_event_open",

tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c void test_stacktrace_build_id_nmi(void) · line 60

Quoted 10 lines
tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c +6 -1
-		  "err %d errno %d. Does the test host support PERF_COUNT_HW_CPU_CYCLES?\n",
+	if (pmu_fd < 0 && errno == ENOENT) {
+		printf("%s:SKIP:no PERF_COUNT_HW_CPU_CYCLES\n", __func__);
+		test__skip();
+		goto close_prog;
+	}
+	if (CHECK(pmu_fd < 0, "perf_event_open", "err %d errno %d\n",
 		  pmu_fd, errno))
 		goto close_prog;
 
maintainer Applied
#2 lore raw
In reply to Hangbin Liu
Quoted 7 lines · Hangbin Liu

The same with commit 4e59afbbed96 ("selftests/bpf: skip nmi test when perf hw events are disabled"), it would make more sense to skip the test_stacktrace_build_id_nmi test if the setup (e.g. virtual machines) has disabled hardware perf events.

Fixes 13790d1cc72c ("bpf: add selftest for stackmap with build_id in NMI context")

Applied to bpf-next, thanks!