summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/prog_tests/res_spin_lock.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/res_spin_lock.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/res_spin_lock.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/res_spin_lock.c b/tools/testing/selftests/bpf/prog_tests/res_spin_lock.c
index f0a8c828f8f1..7541f4966abc 100644
--- a/tools/testing/selftests/bpf/prog_tests/res_spin_lock.c
+++ b/tools/testing/selftests/bpf/prog_tests/res_spin_lock.c
@@ -3,6 +3,8 @@
#include <test_progs.h>
#include <network_helpers.h>
#include <sys/sysinfo.h>
+#include <sys/syscall.h>
+#include <linux/perf_event.h>
#include "res_spin_lock.skel.h"
#include "res_spin_lock_fail.skel.h"
@@ -102,11 +104,29 @@ end:
void serial_test_res_spin_lock_stress(void)
{
+ struct perf_event_attr attr = {
+ .size = sizeof(attr),
+ .type = PERF_TYPE_HARDWARE,
+ .config = PERF_COUNT_HW_CPU_CYCLES,
+ };
+ int pmu_fd;
+
if (libbpf_num_possible_cpus() < 3) {
test__skip();
return;
}
+ pmu_fd = syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0);
+ if (pmu_fd < 0) {
+ if (errno == ENOENT || errno == EOPNOTSUPP) {
+ test__skip();
+ return;
+ }
+ ASSERT_OK(-errno, "perf_event_open pmu probe");
+ return;
+ }
+ close(pmu_fd);
+
ASSERT_OK(load_module("bpf_test_rqspinlock.ko", false), "load module AA");
sleep(5);
unload_module("bpf_test_rqspinlock", false);