Re: [RFC] perf script AMD/IBS: Add scripts to show function/instruction level granular profile

From: Ravi Bangoria
Date: Mon Jan 27 2025 - 03:58:01 EST


Hi Namhyung,

> On Fri, Jan 24, 2025 at 06:06:38AM +0000, Ravi Bangoria wrote:
>> AMD IBS (Instruction Based Sampling) PMUs provides various insights
>> about instruction execution through front-end and back-end units.
>> Various perf tools (e.g. precise-mode (:p), perf-mem, perf-c2c etc.)
>> uses portion of these information but lot of other insightful data are
>> still remains unused by perf. I could not think of any generic perf
>> tool where I can consolidate and show all these data, so thought to
>> add perf-python scripts.
>
> Thanks for doing this. I agree that there are many rooms for
> improvement in this regard. While I'm ok to add the scripts, I'm
> curious if we can add something as sort keys so that it can be used in
> the general perf-mem and perf-c2c.
>
> For example, function level data source breakdown can be shown:
>
> $ perf mem report -H -s sym,mem
> #
> # Overhead Samples Symbol / Memory access
> # ......................... ......................
> #
> 4.58% 97 [k] psi_group_change
> 2.89% 51 L1 hit
> 1.38% 35 LFB/MAB hit
> 0.19% 10 L3 hit
> 0.12% 1 RAM hit
> 4.54% 1 [k] bpf_ksym_find
> 4.54% 1 RAM hit
> ...

Interesting, I wasn't aware of this mode. I usually group them using -F.

$ perf mem report -F sample,mem,sym
Samples: 531K of event 'ibs_op//', Event count (approx.): 4359237
Samples Memory access Symbol
4922 L1 hit [k] perf_event_update_userpage
3028 N/A [k] perf_event_update_userpage
281 L2 hit [k] perf_event_update_userpage
48 LFB/MAB hit [k] perf_event_update_userpage

But, AFAIK, -F (or other options) does not allow grouping and showing all
the data at the function granularity. For ex, if I add a TLB column, the
data gets further split hierarchically in -F field order:

$ perf mem report -F sample,mem,tlb,sym
Samples: 531K of event 'ibs_op//', Event count (approx.): 4359237
Samples Memory access TLB access Symbol
4920 L1 hit L1 hit [k] perf_event_update_userpage
3028 N/A N/A [k] perf_event_update_userpage
280 L2 hit L1 hit [k] perf_event_update_userpage
48 LFB/MAB hit L1 hit [k] perf_event_update_userpage
2 L1 hit L2 hit [k] perf_event_update_userpage
1 L2 hit L2 hit [k] perf_event_update_userpage

Thanks for the feedback,
Ravi