Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751384AbbBUN5S (ORCPT ); Sat, 21 Feb 2015 08:57:18 -0500 Received: from mail-pa0-f52.google.com ([209.85.220.52]:37323 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750895AbbBUN5R (ORCPT ); Sat, 21 Feb 2015 08:57:17 -0500 Date: Sat, 21 Feb 2015 22:56:45 +0900 From: Namhyung Kim To: Masami Hiramatsu Cc: Arnaldo Carvalho de Melo , Peter Zijlstra , Adrian Hunter , linux-kernel@vger.kernel.org, Ingo Molnar , Paul Mackerras , Jiri Olsa , Borislav Petkov , Hemant Kumar Subject: Re: [perf/core PATCH v4 2/2] perf buildid-cache: Add --purge FILE to remove all caches of FILE Message-ID: <20150221135645.GA10557@danjae> References: <20150220094145.4942.22046.stgit@localhost.localdomain> <20150220094150.4942.13002.stgit@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150220094150.4942.13002.stgit@localhost.localdomain> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4097 Lines: 125 Hi Masami, On Fri, Feb 20, 2015 at 06:41:50PM +0900, Masami Hiramatsu wrote: > Add --purge FILE to remove all caches of FILE. > Since the current --remove FILE removes a cache which has > same build-id of given FILE. Since the command takes a > FILE path, it can confuse user who tries to remove cache > about FILE path. > > ----- > # ./perf buildid-cache -v --add ./perf > Adding 133b7b5486d987a5ab5c3ebf4ea14941f45d4d4f ./perf: Ok > # (update the ./perf binary) > # ./perf buildid-cache -v --remove ./perf > Removing 305bbd1be68f66eca7e2d78db294653031edfa79 ./perf: FAIL > ./perf wasn't in the cache > ----- > Actually, the --remove's FAIL is not shown, it just silently fails. > > So, this patch adds --purge FILE action for such usecase. > perf buildid-cache --purge FILE removes all caches which > has same FILE path. > In other words, it removes all caches including old binaries. > > ----- > # ./perf buildid-cache -v --add ./perf > Adding 133b7b5486d987a5ab5c3ebf4ea14941f45d4d4f ./perf: Ok > # (update the ./perf binary) > # ./perf buildid-cache -v --purge ./perf > Removing 133b7b5486d987a5ab5c3ebf4ea14941f45d4d4f ./perf: Ok > ----- > > BTW, if you want to purge all the caches, remove ~/.debug/* . > > Signed-off-by: Masami Hiramatsu I have a nitpick below - other than that both patches look good. Acked-by: Namhyung Kim Thanks, Namhyung > --- > tools/perf/Documentation/perf-buildid-cache.txt | 13 ++- > tools/perf/builtin-buildid-cache.c | 44 ++++++++++++ > tools/perf/util/build-id.c | 86 ++++++++++++++++++----- > tools/perf/util/build-id.h | 1 > 4 files changed, 123 insertions(+), 21 deletions(-) > > diff --git a/tools/perf/Documentation/perf-buildid-cache.txt b/tools/perf/Documentation/perf-buildid-cache.txt > index cec6b57..dd07b55 100644 > --- a/tools/perf/Documentation/perf-buildid-cache.txt > +++ b/tools/perf/Documentation/perf-buildid-cache.txt > @@ -12,9 +12,9 @@ SYNOPSIS > > DESCRIPTION > ----------- > -This command manages the build-id cache. It can add and remove files to/from > -the cache. In the future it should as well purge older entries, set upper > -limits for the space used by the cache, etc. > +This command manages the build-id cache. It can add, remove, update and purge > +files to/from the cache. In the future it should as well set upper limits for > +the space used by the cache, etc. > > OPTIONS > ------- > @@ -36,7 +36,12 @@ OPTIONS > actually made. > -r:: > --remove=:: > - Remove specified file from the cache. > + Remove a cached binary which has same build-id of specified file > + from the cache. > +-p:: > +--purge=:: > + Purge all cached binaries including older caches which have specified > + path from the cache. > -M:: > --missing=:: > List missing build ids in the cache for the specified file. > diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c > index e7568f5..37182bb 100644 > --- a/tools/perf/builtin-buildid-cache.c > +++ b/tools/perf/builtin-buildid-cache.c > @@ -223,6 +223,29 @@ static int build_id_cache__remove_file(const char *filename) > return err; > } > > +static int build_id_cache__purge_path(const char *pathname) > +{ > + struct strlist *list; > + struct str_node *pos; > + int err; > + > + list = build_id_cache__list_build_ids(pathname); > + if (!list) > + return 0; > + > + strlist__for_each(pos, list) { > + err = build_id_cache__remove_s(pos->s); > + if (verbose) > + pr_info("Removing %s %s: %s\n", pos->s, pathname, > + err ? "FAIL" : "Ok"); You can simply use pr_debug() here. :) Thanks, Namhyung > + if (err) > + break; > + } > + strlist__delete(list); > + > + return err; > +} > + -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/