From: Namhyung Kim <namhyung@kernel.org>
To: James Clark <james.clark@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Leo Yan <leo.yan@arm.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf tools: Dump callchain context marker names
Date: Fri, 2 Jan 2026 14:40:05 -0800 [thread overview]
Message-ID: <aVhJRW9URWItj2fh@google.com> (raw)
In-Reply-To: <20260102-james-perf-dump-callchain-markers-v1-1-3a9bdec20c58@linaro.org>
Hi James,
Happy new year!
On Fri, Jan 02, 2026 at 12:15:43PM +0000, James Clark wrote:
> These are hard to interpret in the raw output because they are printed
> as hex but are defined in perf_event.h as decimal. Make it much easier
> to read the raw callchains by just printing their names.
>
> For example:
>
> $ perf report -D
>
> 1798195372321 0x4638 [0xb0]: PERF_RECORD_SAMPLE(IP, 0x4002): 44922/44922: 0x7c8046dd3400 period: 120218 addr: 0
> ... FP chain: nr:12
> ..... 0: fffffffffffffe00 (PERF_CONTEXT_USER)
> ..... 1: 00007c8046dd3400
> ..... 2: 00007c8046db86d3
>
> Signed-off-by: James Clark <james.clark@linaro.org>
> ---
> tools/perf/util/session.c | 25 +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index 4236503c8f6c..e812f8954075 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -841,6 +841,26 @@ static void callchain__lbr_callstack_printf(struct perf_sample *sample)
> }
> }
>
> +static const char *callchain_context_str(u64 ip)
> +{
> + switch (ip) {
> + case PERF_CONTEXT_HV:
> + return " (PERF_CONTEXT_HV)";
> + case PERF_CONTEXT_KERNEL:
> + return " (PERF_CONTEXT_KERNEL)";
> + case PERF_CONTEXT_USER:
> + return " (PERF_CONTEXT_USER)";
We now have PERF_CONTEXT_USER_DEFERRED too.
Thanks,
Namhyung
> + case PERF_CONTEXT_GUEST:
> + return " (PERF_CONTEXT_GUEST)";
> + case PERF_CONTEXT_GUEST_KERNEL:
> + return " (PERF_CONTEXT_GUEST_KERNEL)";
> + case PERF_CONTEXT_GUEST_USER:
> + return " (PERF_CONTEXT_GUEST_USER)";
> + default:
> + return "";
> + }
> +}
> +
> static void callchain__printf(struct evsel *evsel,
> struct perf_sample *sample)
> {
> @@ -853,8 +873,9 @@ static void callchain__printf(struct evsel *evsel,
> printf("... FP chain: nr:%" PRIu64 "\n", callchain->nr);
>
> for (i = 0; i < callchain->nr; i++)
> - printf("..... %2d: %016" PRIx64 "\n",
> - i, callchain->ips[i]);
> + printf("..... %2d: %016" PRIx64 "%s\n",
> + i, callchain->ips[i],
> + callchain_context_str(callchain->ips[i]));
>
> if (sample->deferred_callchain)
> printf("...... (deferred)\n");
>
> ---
> base-commit: cbd41c6d4c26c161a2b0e70ad411d3885ff13507
> change-id: 20260102-james-perf-dump-callchain-markers-64d175b108c8
>
> Best regards,
> --
> James Clark <james.clark@linaro.org>
>
next prev parent reply other threads:[~2026-01-02 22:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-02 12:15 [PATCH] perf tools: Dump callchain context marker names James Clark
2026-01-02 12:18 ` Ian Rogers
2026-01-13 20:33 ` Arnaldo Carvalho de Melo
2026-01-02 22:40 ` Namhyung Kim [this message]
2026-01-13 20:37 ` Arnaldo Carvalho de Melo
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=aVhJRW9URWItj2fh@google.com \
--to=namhyung@kernel.org \
--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=jolsa@kernel.org \
--cc=leo.yan@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/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