perf test: Avoid system wide when not privileged
Ian Rogers
reviewerPATCH 1/1 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.
--- tools/perf/tests/shell/stat_all_metricgroups.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
tools/perf/tests/shell/stat_all_metricgroups.sh +14 -2
@@ -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
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
Hi Ian,
Quoted 6 lines · Ian Rogers
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 <[email protected]>
While I'm ok with the change, I wonder why it doesn't have the same code structure as in the stat_all_metrics.sh which checks the actual result.
Thanks,
Namhyung
Quoted 35 lines
--- tools/perf/tests/shell/stat_all_metricgroups.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)tools/perf/tests/shell/stat_all_metricgroups.sh +14
-3@@ -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 --2.42.0.582.g8ccd20d70d-goog
Ian Rogers
reviewerQuoted 9 lines · Namhyung Kim
Hi Ian,
Quoted 5 lines · Ian Rogers
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.
Quoted 6 lines
Quoted 1 line
Signed-off-by Ian Rogers <[email protected]>While I'm ok with the change, I wonder why it doesn't have the same code structure as in the
stat_all_metrics.shwhich checks the actual result.Acked-by Namhyung Kim <[email protected]>
The metric group isn't printed when we print the metrics within it. This could be changed.
Thanks,
Ian
Quoted 38 lines
Thanks,
NamhyungQuoted 35 lines
--- tools/perf/tests/shell/stat_all_metricgroups.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)tools/perf/tests/shell/stat_all_metricgroups.sh +14
-3@@ -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 --2.42.0.582.g8ccd20d70d-goog
Namhyung Kim
maintainerQuoted 13 lines · Ian Rogers
Quoted 11 lines · Namhyung Kim
Hi Ian,
Quoted 6 lines · Ian Rogers
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 <[email protected]>
Quoted 7 lines
Quoted 4 lines
While I'm ok with the change, I wonder why it doesn't have the same code structure as in the
stat_all_metrics.shwhich checks the actual result.Acked-by Namhyung Kim <[email protected]>The metric group isn't printed when we print the metrics within it. This could be changed.
Ok, we can change it later. Applied to perf-tools-next, thanks!