From: Aaron Tomlin <atomlin@atomlin.com>
To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
namhyung@kernel.org
Cc: mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com,
atomlin@atomlin.com, linux-perf-users@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH perf-tools-next v7 3/6] perf symbol: Introduce vmlinux_path__find() helper
Date: Sat, 17 Oct 2026 22:13:43 -0400 [thread overview]
Message-ID: <20261018021346.582845-4-atomlin@atomlin.com> (raw)
In-Reply-To: <20261018021346.582845-1-atomlin@atomlin.com>
The vmlinux_path array maintains standard paths used by perf to locate
the kernel image (e.g. "vmlinux", "/boot/vmlinux",
"/lib/modules/%s/build/vmlinux", "/usr/lib/debug/..."). While
vmlinux_path__init() populates these candidates and dso__load_vmlinux_path()
loads symbols into a DSO/map, callers (such as test suites or probing tools)
often need to verify the existence of an accessible vmlinux on disk before
attempting machine setup or test execution.
Introduce vmlinux_path__find() to search through the configured vmlinux_path
entries (or symbol_conf.vmlinux_name if explicitly set) and return the
path to the first readable vmlinux file, or NULL if none is accessible.
Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
---
tools/perf/util/symbol.c | 30 ++++++++++++++++++++++++++++++
tools/perf/util/symbol.h | 2 ++
2 files changed, 32 insertions(+)
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 5d98888d068c..a46fd2f3f6a3 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -2390,6 +2390,36 @@ static int vmlinux_path__init(struct perf_env *env)
return -1;
}
+/**
+ * vmlinux_path__find - Locate the first accessible vmlinux file
+ *
+ * Check symbol_conf.vmlinux_name first if set, then search through the
+ * initialized paths in vmlinux_path.
+ *
+ * Return: A pointer to the path of the first readable vmlinux file, or NULL if
+ * none is accessible.
+ */
+const char *vmlinux_path__find(void)
+{
+ int i;
+
+ if (symbol_conf.vmlinux_name && access(symbol_conf.vmlinux_name, R_OK) == 0)
+ return symbol_conf.vmlinux_name;
+
+ if (!vmlinux_path) {
+ symbol_conf.try_vmlinux_path = true;
+ if (vmlinux_path__init(NULL) < 0)
+ return NULL;
+ }
+
+ for (i = 0; i < vmlinux_path__nr_entries; ++i) {
+ if (access(vmlinux_path[i], R_OK) == 0)
+ return vmlinux_path[i];
+ }
+
+ return NULL;
+}
+
int setup_list(struct strlist **list, const char *list_str,
const char *list_name)
{
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index d0bac824c79c..6d1eb08076ab 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -184,6 +184,8 @@ static inline int __symbol__join_symfs(char *bf, size_t size, const char *path)
extern int vmlinux_path__nr_entries;
extern char **vmlinux_path;
+const char *vmlinux_path__find(void);
+
static inline void *symbol__priv(struct symbol *sym)
{
return ((void *)sym) - symbol_conf.priv_size;
--
2.55.0
next prev parent reply other threads:[~2026-10-18 2:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-18 2:13 [PATCH perf-tools-next v7 0/6] perf ftrace: Support inlined functions and display enhancements in function graph tracer Aaron Tomlin
2026-10-18 2:13 ` [PATCH perf-tools-next v7 1/6] perf ftrace: Optimise __cmd_ftrace() stack frame with strbuf streaming Aaron Tomlin
2026-10-18 2:13 ` [PATCH perf-tools-next v7 2/6] perf ftrace: Support filtering return address comments Aaron Tomlin
2026-10-18 2:13 ` Aaron Tomlin [this message]
2026-10-18 2:13 ` [PATCH perf-tools-next v7 4/6] perf ftrace: Support display of inlined functions in function graph tracer Aaron Tomlin
2026-10-18 2:13 ` [PATCH perf-tools-next v7 5/6] perf ftrace: Support omitting execution duration " Aaron Tomlin
2026-10-18 2:13 ` [PATCH perf-tools-next v7 6/6] perf ftrace: Filter extraneous functions " Aaron Tomlin
2026-10-18 2:21 ` [PATCH perf-tools-next v7 0/6] perf ftrace: Support inlined functions and display enhancements " Aaron Tomlin
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=20261018021346.582845-4-atomlin@atomlin.com \
--to=atomlin@atomlin.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.