* [PATCH bpf] selftests/bpf: skip perf hw events test if the setup disabled it
@ 2020-01-17 10:06 Hangbin Liu
2020-01-20 5:04 ` John Fastabend
2020-01-20 22:40 ` Daniel Borkmann
0 siblings, 2 replies; 3+ messages in thread
From: Hangbin Liu @ 2020-01-17 10:06 UTC (permalink / raw)
To: netdev; +Cc: Song Liu, Daniel Borkmann, 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")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
.../selftests/bpf/prog_tests/stacktrace_build_id_nmi.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c b/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c
index f62aa0eb959b..437cb93e72ac 100644
--- a/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c
+++ b/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c
@@ -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;
--
2.19.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH bpf] selftests/bpf: skip perf hw events test if the setup disabled it
2020-01-17 10:06 [PATCH bpf] selftests/bpf: skip perf hw events test if the setup disabled it Hangbin Liu
@ 2020-01-20 5:04 ` John Fastabend
2020-01-20 22:40 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: John Fastabend @ 2020-01-20 5:04 UTC (permalink / raw)
To: Hangbin Liu, netdev; +Cc: Song Liu, Daniel Borkmann, Hangbin Liu
Hangbin Liu wrote:
> 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")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---
> .../selftests/bpf/prog_tests/stacktrace_build_id_nmi.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c b/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c
> index f62aa0eb959b..437cb93e72ac 100644
> --- a/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c
> +++ b/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c
> @@ -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;
>
Acked-by: John Fastabend <john.fastabend@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] selftests/bpf: skip perf hw events test if the setup disabled it
2020-01-17 10:06 [PATCH bpf] selftests/bpf: skip perf hw events test if the setup disabled it Hangbin Liu
2020-01-20 5:04 ` John Fastabend
@ 2020-01-20 22:40 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2020-01-20 22:40 UTC (permalink / raw)
To: Hangbin Liu, netdev; +Cc: Song Liu
On 1/17/20 11:06 AM, Hangbin Liu wrote:
> 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")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Applied to bpf-next, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-01-20 22:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-17 10:06 [PATCH bpf] selftests/bpf: skip perf hw events test if the setup disabled it Hangbin Liu
2020-01-20 5:04 ` John Fastabend
2020-01-20 22:40 ` Daniel Borkmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.