Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf test: Add basic stat and topdown group test

Add a basic stat test.

Add two tests of grouping behavior for topdown events. Topdown events
are special as they must be grouped with the slots event first.

Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Florian Fischer <florian.fischer@muhq.space>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.garry@huawei.com>
Cc: Kim Phillips <kim.phillips@amd.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Riccardo Mancini <rickyman7@gmail.com>
Cc: Shunsuke Nakamura <nakamura.shun@fujitsu.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: https://lore.kernel.org/r/20220517052724.283874-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
6a973e29 d98079c0

+67
+67
tools/perf/tests/shell/stat.sh
··· 1 + #!/bin/sh 2 + # perf stat tests 3 + # SPDX-License-Identifier: GPL-2.0 4 + 5 + set -e 6 + 7 + err=0 8 + test_default_stat() { 9 + echo "Basic stat command test" 10 + if ! perf stat true 2>&1 | egrep -q "Performance counter stats for 'true':" 11 + then 12 + echo "Basic stat command test [Failed]" 13 + err=1 14 + return 15 + fi 16 + echo "Basic stat command test [Success]" 17 + } 18 + 19 + test_topdown_groups() { 20 + # Topdown events must be grouped with the slots event first. Test that 21 + # parse-events reorders this. 22 + echo "Topdown event group test" 23 + if ! perf stat -e '{slots,topdown-retiring}' true > /dev/null 2>&1 24 + then 25 + echo "Topdown event group test [Skipped event parsing failed]" 26 + return 27 + fi 28 + if perf stat -e '{slots,topdown-retiring}' true 2>&1 | egrep -q "<not supported>" 29 + then 30 + echo "Topdown event group test [Failed events not supported]" 31 + err=1 32 + return 33 + fi 34 + if perf stat -e '{topdown-retiring,slots}' true 2>&1 | egrep -q "<not supported>" 35 + then 36 + echo "Topdown event group test [Failed slots not reordered first]" 37 + err=1 38 + return 39 + fi 40 + echo "Topdown event group test [Success]" 41 + } 42 + 43 + test_topdown_weak_groups() { 44 + # Weak groups break if the perf_event_open of multiple grouped events 45 + # fails. Breaking a topdown group causes the events to fail. Test a very large 46 + # grouping to see that the topdown events aren't broken out. 47 + echo "Topdown weak groups test" 48 + ok_grouping="{slots,topdown-bad-spec,topdown-be-bound,topdown-fe-bound,topdown-retiring},branch-instructions,branch-misses,bus-cycles,cache-misses,cache-references,cpu-cycles,instructions,mem-loads,mem-stores,ref-cycles,cache-misses,cache-references" 49 + if ! perf stat --no-merge -e "$ok_grouping" true > /dev/null 2>&1 50 + then 51 + echo "Topdown weak groups test [Skipped event parsing failed]" 52 + return 53 + fi 54 + group_needs_break="{slots,topdown-bad-spec,topdown-be-bound,topdown-fe-bound,topdown-retiring,branch-instructions,branch-misses,bus-cycles,cache-misses,cache-references,cpu-cycles,instructions,mem-loads,mem-stores,ref-cycles,cache-misses,cache-references}:W" 55 + if perf stat --no-merge -e "$group_needs_break" true 2>&1 | egrep -q "<not supported>" 56 + then 57 + echo "Topdown weak groups test [Failed events not supported]" 58 + err=1 59 + return 60 + fi 61 + echo "Topdown weak groups test [Success]" 62 + } 63 + 64 + test_default_stat 65 + test_topdown_groups 66 + test_topdown_weak_groups 67 + exit $err