* [PATCH] perf dso: fix dso__is_kallsyms() check
@ 2025-03-18 23:00 Stephen Brennan
2025-03-20 16:00 ` Namhyung Kim
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Brennan @ 2025-03-18 23:00 UTC (permalink / raw)
To: Namhyung Kim, Arnaldo Carvalho de Melo, Peter Zijlstra,
Ingo Molnar
Cc: linux-perf-users, James Clark, Ian Rogers, linux-kernel,
Alexander Shishkin, Jiri Olsa, Mark Rutland, Chaitanya S Prakash,
Stephen Brennan, Liang, Kan, Athira Rajeev, Adrian Hunter
Kernel modules for which we cannot find a file on-disk will have a
dso->long_name that looks like "[module_name]". Prior to the commit
listed in the fixes, the dso->kernel field would be zero (for user
space), so dso__is_kallsyms() would return false. After the commit,
kernel module DSOs are correctly labeled, but the result is that
dso__is_kallsyms() erroneously returns true for those modules without a
filesystem path.
Later, build_id_cache__add() consults this value of is_kallsyms, and
when true, it copies /proc/kallsyms into the cache. Users with many
kernel modules without a filesystem path (e.g. ksplice or possibly
kernel live patch modules) have reported excessive disk space usage in
the build ID cache directory due to this behavior.
To reproduce the issue, it's enough to build a trivial out-of-tree hello
world kernel module, load it using insmod, and then use:
perf record -ag -- sleep 1
In the build ID directory, there will be a directory for your module
name containing a kallsyms file.
Fix this up by changing dso__is_kallsyms() to consult the
dso_binary_type enumeration, which is also symmetric to the above checks
for dso__is_vmlinux() and dso__is_kcore(). With this change, kallsyms is
not cached in the build-id cache for out-of-tree modules.
Fixes: 02213cec64bbe ("perf maps: Mark module DSOs with kernel type")
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
---
tools/perf/util/dso.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index bb8e8f444054d..c0472a41147c3 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -808,7 +808,9 @@ static inline bool dso__is_kcore(const struct dso *dso)
static inline bool dso__is_kallsyms(const struct dso *dso)
{
- return RC_CHK_ACCESS(dso)->kernel && RC_CHK_ACCESS(dso)->long_name[0] != '/';
+ enum dso_binary_type bt = dso__binary_type(dso);
+
+ return bt == DSO_BINARY_TYPE__KALLSYMS || bt == DSO_BINARY_TYPE__GUEST_KALLSYMS;
}
bool dso__is_object_file(const struct dso *dso);
--
2.43.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] perf dso: fix dso__is_kallsyms() check
2025-03-18 23:00 [PATCH] perf dso: fix dso__is_kallsyms() check Stephen Brennan
@ 2025-03-20 16:00 ` Namhyung Kim
0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2025-03-20 16:00 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
Stephen Brennan
Cc: linux-perf-users, James Clark, Ian Rogers, linux-kernel,
Alexander Shishkin, Jiri Olsa, Mark Rutland, Chaitanya S Prakash,
Liang, Kan, Athira Rajeev, Adrian Hunter
On Tue, 18 Mar 2025 16:00:11 -0700, Stephen Brennan wrote:
> Kernel modules for which we cannot find a file on-disk will have a
> dso->long_name that looks like "[module_name]". Prior to the commit
> listed in the fixes, the dso->kernel field would be zero (for user
> space), so dso__is_kallsyms() would return false. After the commit,
> kernel module DSOs are correctly labeled, but the result is that
> dso__is_kallsyms() erroneously returns true for those modules without a
> filesystem path.
>
> [...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-20 16:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-18 23:00 [PATCH] perf dso: fix dso__is_kallsyms() check Stephen Brennan
2025-03-20 16:00 ` Namhyung Kim
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).