mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-01 09:13:37 +00:00
Running shellcheck on stat+shadow_stat.sh generates below warning:
In tests/shell/stat+shadow_stat.sh line 48:
while read cpu num evt hash ipc rest
^--^ SC2034 (warning): hash appears unused. Verify use (or export if used externally).
This variable is intentionally unused since it is needed to parse
through the output. Use "_" as a prefix for this throw away variable.
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
Link: https://lore.kernel.org/r/20230709182800.53002-11-atrajeev@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
81 lines
1.6 KiB
Bash
Executable file
81 lines
1.6 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
|