Re: [PATCH bpf-next] selftests/bpf: Skip test when perf_event_open returns EOPNOTSUPP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 4/1/24 5:33 AM, Pu Lehui wrote:
From: Pu Lehui <pulehui@xxxxxxxxxx>

For the bpf selftest, the semantics of perf_event_open returning ENOENT
and EOPNOTSUPP imply that continuing the test is meaningless. Let’s skip
test when perf_event_open returns EOPNOTSUPP, which has already been
skipped in other test cases.

Could you explain when EOPNOTSUPP is returned for these two tests?
Is this riscv specific? If the EOPNOTSUPP is returned due to missing
config in tools/testing/selftests/bpf/config, we should add that to
ensure the test can execute properly.


Signed-off-by: Pu Lehui <pulehui@xxxxxxxxxx>
---
  tools/testing/selftests/bpf/prog_tests/send_signal.c            | 2 +-
  .../testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c  | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/send_signal.c b/tools/testing/selftests/bpf/prog_tests/send_signal.c
index b15b343ebb6b..920aee41bd58 100644
--- a/tools/testing/selftests/bpf/prog_tests/send_signal.c
+++ b/tools/testing/selftests/bpf/prog_tests/send_signal.c
@@ -179,7 +179,7 @@ static void test_send_signal_nmi(bool signal_thread)
  	pmu_fd = syscall(__NR_perf_event_open, &attr, 0 /* pid */,
  			 -1 /* cpu */, -1 /* group_fd */, 0 /* flags */);
  	if (pmu_fd == -1) {
-		if (errno == ENOENT) {
+		if (errno == ENOENT || errno == EOPNOTSUPP) {
  			printf("%s:SKIP:no PERF_COUNT_HW_CPU_CYCLES\n",
  			       __func__);
  			test__skip();
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 5db9eec24b5b..0832fd787457 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
@@ -35,7 +35,7 @@ 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 (pmu_fd < 0 && errno == ENOENT) {
+	if (pmu_fd < 0 && (errno == ENOENT || errno == EOPNOTSUPP)) {
  		printf("%s:SKIP:no PERF_COUNT_HW_CPU_CYCLES\n", __func__);
  		test__skip();
  		goto cleanup;




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux