From: Changbin Du <changbin.du@huawei.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
"Liang, Kan" <kan.liang@linux.intel.com>,
<linux-perf-users@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
Changbin Du <changbin.du@huawei.com>
Subject: [PATCH v2] perf buildid-cache: recognize vdso when adding files
Date: Thu, 12 Sep 2024 20:03:03 +0800 [thread overview]
Message-ID: <20240912120303.2294175-1-changbin.du@huawei.com> (raw)
Identify vdso by file name matching. The vdso objects have name
as vdso[32,64].so[.dbg].
$ perf buildid-cache -a /work/linux/arch/x86/entry/vdso/vdso64.so.dbg
Without this change, added vdso using above command actually will never
be used.
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Changbin Du <changbin.du@huawei.com>
---
This patch is separated from the series "perf: Support searching local
debugging vdso or specify vdso path in cmdline".
v2: also update build_id_cache__update_file().
---
tools/perf/builtin-buildid-cache.c | 34 ++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index b0511d16aeb6..69f43460d007 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -172,6 +172,36 @@ static int build_id_cache__add_kcore(const char *filename, bool force)
return 0;
}
+static bool filename_is_vdso(const char *filename)
+{
+ bool is_vdso = false;
+ char *fname, *bname;
+ static const char * const vdso_names[] = {
+ "vdso.so", "vdso32.so", "vdso64.so", "vdsox32.so"
+ };
+
+ fname = strdup(filename);
+ if (!fname) {
+ pr_err("no memory\n");
+ return false;
+ }
+
+ bname = basename(fname);
+ if (!bname)
+ goto out;
+
+ for (unsigned int i = 0; i < ARRAY_SIZE(vdso_names); i++) {
+ if (strstarts(bname, vdso_names[i])) {
+ is_vdso = true;
+ break;
+ }
+ }
+
+out:
+ free(fname);
+ return is_vdso;
+}
+
static int build_id_cache__add_file(const char *filename, struct nsinfo *nsi)
{
char sbuild_id[SBUILD_ID_SIZE];
@@ -189,7 +219,7 @@ static int build_id_cache__add_file(const char *filename, struct nsinfo *nsi)
build_id__sprintf(&bid, sbuild_id);
err = build_id_cache__add_s(sbuild_id, filename, nsi,
- false, false);
+ false, filename_is_vdso(filename));
pr_debug("Adding %s %s: %s\n", sbuild_id, filename,
err ? "FAIL" : "Ok");
return err;
@@ -323,7 +353,7 @@ static int build_id_cache__update_file(const char *filename, struct nsinfo *nsi)
if (!err)
err = build_id_cache__add_s(sbuild_id, filename, nsi, false,
- false);
+ filename_is_vdso(filename));
pr_debug("Updating %s %s: %s\n", sbuild_id, filename,
err ? "FAIL" : "Ok");
--
2.34.1
next reply other threads:[~2024-09-12 12:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-12 12:03 Changbin Du [this message]
2024-09-12 12:14 ` Arnaldo Carvalho de Melo
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=20240912120303.2294175-1-changbin.du@huawei.com \
--to=changbin.du@huawei.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=kan.liang@linux.intel.com \
--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 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®