Re: [PATCH 3/3] perf test: Fix record tests on hybrid machines
From: Ian Rogers
Date: Wed Sep 23 2026 - 23:45:20 EST
On Wed, Sep 23, 2026 at 2:52 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>
> Currently the leader sampling test looks for "cycles:" string to match
> the event and retrieve the value before the event name. But it won't
> work on hybrid systems as the event name is different like below.
>
> $ perf script | grep -m 10 brstack
> perf 3322152 1873980.978431: 625379 cpu_atom/cycles/: 558200cc40cf brstack_bench+0x31 (/home/namhyung/project/linux/tools/perf/perf)
> perf 3322152 1873980.978431: 625379 cpu_atom/cycles/: 558200cc40cf brstack_bench+0x31 (/home/namhyung/project/linux/tools/perf/perf)
> perf 3322152 1873980.978598: 612177 cpu_atom/cycles/: 558200cc4082 brstack_foo+0x17 (/home/namhyung/project/linux/tools/perf/perf)
> perf 3322152 1873980.978598: 612177 cpu_atom/cycles/: 558200cc4082 brstack_foo+0x17 (/home/namhyung/project/linux/tools/perf/perf)
> perf 3322152 1873980.978762: 591859 cpu_atom/cycles/: 558200cc403d brstack_bar+0x0 (/home/namhyung/project/linux/tools/perf/perf)
> perf 3322152 1873980.978762: 591859 cpu_atom/cycles/: 558200cc403d brstack_bar+0x0 (/home/namhyung/project/linux/tools/perf/perf)
> perf 3322152 1873980.978948: 628505 cpu_atom/cycles/: 558200cc403e brstack_bar+0x1 (/home/namhyung/project/linux/tools/perf/perf)
> perf 3322152 1873980.978948: 628505 cpu_atom/cycles/: 558200cc403e brstack_bar+0x1 (/home/namhyung/project/linux/tools/perf/perf)
> perf 3322152 1873980.979146: 669816 cpu_atom/cycles/: 558200cc40e5 brstack_bench+0x47 (/home/namhyung/project/linux/tools/perf/perf)
> perf 3322152 1873980.979146: 669816 cpu_atom/cycles/: 558200cc40e5 brstack_bench+0x47 (/home/namhyung/project/linux/tools/perf/perf)
>
> But we can control the output format of perf script using -F option. So
> we knows where the period is in the output. To filter by symbol name,
> "ip" and "sym" fields are required as well.
>
> $ perf script -F period,ip,sym | grep -m 10 brstack
> 625379 558200cc40cf brstack_bench
> 625379 558200cc40cf brstack_bench
> 612177 558200cc4082 brstack_foo
> 612177 558200cc4082 brstack_foo
> 591859 558200cc403d brstack_bar
> 591859 558200cc403d brstack_bar
> 628505 558200cc403e brstack_bar
> 628505 558200cc403e brstack_bar
> 669816 558200cc40e5 brstack_bench
> 669816 558200cc40e5 brstack_bench
>
> Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
Tested-by: Ian Rogers <irogers@xxxxxxxxxx>
Thanks,
Ian
> ---
> tools/perf/tests/shell/record.sh | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index 04df35b30b0c15fd..fa8d17e389a0116d 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -537,7 +537,7 @@ test_leader_sampling() {
> err=1
> return
> fi
> - perf script -i "${perfdata}" | grep brstack > $script_output
> + perf script -i "${perfdata}" -F period,ip,sym | grep brstack > $script_output
> # Check if the two instruction counts are equal in each record.
> # However, the throttling code doesn't consider event grouping. During throttling, only the
> # leader is stopped, causing the slave's counts significantly higher. To temporarily solve this,
> @@ -549,7 +549,7 @@ test_leader_sampling() {
> tolerance_rate=0.8
> while IFS= read -r line
> do
> - cycles=$(echo $line | awk '{for(i=1;i<=NF;i++) if($i=="cycles:") print $(i-1)}')
> + cycles=$(echo $line | awk '{ print $1 }')
> if [ $(($index%2)) -ne 0 ]
> then
> if (( $(bc <<< "scale=4; r = ${cycles} / ${prev_cycles}; r >= 0.99 && r <= 1.01") ))
> --
> 2.56.0.rc1.310.g51773c2048-goog
>