From: Kohei Enju <kohei@enjuk.jp>
To: linux-perf-users@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@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>,
James Clark <james.clark@linaro.org>, Kohei Enju <kohei@enjuk.jp>
Subject: [PATCH v1 2/2] perf annotate: Honor explicit --source option
Date: Tue, 18 Aug 2026 14:40:13 +0000 [thread overview]
Message-ID: <20260818144149.101248-3-kohei@enjuk.jp> (raw)
In-Reply-To: <20260818144149.101248-1-kohei@enjuk.jp>
Source annotation is hidden by default to avoid forcing objdump -S, but
currently an explicit --source doesn't override annotate.hide_src_code.
In TUI mode, source code can be shown later with the 's' hotkey, which
re-runs annotation with hide_src_code cleared. In --stdio/--stdio2 mode,
there is no such interactive fallback, so --source did not show source
code unless users also set annotate.hide_src_code=false globally in
advance.
Track whether --source/--no-source was specified and synchronize
hide_src_code only in that case.
Fixes: e201757f7a0a ("perf annotate: Fix source code annotate with objdump")
Signed-off-by: Kohei Enju <kohei@enjuk.jp>
---
tools/perf/Documentation/perf-annotate.txt | 4 ++--
tools/perf/Documentation/perf-report.txt | 4 ++--
tools/perf/Documentation/perf-top.txt | 4 ++--
tools/perf/builtin-annotate.c | 7 +++++--
tools/perf/builtin-report.c | 7 +++++--
tools/perf/builtin-top.c | 7 +++++--
6 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt
index a688738809c4..dc5866cf6666 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -107,8 +107,8 @@ include::itrace.txt[]
--show-total-period:: Show a column with the sum of periods.
--source::
- Interleave source code with assembly code. Enabled by default,
- disable with --no-source.
+ Interleave source code with assembly code. This may use objdump and be
+ slower than the default disassembly. Disable with --no-source.
--symfs=<directory[,layout]>::
Look for files with symbols relative to this directory. The optional
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 22f87eaa3279..d494b9a37663 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -388,8 +388,8 @@ OPTIONS
--disassembler-style=:: Set disassembler style for objdump.
--source::
- Interleave source code with assembly code. Enabled by default,
- disable with --no-source.
+ Interleave source code with assembly code. This may use objdump and be
+ slower than the default disassembly. Disable with --no-source.
--asm-raw::
Show raw instruction encoding of assembly instructions.
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index af3e4230c72f..0e5372988a1f 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -178,8 +178,8 @@ Default is to monitor all CPUS.
with different file system layout.
--source::
- Interleave source code with assembly code. Enabled by default,
- disable with --no-source.
+ Interleave source code with assembly code. This may use objdump and be
+ slower than the default disassembly. Disable with --no-source.
--asm-raw::
Show raw instruction encoding of assembly instructions.
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 8a0eb30eac24..cb8ce851a81e 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -692,6 +692,7 @@ static const char * const annotate_usage[] = {
int cmd_annotate(int argc, const char **argv)
{
struct perf_annotate annotate = {};
+ bool source_set = false;
struct perf_data data = {
.mode = PERF_DATA_MODE_READ,
};
@@ -738,8 +739,8 @@ int cmd_annotate(int argc, const char **argv)
OPT_STRING('C', "cpu", &annotate.cpu_list, "cpu", "list of cpus to profile"),
OPT_CALLBACK(0, "symfs", NULL, "directory[,layout]", SYMFS_HELP,
symbol__config_symfs),
- OPT_BOOLEAN(0, "source", &annotate_opts.annotate_src,
- "Interleave source code with assembly code (default)"),
+ OPT_BOOLEAN_SET(0, "source", &annotate_opts.annotate_src, &source_set,
+ "Interleave source code with assembly code"),
OPT_BOOLEAN(0, "asm-raw", &annotate_opts.show_asm_raw,
"Display raw encoding of assembly instructions (default)"),
OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
@@ -798,6 +799,8 @@ int cmd_annotate(int argc, const char **argv)
annotation_config__init();
argc = parse_options(argc, argv, options, annotate_usage, 0);
+ if (source_set)
+ annotate_opts.hide_src_code = !annotate_opts.annotate_src;
if (argc) {
/*
* Special case: if there's an argument left then assume that
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index dd1309c32094..cfd611ca6ffe 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -1306,6 +1306,7 @@ int cmd_report(int argc, const char **argv)
struct itrace_synth_opts itrace_synth_opts = { .set = 0, };
struct stat st;
bool has_br_stack = false;
+ bool source_set = false;
int branch_mode = -1;
int last_key = 0;
bool branch_call_mode = false;
@@ -1420,8 +1421,8 @@ int cmd_report(int argc, const char **argv)
"only consider these parallelism levels (cpu set format)"),
OPT_BOOLEAN('I', "show-info", &report.show_full_info,
"Display extended information about perf.data file"),
- OPT_BOOLEAN(0, "source", &annotate_opts.annotate_src,
- "Interleave source code with assembly code (default)"),
+ OPT_BOOLEAN_SET(0, "source", &annotate_opts.annotate_src, &source_set,
+ "Interleave source code with assembly code"),
OPT_BOOLEAN(0, "asm-raw", &annotate_opts.show_asm_raw,
"Display raw encoding of assembly instructions (default)"),
OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
@@ -1853,6 +1854,8 @@ int cmd_report(int argc, const char **argv)
symbol_conf.priv_size += sizeof(u32);
}
annotation_config__init();
+ if (source_set)
+ annotate_opts.hide_src_code = !annotate_opts.annotate_src;
}
if (symbol__init(perf_session__env(session)) < 0)
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 1211401616ee..cc06e7332e47 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1483,6 +1483,7 @@ int cmd_top(int argc, const char **argv)
.evlistp = &top.evlist,
};
bool branch_call_mode = false;
+ bool source_set = false;
struct record_opts *opts = &top.record_opts;
struct target *target = &opts->target;
const char *disassembler_style = NULL, *objdump_path = NULL, *addr2line_path = NULL;
@@ -1566,8 +1567,8 @@ int cmd_top(int argc, const char **argv)
"only consider symbols in these comms"),
OPT_STRING(0, "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
"only consider these symbols"),
- OPT_BOOLEAN(0, "source", &annotate_opts.annotate_src,
- "Interleave source code with assembly code (default)"),
+ OPT_BOOLEAN_SET(0, "source", &annotate_opts.annotate_src, &source_set,
+ "Interleave source code with assembly code"),
OPT_BOOLEAN(0, "asm-raw", &annotate_opts.show_asm_raw,
"Display raw encoding of assembly instructions (default)"),
OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
@@ -1851,6 +1852,8 @@ int cmd_top(int argc, const char **argv)
goto out_delete_evlist;
annotation_config__init();
+ if (source_set)
+ annotate_opts.hide_src_code = !annotate_opts.annotate_src;
symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
status = symbol__init(NULL);
--
2.53.0
next prev parent reply other threads:[~2026-08-18 16:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 14:40 [PATCH v1 0/2] perf annotate: Fix source option behavior and Kohei Enju
2026-08-18 14:40 ` [PATCH v1 1/2] perf config: Fix annotate.hide_src_code documentation Kohei Enju
2026-08-18 16:05 ` sashiko-bot
2026-08-18 14:40 ` Kohei Enju [this message]
2026-08-18 16:10 ` [PATCH v1 2/2] perf annotate: Honor explicit --source option sashiko-bot
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=20260818144149.101248-3-kohei@enjuk.jp \
--to=kohei@enjuk.jp \
--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=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--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