[PATCH v2 6/8] perf tools: Avoid repeated failing search for debuginfo

From: Namhyung Kim

Date: Mon Sep 28 2026 - 21:14:05 EST


If dso has no debuginfo, dso__find_dbginfo_type() may repeat the same
search for available types. Let's add a new field (debuginfo_searched)
not to do it.

Reviewed-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/util/dso.c | 4 ++++
tools/perf/util/dso.h | 11 +++++++++++
2 files changed, 15 insertions(+)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index c765c9b80e957871..f7a786e0c3cf6a29 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -2129,6 +2129,10 @@ void dso__find_dbginfo_type(struct dso *dso)
if (dso__dbginfo_type(dso) != DSO_BINARY_TYPE__NOT_FOUND)
return;

+ if (dso__debuginfo_searched(dso))
+ return;
+ dso__set_debuginfo_searched(dso);
+
for (type = dbginfo_types; *type != DSO_BINARY_TYPE__NOT_FOUND; type++) {
path = dso__get_filename(dso, "", &decomp, *type);
if (path == NULL)
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 45c4954d5eaf9ffa..3f08d45e7f53a508 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -349,6 +349,7 @@ DECLARE_RC_STRUCT(dso) {
u8 short_name_allocated:1;
u8 long_name_allocated:1;
u8 is_64_bit:1;
+ u8 debuginfo_searched:1;
bool sorted_by_name;
bool loaded;
u8 rel;
@@ -1019,6 +1020,16 @@ static inline void dso__set_dbginfo_type(struct dso *dso, enum dso_binary_type b

void dso__find_dbginfo_type(struct dso *dso);

+static inline bool dso__debuginfo_searched(const struct dso *dso)
+{
+ return RC_CHK_ACCESS(dso)->debuginfo_searched;
+}
+
+static inline void dso__set_debuginfo_searched(struct dso *dso)
+{
+ RC_CHK_ACCESS(dso)->debuginfo_searched = 1;
+}
+
bool dso__is_object_file(const struct dso *dso);

void dso__free_a2l(struct dso *dso);
--
2.55.0