Re: [PATCH] perf annotate-data: Show event name in the data-type title
From: Namhyung Kim
Date: Thu Nov 05 2026 - 00:08:03 EST
On Thu, Oct 29, 2026 at 07:15:10AM +0000, Tengda Wu wrote:
> The same data type can be annotated for multiple sampling events, in
> which case the data-type header is printed once per event. But the
> header only shows the type name and the sample count, so several
> identical-looking headers are emitted and the user cannot tell which
> event each of them corresponds to. E.g.
>
> $ perf annotate --data-type=page --stdio --itrace=f
> Annotate type: 'struct page' in [kernel.kallsyms] (59208 samples):
> ============================================================================
> Percent offset size field
> 100.00 0 0x40 struct page {
> 9.95 0 0x8 long unsigned int flags;
>
> Annotate type: 'struct page' in [kernel.kallsyms] (59480 samples):
> ============================================================================
> Percent offset size field
> 100.00 0 0x40 struct page {
> 10.15 0 0x8 long unsigned int flags;
>
> Add the event name to the data-type title in both the TUI browser and
> the stdio output, so each header can be attributed to its event. For
> group events, use evsel__group_desc() to print the group description
> instead of the leader's name, so the whole group is identified.
>
> While at it, size the underline in the stdio output dynamically based
> on the length of the header line instead of using a fixed-width string,
> so it keeps matching the header as the text grows.
>
> Result:
>
> $ perf annotate --data-type=page --stdio --itrace=f
> Annotate type: 'struct page' in [kernel.kallsyms] for l1d-miss (59208 samples):
> ===============================================================================
> Percent offset size field
> 100.00 0 0x40 struct page {
> 9.95 0 0x8 long unsigned int flags;
>
> Annotate type: 'struct page' in [kernel.kallsyms] for l1d-access (59480 samples):
> =================================================================================
> Percent offset size field
> 100.00 0 0x40 struct page {
> 10.15 0 0x8 long unsigned int flags;
>
> Signed-off-by: Tengda Wu <wutengda@xxxxxxxxxxxxxxx>
Applied to perf-tools-next, thanks!
Best regards
Namhyung