From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: linux-kernel@vger.kernel.org, Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Hemant Kumar <hemant@linux.vnet.ibm.com>,
Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Subject: Re: [PATCH perf/core v5 02/15] perf-buildid-cache: Use path/to/bin/buildid/elf instead of path/to/bin/buildid
Date: Wed, 27 Apr 2016 18:23:50 -0300 [thread overview]
Message-ID: <20160427212350.GR11033@kernel.org> (raw)
In-Reply-To: <20160427183723.23446.47139.stgit@devbox>
Em Thu, Apr 28, 2016 at 03:37:23AM +0900, Masami Hiramatsu escreveu:
> From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
>
> Use path/to/bin/buildid/elf instead of path/to/bin/buildid
> to store corresponding elf binary.
> This also stores vdso in buildid/vdso, kallsyms in buildid/kallsyms.
>
> Note that the existing caches are not updated until user adds
> or updates the cache. Anyway, if there is the old style build-id
> cache it falls back to use it. (IOW, it is backward compatible)
>
> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> ---
> Changes in v5:
> - Support old style buildid caches.
> + /* Remove old style build-id cache */
> + if (__is_regular_file(dir_name))
> + if (unlink(dir_name))
> + goto out_free;
Shouldn't this just fail and require the user to use --force/-f or purge
first?
- Arnaldo
> if (mkdir_p(dir_name, 0755))
> goto out_free;
>
> - if (asprintf(&filename, "%s/%s", dir_name, sbuild_id) < 0) {
> + /* Save the allocated buildid dirname */
> + if (asprintf(&filename, "%s/%s", dir_name,
> + build_id_cache__basename(is_kallsyms, is_vdso)) < 0) {
> filename = NULL;
> goto out_free;
> }
> @@ -437,7 +479,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *name,
> goto out_free;
> }
>
> - if (!build_id__filename(sbuild_id, linkname, size))
> + if (!build_id_cache__linkname(sbuild_id, linkname, size))
> goto out_free;
> tmp = strrchr(linkname, '/');
> *tmp = '\0';
> @@ -446,10 +488,10 @@ int build_id_cache__add_s(const char *sbuild_id, const char *name,
> goto out_free;
>
> *tmp = '/';
> - targetname = filename + strlen(buildid_dir) - 5;
> - memcpy(targetname, "../..", 5);
> + tmp = dir_name + strlen(buildid_dir) - 5;
> + memcpy(tmp, "../..", 5);
>
> - if (symlink(targetname, linkname) == 0)
> + if (symlink(tmp, linkname) == 0)
> err = 0;
> out_free:
> if (!is_kallsyms)
> @@ -474,7 +516,7 @@ static int build_id_cache__add_b(const u8 *build_id, size_t build_id_size,
> bool build_id_cache__cached(const char *sbuild_id)
> {
> bool ret = false;
> - char *filename = build_id__filename(sbuild_id, NULL, 0);
> + char *filename = build_id_cache__linkname(sbuild_id, NULL, 0);
>
> if (filename && !access(filename, F_OK))
> ret = true;
> @@ -493,7 +535,7 @@ int build_id_cache__remove_s(const char *sbuild_id)
> if (filename == NULL || linkname == NULL)
> goto out_free;
>
> - if (!build_id__filename(sbuild_id, linkname, size))
> + if (!build_id_cache__linkname(sbuild_id, linkname, size))
> goto out_free;
>
> if (access(linkname, F_OK))
> @@ -511,7 +553,7 @@ int build_id_cache__remove_s(const char *sbuild_id)
> tmp = strrchr(linkname, '/') + 1;
> snprintf(tmp, size - (tmp - linkname), "%s", filename);
>
> - if (unlink(linkname))
> + if (rm_rf(linkname))
> goto out_free;
>
> err = 0;
> @@ -523,7 +565,7 @@ out_free:
>
> static int dso__cache_build_id(struct dso *dso, struct machine *machine)
> {
> - bool is_kallsyms = dso->kernel && dso->long_name[0] != '/';
> + bool is_kallsyms = dso__is_kallsyms(dso);
> bool is_vdso = dso__is_vdso(dso);
> const char *name = dso->long_name;
> char nm[PATH_MAX];
> diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
> index 0953280..76d79d0 100644
> --- a/tools/perf/util/dso.h
> +++ b/tools/perf/util/dso.h
> @@ -349,6 +349,11 @@ static inline bool dso__is_kcore(struct dso *dso)
> dso->binary_type == DSO_BINARY_TYPE__GUEST_KCORE;
> }
>
> +static inline bool dso__is_kallsyms(struct dso *dso)
> +{
> + return dso->kernel && dso->long_name[0] != '/';
> +}
> +
> void dso__free_a2l(struct dso *dso);
>
> enum dso_type dso__type(struct dso *dso, struct machine *machine);
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index 415c4f6..9463c7d 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -1685,13 +1685,18 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)
> if (!find_matching_kcore(map, path, sizeof(path)))
> return strdup(path);
>
> - scnprintf(path, sizeof(path), "%s/[kernel.kallsyms]/%s",
> + scnprintf(path, sizeof(path), "%s/[kernel.kallsyms]/%s/kallsyms",
> buildid_dir, sbuild_id);
> -
> + /* Try old style kallsyms cache */
> if (access(path, F_OK)) {
> - pr_err("No kallsyms or vmlinux with build-id %s was found\n",
> - sbuild_id);
> - return NULL;
> + scnprintf(path, sizeof(path), "%s/[kernel.kallsyms]/%s",
> + buildid_dir, sbuild_id);
> +
> + if (access(path, F_OK)) {
> + pr_err("No kallsyms or vmlinux with build-id %s was found\n",
> + sbuild_id);
> + return NULL;
> + }
> }
>
> return strdup(path);
next prev parent reply other threads:[~2016-04-27 21:23 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-27 18:37 [PATCH perf/core v5 00/15] perf-probe --cache and SDT support Masami Hiramatsu
2016-04-27 18:37 ` [PATCH perf/core v5 01/15] perf probe: Use strbuf for making strings Masami Hiramatsu
2016-05-01 7:38 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2016-04-27 18:37 ` [PATCH perf/core v5 02/15] perf-buildid-cache: Use path/to/bin/buildid/elf instead of path/to/bin/buildid Masami Hiramatsu
2016-04-27 21:12 ` Arnaldo Carvalho de Melo
2016-04-28 1:52 ` Masami Hiramatsu
2016-04-27 21:23 ` Arnaldo Carvalho de Melo [this message]
2016-04-28 1:51 ` Masami Hiramatsu
2016-04-28 1:22 ` Namhyung Kim
2016-04-28 22:50 ` Masami Hiramatsu
2016-04-27 18:37 ` [PATCH perf/core v5 03/15] perf-buildid-cache: Use lsdir for looking up buildid caches Masami Hiramatsu
2016-04-27 18:37 ` [PATCH perf/core v5 04/15] perf probe: Add --cache option to cache the probe definitions Masami Hiramatsu
2016-04-28 2:12 ` Namhyung Kim
2016-04-28 23:14 ` Masami Hiramatsu
2016-04-28 2:32 ` Namhyung Kim
2016-04-28 23:06 ` Masami Hiramatsu
2016-04-27 18:37 ` [PATCH perf/core v5 05/15] perf probe: Use cache entry if possible Masami Hiramatsu
2016-04-28 2:47 ` Namhyung Kim
2016-04-28 23:52 ` Masami Hiramatsu
2016-04-29 11:33 ` Namhyung Kim
2016-04-27 18:38 ` [PATCH perf/core v5 06/15] perf probe: Show all cached probes Masami Hiramatsu
2016-04-27 18:38 ` [PATCH perf/core v5 07/15] perf probe: Remove caches when --cache is given Masami Hiramatsu
2016-04-27 18:38 ` [PATCH perf/core v5 08/15] perf/sdt: ELF support for SDT Masami Hiramatsu
2016-04-27 18:38 ` [PATCH perf/core v5 09/15] perf probe: Add group name support Masami Hiramatsu
2016-04-27 18:38 ` [PATCH perf/core v5 10/15] perf buildid-cache: Scan and import user SDT events to probe cache Masami Hiramatsu
2016-04-27 20:32 ` Hemant Kumar
2016-04-27 18:38 ` [PATCH perf/core v5 11/15] perf probe: Accept %sdt and %cached event name Masami Hiramatsu
2016-04-27 20:50 ` Hemant Kumar
2016-04-28 5:26 ` Namhyung Kim
2016-04-29 0:13 ` Masami Hiramatsu
2016-04-27 18:38 ` [PATCH perf/core v5 12/15] perf-list: Show SDT and pre-cached events Masami Hiramatsu
2016-04-27 20:46 ` Hemant Kumar
2016-04-27 18:39 ` [PATCH perf/core v5 13/15] perf-list: Skip SDTs placed in invalid binaries Masami Hiramatsu
2016-04-27 18:39 ` [PATCH perf/core v5 14/15] perf probe: Allow wildcard for cached events Masami Hiramatsu
2016-04-27 18:42 ` Masami Hiramatsu
2016-04-27 19:15 ` [PATCH perf/core v5.1 " Masami Hiramatsu
2016-04-27 20:36 ` Hemant Kumar
2016-04-27 18:39 ` [PATCH perf/core v5 15/15] perf probe: Support @BUILDID or @FILE suffix for SDT events Masami Hiramatsu
2016-04-29 13:53 ` [PATCH perf/core v5 00/15] perf-probe --cache and SDT support Hemant Kumar
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=20160427212350.GR11033@kernel.org \
--to=acme@kernel.org \
--cc=ananth@linux.vnet.ibm.com \
--cc=hemant@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--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
Powered by JetHome