[PATCH v5 8/8] perf buildid-cache: recognize vdso when adding files

Changbin Du posted 8 patches 1 year, 5 months ago
[PATCH v5 8/8] perf buildid-cache: recognize vdso when adding files
Posted by Changbin Du 1 year, 5 months ago
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, adding vdso using above command actually will never
be used.

Signed-off-by: Changbin Du <changbin.du@huawei.com>
---
 tools/perf/builtin-buildid-cache.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index b0511d16aeb6..8edea9044a65 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -172,6 +172,30 @@ static int build_id_cache__add_kcore(const char *filename, bool force)
 	return 0;
 }
 
+static bool filename_is_vdso(const char *filename)
+{
+	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 mememory\n");
+		return false;
+	}
+
+	bname = basename(fname);
+	if (!bname)
+		return false;
+
+	for (unsigned int i = 0; i < ARRAY_SIZE(vdso_names); i++) {
+		if (!strncmp(bname, vdso_names[i], strlen(vdso_names[i])))
+			return true;
+	}
+	return false;
+}
+
 static int build_id_cache__add_file(const char *filename, struct nsinfo *nsi)
 {
 	char sbuild_id[SBUILD_ID_SIZE];
@@ -189,7 +213,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;
-- 
2.34.1
Re: [PATCH v5 8/8] perf buildid-cache: recognize vdso when adding files
Posted by kernel test robot 1 year, 4 months ago

Hello,

kernel test robot noticed "perf-sanity-tests.build_id_cache_operations.fail" on:

commit: f715cdcabbfb1d34e86b0a2cbb700d690308d724 ("[PATCH v5 8/8] perf buildid-cache: recognize vdso when adding files")
url: https://github.com/intel-lab-lkp/linux/commits/Changbin-Du/perf-support-specify-vdso-path-in-cmdline/20240702-122209
base: https://git.kernel.org/cgit/linux/kernel/git/perf/perf-tools-next.git perf-tools-next
patch link: https://lore.kernel.org/all/20240702041837.5306-9-changbin.du@huawei.com/
patch subject: [PATCH v5 8/8] perf buildid-cache: recognize vdso when adding files

in testcase: perf-sanity-tests
version: 
with following parameters:

	perf_compiler: gcc



compiler: gcc-13
test machine: 224 threads 2 sockets Intel(R) Xeon(R) Platinum 8480+ (Sapphire Rapids) with 256G memory

(please refer to attached dmesg/kmsg for entire log/backtrace)



If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <oliver.sang@intel.com>
| Closes: https://lore.kernel.org/oe-lkp/202407242254.98492680-oliver.sang@intel.com



2024-07-18 05:11:32 sudo /usr/src/linux-perf-x86_64-rhel-8.3-bpf-f715cdcabbfb1d34e86b0a2cbb700d690308d724/tools/perf/perf test 78
 78: build id cache operations                                       : FAILED!



The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20240724/202407242254.98492680-oliver.sang@intel.com



-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH v5 8/8] perf buildid-cache: recognize vdso when adding files
Posted by Namhyung Kim 1 year, 5 months ago
Hello,

On Tue, Jul 02, 2024 at 12:18:37PM +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, adding vdso using above command actually will never
> be used.

Can we handle /tmp/perf-vdso.so-XXXXXX too?

Thanks,
Namhyung

> 
> Signed-off-by: Changbin Du <changbin.du@huawei.com>
> ---
>  tools/perf/builtin-buildid-cache.c | 26 +++++++++++++++++++++++++-
>  1 file changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
> index b0511d16aeb6..8edea9044a65 100644
> --- a/tools/perf/builtin-buildid-cache.c
> +++ b/tools/perf/builtin-buildid-cache.c
> @@ -172,6 +172,30 @@ static int build_id_cache__add_kcore(const char *filename, bool force)
>  	return 0;
>  }
>  
> +static bool filename_is_vdso(const char *filename)
> +{
> +	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 mememory\n");
> +		return false;
> +	}
> +
> +	bname = basename(fname);
> +	if (!bname)
> +		return false;
> +
> +	for (unsigned int i = 0; i < ARRAY_SIZE(vdso_names); i++) {
> +		if (!strncmp(bname, vdso_names[i], strlen(vdso_names[i])))
> +			return true;
> +	}
> +	return false;
> +}
> +
>  static int build_id_cache__add_file(const char *filename, struct nsinfo *nsi)
>  {
>  	char sbuild_id[SBUILD_ID_SIZE];
> @@ -189,7 +213,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;
> -- 
> 2.34.1
>
Re: [PATCH v5 8/8] perf buildid-cache: recognize vdso when adding files
Posted by duchangbin 1 year, 5 months ago
Hi, Namhyung,
On Wed, Jul 03, 2024 at 04:18:26PM -0700, Namhyung Kim wrote:
> Hello,
> 
> On Tue, Jul 02, 2024 at 12:18:37PM +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, adding vdso using above command actually will never
> > be used.
> 
> Can we handle /tmp/perf-vdso.so-XXXXXX too?
>
This temporary path is already handled by perf_session__cache_build_ids()->...->dso__cache_build_id().

> Thanks,
> Namhyung
> 
> > 
> > Signed-off-by: Changbin Du <changbin.du@huawei.com>
> > ---
> >  tools/perf/builtin-buildid-cache.c | 26 +++++++++++++++++++++++++-
> >  1 file changed, 25 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
> > index b0511d16aeb6..8edea9044a65 100644
> > --- a/tools/perf/builtin-buildid-cache.c
> > +++ b/tools/perf/builtin-buildid-cache.c
> > @@ -172,6 +172,30 @@ static int build_id_cache__add_kcore(const char *filename, bool force)
> >  	return 0;
> >  }
> >  
> > +static bool filename_is_vdso(const char *filename)
> > +{
> > +	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 mememory\n");
> > +		return false;
> > +	}
> > +
> > +	bname = basename(fname);
> > +	if (!bname)
> > +		return false;
> > +
> > +	for (unsigned int i = 0; i < ARRAY_SIZE(vdso_names); i++) {
> > +		if (!strncmp(bname, vdso_names[i], strlen(vdso_names[i])))
> > +			return true;
> > +	}
> > +	return false;
> > +}
> > +
> >  static int build_id_cache__add_file(const char *filename, struct nsinfo *nsi)
> >  {
> >  	char sbuild_id[SBUILD_ID_SIZE];
> > @@ -189,7 +213,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;
> > -- 
> > 2.34.1
> > 
> 

-- 
Cheers,
Changbin Du