Re: [PATCH 2/3] perf test: Fix record tests on Intel Broadwell
From: Ian Rogers
Date: Wed Sep 23 2026 - 23:46:04 EST
On Wed, Sep 23, 2026 at 2:53 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>
> I noticed it failed for leader sampling tests on Broadwell. It's
> because the period of groups members are a little bit different. Maybe
> there's an hardware issue but anyway it's close enough to treat them as
> same. I printed the value like below.
>
> $ perf test record
> ...
> prev: 462507, curr: 462506
> prev: 494783, curr: 494782
> prev: 454350, curr: 454349
> prev: 502782, curr: 502781
> prev: 566693, curr: 566692
> prev: 606558, curr: 606557
> prev: 559770, curr: 559769
> prev: 595737, curr: 595736
> prev: 643386, curr: 643385
> prev: 663672, curr: 663671
> prev: 620622, curr: 620621
> prev: 650419, curr: 650418
> Leader sampling [Failed inconsistent cycles count]
>
> Let's update the logic to compare values to allow 1% of errors.
>
> Also I think it should compare only if sees the non-leader samples so
> split the check of (($index % 2)).
>
> Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
+Dapeng Mi
Tested-by: Ian Rogers <irogers@xxxxxxxxxx>
Thanks,
Ian
> ---
> tools/perf/tests/shell/record.sh | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index cf8ba3d3411b0bcc..04df35b30b0c15fd 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -550,11 +550,14 @@ test_leader_sampling() {
> while IFS= read -r line
> do
> cycles=$(echo $line | awk '{for(i=1;i<=NF;i++) if($i=="cycles:") print $(i-1)}')
> - if [ $(($index%2)) -ne 0 ] && [ ${cycles}x != ${prev_cycles}x ]
> + if [ $(($index%2)) -ne 0 ]
> then
> - invalid_counts=$(($invalid_counts+1))
> - else
> - valid_counts=$(($valid_counts+1))
> + if (( $(bc <<< "scale=4; r = ${cycles} / ${prev_cycles}; r >= 0.99 && r <= 1.01") ))
> + then
> + valid_counts=$(($valid_counts+1))
> + else
> + invalid_counts=$(($invalid_counts+1))
> + fi
> fi
> index=$(($index+1))
> prev_cycles=$cycles
> --
> 2.56.0.rc1.310.g51773c2048-goog
>