perf test: Skip 6.2 kernel for bpf-filter test
Subsystems (3)
Namhyung Kim
maintainerPATCH 1/3 perf test: Skip 6.2 kernel for bpf-filter test
The BPF sample filtering requires two kernel changes below:
* bpf_cast_to_kernel_ctx() kfunc (added in v6.2)
* setting perf_sample_data->sample_flags (finished in v6.3)
The perf tools can check bpf_cast_to_kernel_ctx() easily so it can refuse BPF filters on those old kernels (v6.1 and earlier). But checking sample_flags appears to be difficult so current code won't work on v6.2 kernel. That's unfortunate but I don't know what's the correct way to handle it.
For now, let's skip v6.2 kernels explicitly (if failed) in the test.
--- tools/perf/tests/shell/record_bpf_filter.sh | 6 ++++++ 1 file changed, 6 insertions(+)
tools/perf/tests/shell/record_bpf_filter.sh +6 -0
@@ -49,6 +49,12 @@ test_bpf_filter_basic() { fi if perf script -i "${perfdata}" -F ip | grep 'ffffffff[0-9a-f]*' then + if uname -r | grep -q ^6.2 + then + echo "Basic bpf-filter test [Skipped unsupported kernel]" + err=2 + return + fi echo "Basic bpf-filter test [Failed invalid output]" err=1 return
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
Namhyung Kim
maintainerPATCH 2/3 perf test: Fix perf stat bpf counters test on Intel
As of now, bpf counters (bperf) don't support event groups. But the default perf stat includes topdown metrics if supported (on recent Intel machines) which require groups. That makes perf stat exiting.
$ sudo perf stat --bpf-counter true bpf managed perf events do not yet support groups.
Actually the test explicitly uses cycles event only, but it missed to pass the option when it checks the availability of the command.
--- tools/perf/tests/shell/stat_bpf_counters.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/tests/shell/stat_bpf_counters.sh +2 -2
@@ -22,10 +22,10 @@ compare_number() } # skip if --bpf-counters is not supported -if ! perf stat --bpf-counters true > /dev/null 2>&1; then +if ! perf stat -e cycles --bpf-counters true > /dev/null 2>&1; then if [ "$1" = "-v" ]; then echo "Skipping: --bpf-counters not supported" - perf --no-pager stat --bpf-counters true || true + perf --no-pager stat -e cycles --bpf-counters true || true fi exit 2 fi
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
Re: [PATCH 2/3] perf test: Fix perf stat bpf counters test on Intel
Quoted 8 lines · Namhyung Kim
As of now, bpf counters (bperf) don't support event groups. But the default perf stat includes topdown metrics if supported (on recent Intel machines) which require groups. That makes perf stat exiting.
$ sudo perf stat --bpf-counter true bpf managed perf events do not yet support groups.
Quoted 7 lines
Actually the test explicitly uses cycles event only, but it missed to pass the option when it checks the availability of the command.
Fixes 2c0cb9f56020d ("perf test: Add a shell test for 'perf stat --bpf-counters' new option")Cc Song Liu <[email protected]>Signed-off-by Namhyung Kim <[email protected]>
Thanks!
Song
Quoted 24 lines
--- tools/perf/tests/shell/stat_bpf_counters.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/tests/shell/stat_bpf_counters.sh +2
-3@@ -22,10 +22,10 @@ compare_number() } # skip if --bpf-counters is not supported -if ! perf stat --bpf-counters true > /dev/null 2>&1; then +if ! perf stat -e cycles --bpf-counters true > /dev/null 2>&1; then if [ "$1" = "-v" ]; then echo "Skipping: --bpf-counters not supported" - perf --no-pager stat --bpf-counters true || true + perf --no-pager stat -e cycles --bpf-counters true || true fi exit 2 fi --2.42.0.rc1.204.g551eb34607-goog
Namhyung Kim
maintainerPATCH 3/3 perf test: Enhance perf stat cgroup BPF counter test
In reply to Namhyung KimIt has system-wide test and cpu-list test but the cpu-list test fails sometimes. It runs sleep command on CPU1 and measure both user.slice and system.slice cgroups by default (on systemd-based systems).
But if the system was idle enough, sometime the system.slice gets no count and it makes the test failing. Maybe that's because it only looks at the CPU1, let's add CPU0 to increase the chance it finds some tasks.
--- tools/perf/tests/shell/stat_bpf_counters_cgrp.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/stat_bpf_counters_cgrp.sh +1 -1
@@ -60,7 +60,7 @@ check_system_wide_counted() check_cpu_list_counted() { - check_cpu_list_counted_output=$(perf stat -C 1 --bpf-counters --for-each-cgroup ${test_cgroups} -e cpu-clock -x, taskset -c 1 sleep 1 2>&1) + check_cpu_list_counted_output=$(perf stat -C 0,1 --bpf-counters --for-each-cgroup ${test_cgroups} -e cpu-clock -x, taskset -c 1 sleep 1 2>&1) if echo ${check_cpu_list_counted_output} | grep -q -F "<not "; then echo "Some CPU events are not counted" if [ "${verbose}" = "1" ]; then
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog