From: Ian Rogers Date: Sat, 30 Sep 2023 06:02:06 +0000 (-0700) Subject: perf test: Avoid system wide when not privileged X-Git-Tag: v6.7-rc1~83^2~90 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0ddce121b038c553d6ec103f3b9fc399f99945e9;p=thirdparty%2Fkernel%2Flinux.git perf test: Avoid system wide when not privileged Switch the test program to sleep that makes more sense for system wide events. Only enable system wide when root or not paranoid. This avoids failures under some testing conditions like ARM cloud. Signed-off-by: Ian Rogers Acked-by: Namhyung Kim Link: https://lore.kernel.org/r/20230930060206.2353141-1-irogers@google.com Signed-off-by: Namhyung Kim --- diff --git a/tools/perf/tests/shell/stat_all_metricgroups.sh b/tools/perf/tests/shell/stat_all_metricgroups.sh index cb35e488809ae..f3e305649e2c1 100755 --- a/tools/perf/tests/shell/stat_all_metricgroups.sh +++ b/tools/perf/tests/shell/stat_all_metricgroups.sh @@ -4,9 +4,21 @@ set -e -for m in $(perf list --raw-dump metricgroups); do +function ParanoidAndNotRoot() +{ + [ "$(id -u)" != 0 ] && [ "$(cat /proc/sys/kernel/perf_event_paranoid)" -gt $1 ] +} + +system_wide_flag="-a" +if ParanoidAndNotRoot 0 +then + system_wide_flag="" +fi + +for m in $(perf list --raw-dump metricgroups) +do echo "Testing $m" - perf stat -M "$m" -a true + perf stat -M "$m" $system_wide_flag sleep 0.01 done exit 0