Re: [PATCH 1/2] perf/x86/intel: Only check the group flag for X86 leader

From: Liang, Kan
Date: Thu Apr 24 2025 - 09:51:37 EST




On 2025-04-24 5:40 a.m., Peter Zijlstra wrote:
> On Wed, Apr 23, 2025 at 03:10:14PM -0700, kan.liang@xxxxxxxxxxxxxxx wrote:
>> From: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
>>
>> A warning in intel_pmu_lbr_counters_reorder() may be triggered by below
>> perf command.
>>
>> perf record -e "{cpu-clock,cycles/call-graph="lbr"/}" -- sleep 1
>>
>> It's because the group is mistakenly treated as a branch counter group.
>>
>> The hw.flags of the leader are used to determine whether a group is a
>> branch counters group. However, the hw.flags is only available for a
>> hardware event. The field to store the flags is a union type. For a
>> software event, it's a hrtimer. The corresponding bit may be set if the
>> leader is a software event.
>>
>> For a branch counter group and other groups that have a group flag
>> (e.g., topdown, PEBS counters snapshotting, and ACR), the leader must
>> be a X86 event. Check the X86 event before checking the flag.
>>
>> There may be an alternative way to fix the issue by moving the hw.flags
>> out of the union type. It should work for now. But it's still possible
>> that the flags will be used by other types of events later. As long as
>> that type of event is used as a leader, a similar issue will be
>> triggered. So the alternative way is dropped.
>>
>> Reported-by: Luo Gengkun <luogengkun@xxxxxxxxxxxxxxx>
>> Closes: https://lore.kernel.org/lkml/20250412091423.1839809-1-luogengkun@xxxxxxxxxxxxxxx/
>> Signed-off-by: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
>
> Can I get a Fixes tag for this such that I can stick it in urgent?
>

I have split the patch series and sent a V2.
https://lore.kernel.org/lkml/20250424134718.311934-1-kan.liang@xxxxxxxxxxxxxxx/

There is a fix for the non-precise events counters-snapshotting, which
is buried in the LKML.
https://lore.kernel.org/lkml/20250204210514.4089680-1-kan.liang@xxxxxxxxxxxxxxx/
I've also added it into the above V2 with a fixes tag.
Please take a look. If it looks good for you, please stick it in urgent
as well.

Thanks,
Kan