From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>,
James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org
Subject: [PATCH v2 3/5] perf tools: Fallback to initial kernel map properly
Date: Tue, 2 Dec 2025 15:57:16 -0800 [thread overview]
Message-ID: <20251202235718.1018752-4-namhyung@kernel.org> (raw)
In-Reply-To: <20251202235718.1018752-1-namhyung@kernel.org>
In maps__split_kallsyms(), it assumes new kernel map when it finds a
symbol without module after any module and the initial kernel map has
some symbols. Because it expects modules are out of the kernel map so
modules should not have symbols in the kernel map.
For example, the following memory map shows symbols and maps. Any
symbols in the module 1 area will go to the module 1. The main kernel
map starts at 0xffffffffbc200000. But if any symbol has a module
between the symbols in that area, next symbols after 0xffffffffbd008000
will generate new kernel maps like [kernel].1.
kernel address | |
| |
0xffffffffc0000000 |---------------------|
| (symbols) |
| ... | <--- [kernel].N
0xffffffffbc400000 |---------------------|
| (symbols) |
| module 2 | <--- bad?
0xffffffffbc380000 |---------------------|
| ... |
| (symbols) |
| [kernel.kallsyms] | <--- initial map
0xffffffffbc200000 |---------------------|
| |
| |
0xffffffffabcde000 |---------------------|
| (symbols) |
| module 1 |
0xffffffffabcd0000 |---------------------|
This is very fragile when the module has a symbol that falls into the
main kernel map for some reason. My system has a livepatch module with
such symbols. And it created a lot of new kernel maps after those
symbols. But the symbol may have broken addresses and the later symbols
can still be found in the initial kernel map.
Let's check the symbol address in the initial map and use it if found.
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/symbol.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 8eea49c50453d13a..b533fbf17a8b19a3 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -951,7 +951,8 @@ static int maps__split_kallsyms(struct maps *kmaps, struct dso *dso, u64 delta,
pos->end -= delta;
}
- if (count == 0) {
+ if (map__start(initial_map) <= (pos->start + delta) &&
+ (pos->start + delta) < map__end(initial_map)) {
map__zput(curr_map);
curr_map = map__get(initial_map);
goto add_symbol;
--
2.52.0.158.g65b55ccf14-goog
next prev parent reply other threads:[~2025-12-02 23:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-02 23:57 [PATCHSET v2 0/5] perf tools: Fix /proc/kallsyms map split Namhyung Kim
2025-12-02 23:57 ` [PATCH v2 1/5] perf tools: Mark split kallsyms DSOs as loaded Namhyung Kim
2025-12-02 23:57 ` [PATCH v2 2/5] perf tools: Fix split kallsyms DSO counting Namhyung Kim
2025-12-02 23:57 ` Namhyung Kim [this message]
2025-12-02 23:57 ` [PATCH v2 4/5] perf tools: Use machine->root_dir to find /proc/kallsyms Namhyung Kim
2025-12-02 23:57 ` [PATCH v2 5/5] perf test: Add kallsyms split test Namhyung Kim
2025-12-03 1:12 ` Ian Rogers
2025-12-03 17:58 ` [PATCHSET v2 0/5] perf tools: Fix /proc/kallsyms map split 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=20251202235718.1018752-4-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@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;
as well as URLs for NNTP newsgroup(s).