From 69c258e8b595ee0c252aa2648d73a10e62ecfca5 Mon Sep 17 00:00:00 2001 From: Aaron Merey Date: Mon, 16 Oct 2017 20:08:17 -0400 Subject: [PATCH] stapbpf: remove hardware perf events dependency. * stapbpf.cxx (create_group_fds): change perf event group leader from hardware type to software type. * bpf_tests/context_vars1.stp: remove unused variable. * bpf_tests/printf.stp: ensure kernel probe only triggers once. --- stapbpf/stapbpf.cxx | 2 ++ testsuite/systemtap.bpf/bpf_tests/context_vars1.stp | 1 - testsuite/systemtap.bpf/bpf_tests/printf.stp | 13 ++++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/stapbpf/stapbpf.cxx b/stapbpf/stapbpf.cxx index 89acee908..72ca63049 100644 --- a/stapbpf/stapbpf.cxx +++ b/stapbpf/stapbpf.cxx @@ -143,6 +143,8 @@ create_group_fds() memset(&peattr, 0, sizeof(peattr)); peattr.size = sizeof(peattr); peattr.disabled = 1; + peattr.type = PERF_TYPE_SOFTWARE; + peattr.config = PERF_COUNT_SW_DUMMY; return group_fd = perf_event_open(&peattr, -1, 0, -1, 0); } diff --git a/testsuite/systemtap.bpf/bpf_tests/context_vars1.stp b/testsuite/systemtap.bpf/bpf_tests/context_vars1.stp index 9f736081d..8c422c226 100644 --- a/testsuite/systemtap.bpf/bpf_tests/context_vars1.stp +++ b/testsuite/systemtap.bpf/bpf_tests/context_vars1.stp @@ -1,4 +1,3 @@ -global res1 probe begin { printf("BEGIN\n") } diff --git a/testsuite/systemtap.bpf/bpf_tests/printf.stp b/testsuite/systemtap.bpf/bpf_tests/printf.stp index 6cf6a7e1b..ce114e4a6 100644 --- a/testsuite/systemtap.bpf/bpf_tests/printf.stp +++ b/testsuite/systemtap.bpf/bpf_tests/printf.stp @@ -1,4 +1,4 @@ -global x +global x, flag = 1 probe begin { printf("BEGIN") x = 1; y = 1; z = 3 @@ -7,10 +7,13 @@ probe begin { } probe kernel.function("sys_open") { - y = 1; z = 3 - printf("abcd%d2", x) - printf("%d4%d%d", x + 2, y + 4, z + 3) - exit() + if (flag) { + y = 1; z = 3 + printf("abcd%d2", x) + printf("%d4%d%d", x + 2, y + 4, z + 3) + flag = 0 + exit() + } } -- 2.43.5