diff mbox series

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

Message ID 20240401123336.1124715-1-pulehui@huaweicloud.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series [bpf-next] selftests/bpf: Skip test when perf_event_open returns EOPNOTSUPP | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR success PR summary
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for bpf-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: shuah@kernel.org linux-kselftest@vger.kernel.org
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-11 success Logs for s390x-gcc / build / build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for x86_64-llvm-17 / build / build for x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-34 success Logs for x86_64-llvm-17 / veristat
bpf/vmtest-bpf-next-VM_Test-5 success Logs for aarch64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-18 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-42 success Logs for x86_64-llvm-18 / veristat
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Unittests
bpf/vmtest-bpf-next-VM_Test-35 success Logs for x86_64-llvm-18 / build / build for x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-0 success Logs for Lint
bpf/vmtest-bpf-next-VM_Test-4 success Logs for aarch64-gcc / build / build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-19 success Logs for x86_64-gcc / build / build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for Validate matrix.py
bpf/vmtest-bpf-next-VM_Test-9 success Logs for aarch64-gcc / test (test_verifier, false, 360) / test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-21 success Logs for x86_64-gcc / test (test_maps, false, 360) / test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-33 success Logs for x86_64-llvm-17 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-10 success Logs for aarch64-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-16 success Logs for s390x-gcc / test (test_verifier, false, 360) / test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-41 success Logs for x86_64-llvm-18 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-30 success Logs for x86_64-llvm-17 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-36 success Logs for x86_64-llvm-18 / build-release / build for x86_64 with llvm-18 and -O2 optimization
bpf/vmtest-bpf-next-VM_Test-29 success Logs for x86_64-llvm-17 / build-release / build for x86_64 with llvm-17 and -O2 optimization
bpf/vmtest-bpf-next-VM_Test-17 success Logs for s390x-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-12 success Logs for s390x-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-37 success Logs for x86_64-llvm-18 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-26 success Logs for x86_64-gcc / test (test_verifier, false, 360) / test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for x86_64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-7 success Logs for aarch64-gcc / test (test_progs, false, 360) / test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for aarch64-gcc / test (test_maps, false, 360) / test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for x86_64-gcc / veristat / veristat on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for x86_64-gcc / test (test_progs_no_alu32_parallel, true, 30) / test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-38 success Logs for x86_64-llvm-18 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-22 success Logs for x86_64-gcc / test (test_progs, false, 360) / test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for x86_64-gcc / test (test_progs_parallel, true, 30) / test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for s390x-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for x86_64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-32 success Logs for x86_64-llvm-17 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-31 success Logs for x86_64-llvm-17 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-39 success Logs for x86_64-llvm-18 / test (test_progs_cpuv4, false, 360) / test_progs_cpuv4 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-13 success Logs for s390x-gcc / test (test_maps, false, 360) / test_maps on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-40 success Logs for x86_64-llvm-18 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-8 success Logs for aarch64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-14 success Logs for s390x-gcc / test (test_progs, false, 360) / test_progs on s390x with gcc

Commit Message

Pu Lehui April 1, 2024, 12:33 p.m. UTC
From: Pu Lehui <pulehui@huawei.com>

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.

Signed-off-by: Pu Lehui <pulehui@huawei.com>
---
 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(-)

Comments

Yonghong Song April 1, 2024, 3:29 p.m. UTC | #1
On 4/1/24 5:33 AM, Pu Lehui wrote:
> From: Pu Lehui <pulehui@huawei.com>
>
> 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@huawei.com>
> ---
>   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;
Pu Lehui April 2, 2024, 2:22 a.m. UTC | #2
On 2024/4/1 23:29, Yonghong Song wrote:
> 
> On 4/1/24 5:33 AM, Pu Lehui wrote:
>> From: Pu Lehui <pulehui@huawei.com>
>>
>> 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.
> 

Hello Yonghong, I tested on riscv but it is not unique to riscv. When 
the perf driver does not support sampling events, perf_event_open will 
return EOPNOTSUPP, that is, PERF_PMU_CAP_NO_INTERRUPT is set to the pmu 
capabilities. This is no problem with riscv with sscofpmf extension and 
sbi pmu driver. I found that PERF_PMU_CAP_NO_INTERRUPT is set not only 
in the riscv-related perf driver. At the same time, it is possible to 
return EOPNOTSUPP about PERF_PMU_CAP_AUX_OUTPUT on the path of 
perf_event_open. I think it resonable to skip such use cases for 
functions not supported by non-bpf modules, what do you think?

>>
>> Signed-off-by: Pu Lehui <pulehui@huawei.com>
>> ---
>>   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;
Yonghong Song April 2, 2024, 6:16 a.m. UTC | #3
On 4/1/24 7:22 PM, Pu Lehui wrote:
>
>
> On 2024/4/1 23:29, Yonghong Song wrote:
>>
>> On 4/1/24 5:33 AM, Pu Lehui wrote:
>>> From: Pu Lehui <pulehui@huawei.com>
>>>
>>> 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.
>>
>
> Hello Yonghong, I tested on riscv but it is not unique to riscv. When 
> the perf driver does not support sampling events, perf_event_open will 
> return EOPNOTSUPP, that is, PERF_PMU_CAP_NO_INTERRUPT is set to the 
> pmu capabilities. This is no problem with riscv with sscofpmf 
> extension and sbi pmu driver. I found that PERF_PMU_CAP_NO_INTERRUPT 
> is set not only in the riscv-related perf driver. At the same time, it 
> is possible to return EOPNOTSUPP about PERF_PMU_CAP_AUX_OUTPUT on the 
> path of perf_event_open. I think it resonable to skip such use cases 
> for functions not supported by non-bpf modules, what do you think?

Thanks for explanation. I checked kernel/events/core.c and arch/x86/.... I agree that if hardware has capabilities PERF_PMU_CAP_NO_INTERRUPT
or PERF_PMU_CAP_AUX_OUTPUT, EOPNOTSUPP could be returned, although I think this should be extremely rare for x86 cpu's (probably only really old ones).
Several other arch's also have hardware which has capability PERF_PMU_CAP_NO_INTERRUPT, so may indeed hit this issue.

In bpf-next/arch/riscv, I didn't find usage of PERF_PMU_CAP_NO_INTERRUPT though.

Your patch looks good to me. Since you hit the issue with riscv so please describe how EOPNOTSUPP could be returned in your test. It would be a good
justification for your patch.

>
>>>
>>> Signed-off-by: Pu Lehui <pulehui@huawei.com>
>>> ---
>>> 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;
>
Pu Lehui April 2, 2024, 6:32 a.m. UTC | #4
On 2024/4/2 14:16, Yonghong Song wrote:
> 
> On 4/1/24 7:22 PM, Pu Lehui wrote:
>>
>>
>> On 2024/4/1 23:29, Yonghong Song wrote:
>>>
>>> On 4/1/24 5:33 AM, Pu Lehui wrote:
>>>> From: Pu Lehui <pulehui@huawei.com>
>>>>
>>>> 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.
>>>
>>
>> Hello Yonghong, I tested on riscv but it is not unique to riscv. When 
>> the perf driver does not support sampling events, perf_event_open will 
>> return EOPNOTSUPP, that is, PERF_PMU_CAP_NO_INTERRUPT is set to the 
>> pmu capabilities. This is no problem with riscv with sscofpmf 
>> extension and sbi pmu driver. I found that PERF_PMU_CAP_NO_INTERRUPT 
>> is set not only in the riscv-related perf driver. At the same time, it 
>> is possible to return EOPNOTSUPP about PERF_PMU_CAP_AUX_OUTPUT on the 
>> path of perf_event_open. I think it resonable to skip such use cases 
>> for functions not supported by non-bpf modules, what do you think?
> 
> Thanks for explanation. I checked kernel/events/core.c and arch/x86/.... 
> I agree that if hardware has capabilities PERF_PMU_CAP_NO_INTERRUPT
> or PERF_PMU_CAP_AUX_OUTPUT, EOPNOTSUPP could be returned, although I 
> think this should be extremely rare for x86 cpu's (probably only really 
> old ones).
> Several other arch's also have hardware which has capability 
> PERF_PMU_CAP_NO_INTERRUPT, so may indeed hit this issue.
> 
> In bpf-next/arch/riscv, I didn't find usage of PERF_PMU_CAP_NO_INTERRUPT 
> though.
> 

The riscv pmu driver is located in drivers/perf/riscv_pmu*. Sampling 
events are not supported in legacy mode, nor in sbi mode without the 
sscofpmf extension.

> Your patch looks good to me. Since you hit the issue with riscv so 
> please describe how EOPNOTSUPP could be returned in your test. It would 
> be a good
> justification for your patch.

Alright, I will patch that in next version.

> 
>>
>>>>
>>>> Signed-off-by: Pu Lehui <pulehui@huawei.com>
>>>> ---
>>>> 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;
>>
diff mbox series

Patch

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;