public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Adrian Hunter <adrian.hunter@intel.com>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
	Paul Mackerras <paulus@samba.org>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>, Borislav Petkov <bp@suse.de>,
	Hemant Kumar <hemant@linux.vnet.ibm.com>
Subject: Re: [perf/core PATCH v2 3/4] perf buildid-cache: Add new buildid cache if update target is not cached
Date: Wed, 11 Feb 2015 11:49:28 -0300	[thread overview]
Message-ID: <20150211144928.GH24251@kernel.org> (raw)
In-Reply-To: <20150210091855.19264.32910.stgit@localhost.localdomain>

Em Tue, Feb 10, 2015 at 06:18:56PM +0900, Masami Hiramatsu escreveu:
> Add new buildid cache if the update target file is not cached.
> This can happen when an old binary is replaced by new one
> after caching the old one. In this case, user sees his operation
> just failed. But it does not look straight, since user just
> pass the binary "path", not "build-id".
> 
>   ----
>   # ./perf buildid-cache --add ./perf
>   (update ./perf to new binary)
>   # ./perf buildid-cache --update ./perf
>   ./perf wasn't in the cache

Humm, without re-reading the original motivation for the '--update'
operation I would think it was about finding all build-ids in the cache
that are for a binary with that path, remove them and insert this new
one, no?

Checking...

>   #
>   ----
> 
> This patch adds given new binary to cache if the new binary is
> not cached. So we'll not see the above error.
> 
>   ----
>   # ./perf buildid-cache --add ./perf
>   (update ./perf to new binary)
>   # ./perf buildid-cache --update ./perf
>   #
>   ----
> 
> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> ---
>  tools/perf/Documentation/perf-buildid-cache.txt |    2 ++
>  tools/perf/builtin-buildid-cache.c              |    6 ++++--
>  tools/perf/util/build-id.c                      |   12 ++++++++++++
>  tools/perf/util/build-id.h                      |    1 +
>  4 files changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/Documentation/perf-buildid-cache.txt b/tools/perf/Documentation/perf-buildid-cache.txt
> index 0294c57..6575dce 100644
> --- a/tools/perf/Documentation/perf-buildid-cache.txt
> +++ b/tools/perf/Documentation/perf-buildid-cache.txt
> @@ -44,6 +44,8 @@ OPTIONS
>  --update::
>  	Update specified file of the cache. It can be used to update kallsyms
>  	kernel dso to vmlinux in order to support annotation.
> +	If there is no cache which has given binary's build-id, this just adds
> +	new one.
>  -v::
>  --verbose::
>  	Be more verbose.
> diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
> index d929d95..e7568f5 100644
> --- a/tools/perf/builtin-buildid-cache.c
> +++ b/tools/perf/builtin-buildid-cache.c
> @@ -255,7 +255,7 @@ static int build_id_cache__update_file(const char *filename)
>  	u8 build_id[BUILD_ID_SIZE];
>  	char sbuild_id[BUILD_ID_SIZE * 2 + 1];
>  
> -	int err;
> +	int err = 0;
>  
>  	if (filename__read_build_id(filename, &build_id, sizeof(build_id)) < 0) {
>  		pr_debug("Couldn't read a build-id in %s\n", filename);
> @@ -263,7 +263,9 @@ static int build_id_cache__update_file(const char *filename)
>  	}
>  
>  	build_id__sprintf(build_id, sizeof(build_id), sbuild_id);
> -	err = build_id_cache__remove_s(sbuild_id);
> +	if (build_id_cache__cached(sbuild_id))
> +		err = build_id_cache__remove_s(sbuild_id);
> +
>  	if (!err)
>  		err = build_id_cache__add_s(sbuild_id, filename, false, false);
>  
> diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
> index adbc360..0bc33be 100644
> --- a/tools/perf/util/build-id.c
> +++ b/tools/perf/util/build-id.c
> @@ -352,6 +352,18 @@ static int build_id_cache__add_b(const u8 *build_id, size_t build_id_size,
>  	return build_id_cache__add_s(sbuild_id, name, is_kallsyms, is_vdso);
>  }
>  
> +bool build_id_cache__cached(const char *sbuild_id)
> +{
> +	bool ret = false;
> +	char *filename = build_id__filename(sbuild_id, NULL, 0);
> +
> +	if (filename && !access(filename, F_OK))
> +		ret = true;
> +	free(filename);
> +
> +	return ret;
> +}
> +
>  int build_id_cache__remove_s(const char *sbuild_id)
>  {
>  	const size_t size = PATH_MAX;
> diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
> index 31b3c63..2a09498 100644
> --- a/tools/perf/util/build-id.h
> +++ b/tools/perf/util/build-id.h
> @@ -22,6 +22,7 @@ bool perf_session__read_build_ids(struct perf_session *session, bool with_hits);
>  int perf_session__write_buildid_table(struct perf_session *session, int fd);
>  int perf_session__cache_build_ids(struct perf_session *session);
>  
> +bool build_id_cache__cached(const char *sbuild_id);
>  int build_id_cache__add_s(const char *sbuild_id,
>  			  const char *name, bool is_kallsyms, bool is_vdso);
>  int build_id_cache__remove_s(const char *sbuild_id);

  reply	other threads:[~2015-02-11 14:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-10  9:18 [perf/core PATCH v2 0/4] perf-buildid-cache: Cleanup, enhance --update and add --remove-all Masami Hiramatsu
2015-02-10  9:18 ` [perf/core PATCH v2 1/4] perf-buildid-cache: Remove unneeded debugdir parameters Masami Hiramatsu
2015-02-18 18:29   ` [tip:perf/core] perf buildid-cache: " tip-bot for Masami Hiramatsu
2015-02-10  9:18 ` [perf/core PATCH v2 2/4] perf buildid-cache: Consolidate .build-id cache path generators Masami Hiramatsu
2015-02-11 14:46   ` Arnaldo Carvalho de Melo
2015-02-18 18:30   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2015-02-10  9:18 ` [perf/core PATCH v2 3/4] perf buildid-cache: Add new buildid cache if update target is not cached Masami Hiramatsu
2015-02-11 14:49   ` Arnaldo Carvalho de Melo [this message]
2015-02-11 14:57     ` Arnaldo Carvalho de Melo
2015-02-12  6:36       ` Masami Hiramatsu
2015-02-12 14:11         ` Arnaldo Carvalho de Melo
2015-02-10  9:18 ` [perf/core PATCH v2 4/4] perf buildid-cache: Add --remove-all FILE to remove all caches of FILE Masami Hiramatsu
2015-02-11 15:00   ` Arnaldo Carvalho de Melo
2015-02-12  6:13     ` Masami Hiramatsu
2015-02-12 14:12       ` Arnaldo Carvalho de Melo
2015-02-10 14:09 ` [perf/core PATCH v2 0/4] perf-buildid-cache: Cleanup, enhance --update and add --remove-all Namhyung Kim

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=20150211144928.GH24251@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=adrian.hunter@intel.com \
    --cc=bp@suse.de \
    --cc=hemant@linux.vnet.ibm.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.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