linux/tools/perf/tests/shell/stat+shadow_stat.sh
Jin Yao a37f3b8856 perf tests: Skip 'perf stat metrics (shadow stat) test' for hybrid
Currently we don't support shadow stat for hybrid.

  root@ssp-pwrt-002:~# ./perf stat -e cycles,instructions -a -- sleep 1

   Performance counter stats for 'system wide':

      12,883,109,591      cpu_core/cycles/
       6,405,163,221      cpu_atom/cycles/
         555,553,778      cpu_core/instructions/
         841,158,734      cpu_atom/instructions/

         1.002644773 seconds time elapsed

Now there is no shadow stat 'insn per cycle' reported. We will support
it later and now just skip the 'perf stat metrics (shadow stat) test'.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210427070139.25256-26-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-04-29 10:31:00 -03:00

82 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
# perf stat metrics (shadow stat) test
# SPDX-License-Identifier: GPL-2.0
set -e
# skip if system-wide mode is forbidden
perf stat -a true > /dev/null 2>&1 || exit 2
# skip if on hybrid platform
perf stat -a -e cycles sleep 1 2>&1 | grep -e cpu_core && exit 2
test_global_aggr()
{
perf stat -a --no-big-num -e cycles,instructions sleep 1 2>&1 | \
grep -e cycles -e instructions | \
while read num evt hash ipc rest
do
# skip not counted events
if [ "$num" = "<not" ]; then
continue
fi
# save cycles count
if [ "$evt" = "cycles" ]; then
cyc=$num
continue
fi
# skip if no cycles
if [ -z "$cyc" ]; then
continue
fi
# use printf for rounding and a leading zero
res=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)`
if [ "$ipc" != "$res" ]; then
echo "IPC is different: $res != $ipc ($num / $cyc)"
exit 1
fi
done
}
test_no_aggr()
{
perf stat -a -A --no-big-num -e cycles,instructions sleep 1 2>&1 | \
grep ^CPU | \
while read cpu num evt hash ipc rest
do
# skip not counted events
if [ "$num" = "<not" ]; then
continue
fi
# save cycles count
if [ "$evt" = "cycles" ]; then
results="$results $cpu:$num"
continue
fi
cyc=${results##* $cpu:}
cyc=${cyc%% *}
# skip if no cycles
if [ -z "$cyc" ]; then
continue
fi
# use printf for rounding and a leading zero
res=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)`
if [ "$ipc" != "$res" ]; then
echo "IPC is different for $cpu: $res != $ipc ($num / $cyc)"
exit 1
fi
done
}
test_global_aggr
test_no_aggr
exit 0