Re: [PATCH 2/3] perf test: Fix record tests on Intel Broadwell

From: Mi, Dapeng

Date: Thu Sep 24 2026 - 03:01:31 EST



On 9/24/2026 11:45 AM, Ian Rogers wrote:
> 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]

Reviewed-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx>

It looks a hardware overcount issue.  I don't see this issue on recent
platforms, like SPR+, so I suppose the issue got fixed. 

BTW, recently I found the SAMPLE_READ may report invalid counts in some
PEBS based corner sampling cases, like ACR events + SAMPLE_READ, or
multiple PEBS events simultaneously run SAMPLE_READ, I'm working on a patch
series to fix the issues.

Thanks.


>> 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
>>