From: Tengda Wu <wutengda@huaweicloud.com>
To: Namhyung Kim <namhyung@kernel.org>,
Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: james.clark@linaro.org, xueshuai@linux.alibaba.com,
Peter Zijlstra <peterz@infradead.org>,
leo.yan@linux.dev, Li Huafei <lihuafei1@huawei.com>,
Ian Rogers <irogers@google.com>,
Kim Phillips <kim.phillips@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Ingo Molnar <mingo@redhat.com>, Bill Wendling <morbo@google.com>,
Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Zecheng Li <zli94@ncsu.edu>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Tengda Wu <wutengda@huaweicloud.com>
Subject: [PATCH] perf annotate-data: Show event name in the data-type title
Date: Thu, 29 Oct 2026 07:15:10 +0000 [thread overview]
Message-ID: <20261029071510.460873-1-wutengda@huaweicloud.com> (raw)
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@huaweicloud.com>
---
tools/perf/ui/browsers/annotate-data.c | 14 +++++++++++---
tools/perf/util/annotate-data.c | 15 ++++++++++++---
2 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/tools/perf/ui/browsers/annotate-data.c b/tools/perf/ui/browsers/annotate-data.c
index a15608f6ee53..0f778788df4a 100644
--- a/tools/perf/ui/browsers/annotate-data.c
+++ b/tools/perf/ui/browsers/annotate-data.c
@@ -340,11 +340,19 @@ static int browser__show(struct ui_browser *uib)
struct hist_entry *he = uib->priv;
struct annotated_data_type *adt = he->mem_type;
struct annotated_data_browser *browser = get_browser(uib);
+ struct evsel *evsel = hists_to_evsel(he->hists);
const char *help = "Press 'h' for help on key bindings";
- char title[256];
+ const char *evsel_name = evsel__name(evsel);
+ char buf[512];
+ char title[sizeof(buf) + 256];
+
+ if (evsel__is_group_event(evsel)) {
+ evsel__group_desc(evsel, buf, sizeof(buf));
+ evsel_name = buf;
+ }
- snprintf(title, sizeof(title), "Annotate type: '%s' (%d samples)",
- adt->self.type_name, he->stat.nr_events);
+ snprintf(title, sizeof(title), "Annotate type: '%s' for %s (%d samples)",
+ adt->self.type_name, evsel_name, he->stat.nr_events);
if (ui_browser__show(uib, title, help) < 0)
return -1;
diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c
index b3de1ca688a2..25e3169ea8ad 100644
--- a/tools/perf/util/annotate-data.c
+++ b/tools/perf/util/annotate-data.c
@@ -2149,16 +2149,23 @@ static void print_annotated_data_header(struct hist_entry *he, struct evsel *evs
int nr_samples = he->stat.nr_events;
int width = 7;
const char *val_hdr = "Percent";
+ const char *evsel_name = evsel__name(evsel);
+ char buf[512];
+ int len;
if (evsel__is_group_event(evsel)) {
struct hist_entry *pair;
list_for_each_entry(pair, &he->pairs.head, pairs.node)
nr_samples += pair->stat.nr_events;
+
+ evsel__group_desc(evsel, buf, sizeof(buf));
+ evsel_name = buf;
}
- printf("Annotate type: '%s' in %s (%d samples):\n",
- he->mem_type->self.type_name, dso__name(dso), nr_samples);
+ len = printf("Annotate type: '%s' in %s for %s (%d samples):\n",
+ he->mem_type->self.type_name, dso__name(dso), evsel_name,
+ nr_samples);
if (evsel__is_group_event(evsel)) {
struct evsel *pos;
@@ -2183,7 +2190,9 @@ static void print_annotated_data_header(struct hist_entry *he, struct evsel *evs
val_hdr = "Samples";
}
- printf("============================================================================\n");
+ while (len-- > 1)
+ putchar('=');
+ putchar('\n');
printf("%*s %10s %10s %s\n", (width + 1) * nr_members, val_hdr,
"offset", "size", "field");
}
base-commit: 151a134a4e6ec66f69db8750c66006f5207f7a9d
--
2.34.1
next reply other threads:[~2026-10-29 7:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 7:15 Tengda Wu [this message]
2026-10-31 6:09 ` Namhyung Kim
2026-11-05 5:07 ` Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261029071510.460873-1-wutengda@huaweicloud.com \
--to=wutengda@huaweicloud.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=kim.phillips@arm.com \
--cc=leo.yan@linux.dev \
--cc=lihuafei1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=namhyung@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=peterz@infradead.org \
--cc=xueshuai@linux.alibaba.com \
--cc=zli94@ncsu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®