* [PATCH] perf dso: Stay in perf's mount namespace for cached debuginfo
@ 2026-11-21 22:25 Alireza Haghdoost via B4 Relay
0 siblings, 0 replies; only message in thread
From: Alireza Haghdoost via B4 Relay @ 2026-11-21 22:25 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, James Clark
Cc: Arnaldo Carvalho de Melo, linux-perf-users, linux-kernel,
Alireza Haghdoost
From: Alireza Haghdoost <haghdoost@uber.com>
When perf reads the data of a DSO that belongs to a process in another
mount namespace, open_dso() enters that namespace to open the file. It
does not do this for files in perf's own build-id cache, but it only
checks for DSO_BINARY_TYPE__BUILD_ID_CACHE.
Cached debuginfo files (DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO) are
in the same build-id cache, yet open_dso() looks for them in the
target's namespace. The file is usually not there, so for example
perf script -F +insn prints no instruction bytes. If a file with the
same path does exist there, perf reads the wrong file.
This patch skips the namespace switch for both build-id cache types, as
dso__load() already does.
Fixes: 5363c306787c ("perf symbol: Set binary_type of dso when loading")
Signed-off-by: Alireza Haghdoost <haghdoost@uber.com>
---
Found while working on lazy symbol loading [1]. It does not depend on
that series.
[1] https://lore.kernel.org/all/20261121-perf-symbol-memory-send-v8-0-370561cbb5a7@uber.com/
---
tools/perf/util/dso.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index e46cd614eb21..6aad25e9d4f5 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -707,14 +707,17 @@ static int open_dso(struct dso *dso, struct machine *machine)
{
int fd;
struct nscookie nsc;
+ enum dso_binary_type bt = dso__binary_type(dso);
+ bool nsenter = bt != DSO_BINARY_TYPE__BUILD_ID_CACHE &&
+ bt != DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO;
- if (dso__binary_type(dso) != DSO_BINARY_TYPE__BUILD_ID_CACHE) {
+ if (nsenter) {
mutex_lock(dso__lock(dso));
nsinfo__mountns_enter(dso__nsinfo(dso), &nsc);
mutex_unlock(dso__lock(dso));
}
fd = __open_dso(dso, machine);
- if (dso__binary_type(dso) != DSO_BINARY_TYPE__BUILD_ID_CACHE)
+ if (nsenter)
nsinfo__mountns_exit(&nsc);
if (fd >= 0) {
---
base-commit: bb27ddbaee56536fb8df0a24f07b526766dfe131
change-id: 20261121-perf-dso-ns-fix-4a71bd206f04
Best regards,
--
Alireza Haghdoost <haghdoost@uber.com>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-21 22:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-21 22:25 [PATCH] perf dso: Stay in perf's mount namespace for cached debuginfo Alireza Haghdoost via B4 Relay
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®