* [PATCH v2] perf buildid-cache: recognize vdso when adding files
@ 2024-09-12 12:03 Changbin Du
2024-09-12 12:14 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 2+ messages in thread
From: Changbin Du @ 2024-09-12 12:03 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim
Cc: Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Adrian Hunter, Liang, Kan, linux-perf-users, linux-kernel,
Changbin Du
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] perf buildid-cache: recognize vdso when adding files
2024-09-12 12:03 [PATCH v2] perf buildid-cache: recognize vdso when adding files Changbin Du
@ 2024-09-12 12:14 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-09-12 12:14 UTC (permalink / raw)
To: Changbin Du
Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
Liang, Kan, linux-perf-users, linux-kernel
On Thu, Sep 12, 2024 at 08:03:03PM +0800, Changbin Du wrote:
> 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>
Thanks, applied to perf-tools-next,
- Arnaldo
> ---
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-12 12:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-12 12:03 [PATCH v2] perf buildid-cache: recognize vdso when adding files Changbin Du
2024-09-12 12:14 ` Arnaldo Carvalho de Melo
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.