* [PATCH] perf dso: Fix kallsyms DSO detection with fallback logic
@ 2026-04-10 7:12 Tanushree Shah
2026-04-10 8:17 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Tanushree Shah @ 2026-04-10 7:12 UTC (permalink / raw)
To: acme, jolsa, adrian.hunter, vmolnaro, mpetlan, tmricht, maddy,
irogers, namhyung
Cc: linux-perf-users, linuxppc-dev, atrajeev, hbathini, Tejas.Manhas1,
Tanushree.Shah, Shivani.Nittor, Tanushree Shah
The current kallsyms detection in dso__is_kallsyms() uses the
dso_binary_type enum which fixes the issue of kallsyms being cached in
the build-id cache for out-of-tree modules.
However, during build-id injection in perf record/inject, dso_binary_type
has not been explicitly set yet,so dso__binary_type() returns
DSO_BINARY_TYPE__NOT_FOUND instead of DSO_BINARY_TYPE__KALLSYMS for the
kernel DSO. The current check then fails to identify it as kallsyms,
causing build-id symlinks to not be created in ~/.debug/.build-id/ and
perf archive to fail with "Cannot stat" errors.
Steps to reproduce the issue:
1. rm -rf ~/.debug/.build-id
2. perf record sleep 1
3. perf archive
Fix by falling back to matching long_name against the known kallsyms
strings explicitly when binary_type is not yet set
(== DSO_BINARY_TYPE__NOT_FOUND).
Fixes: ebf0b332732d ("perf dso: fix dso__is_kallsyms() check")
Signed-off-by: Tanushree Shah <tshah@linux.ibm.com>
---
tools/perf/util/dso.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index ede691e9a249..e44071998c49 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -9,6 +9,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <linux/bitops.h>
+#include <string.h>
#include "build-id.h"
#include "debuginfo.h"
#include "mutex.h"
@@ -20,6 +21,7 @@ struct perf_env;
#define DSO__NAME_KALLSYMS "[kernel.kallsyms]"
#define DSO__NAME_KCORE "[kernel.kcore]"
+#define DSO__NAME_GUEST_KALLSYMS "[guest.kernel.kallsyms"
/**
* enum dso_binary_type - The kind of DSO generally associated with a memory
@@ -915,6 +917,14 @@ static inline bool dso__is_kallsyms(const struct dso *dso)
{
enum dso_binary_type bt = dso__binary_type(dso);
+ if (bt == DSO_BINARY_TYPE__NOT_FOUND) {
+ return RC_CHK_ACCESS(dso)->kernel &&
+ ((strncmp(RC_CHK_ACCESS(dso)->long_name, DSO__NAME_KALLSYMS,
+ strlen(DSO__NAME_KALLSYMS)) == 0) ||
+ (strncmp(RC_CHK_ACCESS(dso)->long_name, DSO__NAME_GUEST_KALLSYMS,
+ strlen(DSO__NAME_GUEST_KALLSYMS)) == 0));
+ }
+
return bt == DSO_BINARY_TYPE__KALLSYMS || bt == DSO_BINARY_TYPE__GUEST_KALLSYMS;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] perf dso: Fix kallsyms DSO detection with fallback logic
2026-04-10 7:12 [PATCH] perf dso: Fix kallsyms DSO detection with fallback logic Tanushree Shah
@ 2026-04-10 8:17 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-04-10 8:17 UTC (permalink / raw)
To: Tanushree Shah; +Cc: linux-perf-users
Sashiko AI review found 1 potential issue(s):
- [Low] The macro `DSO__NAME_GUEST_KALLSYMS` is defined with an unbalanced bracket, which is deceptive and prone to misuse.
--
commit bff739892129d9369935f2dfb42b44d83b2f857d
Author: Tanushree Shah <tshah@linux.ibm.com>
perf dso: Fix kallsyms DSO detection with fallback logic
This commit fixes kallsyms DSO detection during build-id injection when
the binary type is not yet explicitly set. It implements a fallback that
matches the long_name against known kallsyms strings to correctly identify
the kernel DSO.
> diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
> index ede691e9a2495..e44071998c499 100644
> --- a/tools/perf/util/dso.h
> +++ b/tools/perf/util/dso.h
[ ... ]
> @@ -20,6 +21,7 @@ struct perf_env;
>
> #define DSO__NAME_KALLSYMS "[kernel.kallsyms]"
> #define DSO__NAME_KCORE "[kernel.kcore]"
> +#define DSO__NAME_GUEST_KALLSYMS "[guest.kernel.kallsyms"
This isn't a bug, but there is a missing closing bracket in this macro
definition.
While it looks like this was done intentionally to allow prefix matching
against dynamic guest kallsyms names (which append a PID) using strncmp
later in the patch, naming it DSO__NAME_GUEST_KALLSYMS implies it represents
a complete, well-formed identifier like DSO__NAME_KALLSYMS.
Could this macro be renamed to something like DSO__PREFIX_GUEST_KALLSYMS
to make its intended use as a prefix clear, preventing it from being
accidentally used in contexts expecting a full name?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260410071225.708005-2-tshah@linux.ibm.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-10 8:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-10 7:12 [PATCH] perf dso: Fix kallsyms DSO detection with fallback logic Tanushree Shah
2026-04-10 8:17 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox