drm/nouveau: consume the return of large GSP message
[drm/drm-misc.git] / tools / perf / tests / shell / stat_bpf_counters_cgrp.sh
blob2ec69060c42ffdc598e3b676706a705fb801e5b5
1 #!/bin/sh
2 # perf stat --bpf-counters --for-each-cgroup test
3 # SPDX-License-Identifier: GPL-2.0
5 set -e
7 test_cgroups=
8 if [ "$1" = "-v" ]; then
9 verbose="1"
12 # skip if --bpf-counters --for-each-cgroup is not supported
13 check_bpf_counter()
15 if ! perf stat -a --bpf-counters --for-each-cgroup / true > /dev/null 2>&1; then
16 if [ "${verbose}" = "1" ]; then
17 echo "Skipping: --bpf-counters --for-each-cgroup not supported"
18 perf --no-pager stat -a --bpf-counters --for-each-cgroup / true || true
20 exit 2
24 # find two cgroups to measure
25 find_cgroups()
27 # try usual systemd slices first
28 if [ -d /sys/fs/cgroup/system.slice ] && [ -d /sys/fs/cgroup/user.slice ]; then
29 test_cgroups="system.slice,user.slice"
30 return
33 # try root and self cgroups
34 find_cgroups_self_cgrp=$(grep perf_event /proc/self/cgroup | cut -d: -f3)
35 if [ -z ${find_cgroups_self_cgrp} ]; then
36 # cgroup v2 doesn't specify perf_event
37 find_cgroups_self_cgrp=$(grep ^0: /proc/self/cgroup | cut -d: -f3)
40 if [ -z ${find_cgroups_self_cgrp} ]; then
41 test_cgroups="/"
42 else
43 test_cgroups="/,${find_cgroups_self_cgrp}"
47 # As cgroup events are cpu-wide, we cannot simply compare the result.
48 # Just check if it runs without failure and has non-zero results.
49 check_system_wide_counted()
51 check_system_wide_counted_output=$(perf stat -a --bpf-counters --for-each-cgroup ${test_cgroups} -e cpu-clock -x, sleep 1 2>&1)
52 if echo ${check_system_wide_counted_output} | grep -q -F "<not "; then
53 echo "Some system-wide events are not counted"
54 if [ "${verbose}" = "1" ]; then
55 echo ${check_system_wide_counted_output}
57 exit 1
61 check_bpf_counter
62 find_cgroups
64 check_system_wide_counted
66 exit 0