LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org> To: Ingo Molnar <mingo@kernel.org> Cc: Clark Williams <williams@redhat.com>, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Kate Stewart <kstewart@linuxfoundation.org>, Krister Johansen <kjlx@templeofstupid.com>, Masami Hiramatsu <mhiramat@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Philippe Ombredanne <pombredanne@nexb.com>, Sihyeon Jang <uneedsihyeon@gmail.com>, Thomas Gleixner <tglx@linutronix.de>, Arnaldo Carvalho de Melo <acme@redhat.com> Subject: [PATCH 02/52] perf buildid-cache: Support --purge-all option Date: Wed, 2 May 2018 12:18:52 -0300 [thread overview] Message-ID: <20180502151942.20542-3-acme@kernel.org> (raw) In-Reply-To: <20180502151942.20542-1-acme@kernel.org> From: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> User can remove files from cache using --remove/--purge options but both needs list of files as an argument. It's not convenient when you want to flush out entire cache. Add an option to purge all files from cache. Ex, # perf buildid-cache -l 8a86ef73e44067bca52cc3f6cd3e5446c783391c /tmp/a.out ebe71fdcf4b366518cc154d570a33cd461a51c36 /tmp/a.out.1 # perf buildid-cache -P -v Removing /tmp/a.out (8a86ef73e44067bca52cc3f6cd3e5446c783391c): Ok Removing /tmp/a.out.1 (ebe71fdcf4b366518cc154d570a33cd461a51c36): Ok Purged all: Ok Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Kate Stewart <kstewart@linuxfoundation.org> Cc: Krister Johansen <kjlx@templeofstupid.com> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Philippe Ombredanne <pombredanne@nexb.com> Cc: Sihyeon Jang <uneedsihyeon@gmail.com> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/20180417041346.5617-4-ravi.bangoria@linux.vnet.ibm.com [ Initialize 'err' in build_id_cache__purge_all(), to fix build on debian:7, as it can be used uninitialized ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> --- tools/perf/Documentation/perf-buildid-cache.txt | 3 +++ tools/perf/builtin-buildid-cache.c | 36 ++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/tools/perf/Documentation/perf-buildid-cache.txt b/tools/perf/Documentation/perf-buildid-cache.txt index 3f285ba6e1f9..f6de0952ff3c 100644 --- a/tools/perf/Documentation/perf-buildid-cache.txt +++ b/tools/perf/Documentation/perf-buildid-cache.txt @@ -48,6 +48,9 @@ OPTIONS --purge=:: Purge all cached binaries including older caches which have specified path from the cache. +-P:: +--purge-all:: + Purge all cached binaries. This will flush out entire 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 fd0a08661b42..7a7403913b57 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c @@ -240,6 +240,34 @@ static int build_id_cache__purge_path(const char *pathname, struct nsinfo *nsi) return err; } +static int build_id_cache__purge_all(void) +{ + struct strlist *list; + struct str_node *pos; + int err = 0; + char *buf; + + list = build_id_cache__list_all(false); + if (!list) { + pr_debug("Failed to get buildids: -%d\n", errno); + return -EINVAL; + } + + strlist__for_each_entry(pos, list) { + buf = build_id_cache__origname(pos->s); + err = build_id_cache__remove_s(pos->s); + pr_debug("Removing %s (%s): %s\n", buf, pos->s, + err ? "FAIL" : "Ok"); + free(buf); + if (err) + break; + } + strlist__delete(list); + + pr_debug("Purged all: %s\n", err ? "FAIL" : "Ok"); + return err; +} + static bool dso__missing_buildid_cache(struct dso *dso, int parm __maybe_unused) { char filename[PATH_MAX]; @@ -327,6 +355,7 @@ int cmd_buildid_cache(int argc, const char **argv) bool force = false; bool list_files = false; bool opts_flag = false; + bool purge_all = false; char const *add_name_list_str = NULL, *remove_name_list_str = NULL, *purge_name_list_str = NULL, @@ -350,6 +379,7 @@ int cmd_buildid_cache(int argc, const char **argv) "file(s) to remove"), OPT_STRING('p', "purge", &purge_name_list_str, "file list", "file(s) to remove (remove old caches too)"), + OPT_BOOLEAN('P', "purge-all", &purge_all, "purge all cached files"), OPT_BOOLEAN('l', "list", &list_files, "list all cached files"), OPT_STRING('M', "missing", &missing_filename, "file", "to find missing build ids in the cache"), @@ -370,7 +400,8 @@ int cmd_buildid_cache(int argc, const char **argv) opts_flag = add_name_list_str || kcore_filename || remove_name_list_str || purge_name_list_str || - missing_filename || update_name_list_str; + missing_filename || update_name_list_str || + purge_all; if (argc || !(list_files || opts_flag)) usage_with_options(buildid_cache_usage, buildid_cache_options); @@ -457,6 +488,9 @@ int cmd_buildid_cache(int argc, const char **argv) } } + if (purge_all) + ret = build_id_cache__purge_all(); + if (missing_filename) ret = build_id_cache__fprintf_missing(session, stdout); -- 2.14.3
next prev parent reply other threads:[~2018-05-02 15:34 UTC|newest] Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-05-02 15:18 [GIT PULL 00/52] perf/core improvements and fixes Arnaldo Carvalho de Melo 2018-05-02 15:18 ` [PATCH 01/52] perf buildid-cache: Support --list option Arnaldo Carvalho de Melo 2018-05-02 15:18 ` Arnaldo Carvalho de Melo [this message] 2018-05-02 15:18 ` [PATCH 03/52] perf check-headers.sh: Simplify arguments passing Arnaldo Carvalho de Melo 2018-05-02 15:18 ` [PATCH 04/52] perf check-headers.sh: Add support to check 2 independent files Arnaldo Carvalho de Melo 2018-05-02 15:18 ` [PATCH 05/52] perf stat: Display time in precision based on std deviation Arnaldo Carvalho de Melo 2018-05-02 15:18 ` [PATCH 06/52] perf stat: Add --table option to display time of each run Arnaldo Carvalho de Melo 2018-05-02 15:18 ` [PATCH 07/52] perf stat: Display length strings of each run for --table option Arnaldo Carvalho de Melo 2018-05-02 15:18 ` [PATCH 08/52] perf top: Use __map__is_kernel() Arnaldo Carvalho de Melo 2018-05-02 15:18 ` [PATCH 09/52] perf symbols: Use __map__is_kernel() instead of ad-hoc equivalent code Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 10/52] perf dso: Add dso__has_symbols() method Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 11/52] perf map: Introduce map__has_symbols() Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 12/52] perf thread: Introduce thread__find_map() Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 13/52] perf tests: Let 'perf test list' display subtests Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 14/52] perf thread: Introduce thread__find_symbol() Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 15/52] perf script: Use thread__find_symbol() instead of ad-hoc equivalent Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 16/52] perf thread: Make thread__find_map() return the map Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 17/52] perf thread: Make thread__find_symbol() return the symbol searched Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 18/52] perf map: Shorten map_groups__find_by_name() signature Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 19/52] perf Documentation: Support for asciidoctor Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 20/52] perf machine: Introduce machine__kernel_maps() Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 21/52] perf machine: Shorten machine__load_kallsyms() signature Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 22/52] perf machine: Remove needless map_type from machine__load_vmlinux_path() Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 23/52] perf tests vmlinux-kallsyms: Use machine__find_kernel_function(_by_name) Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 24/52] perf tests vmlinux-kallsyms: Use map__for_each_symbol() instead of open coded equivalent Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 25/52] perf map: Shorten map_groups__find() signature Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 26/52] perf ui stdio: Use map_groups__fprintf() Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 27/52] perf symbols: Shorten dso__(first|last)_symbol() Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 28/52] tools lib symbols: Introduce kallsyms__is_function() Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 29/52] perf tools: Use kallsyms__is_function() Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 30/52] perf symbols: Unexport symbol_type__is_a() Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 31/52] perf map: Remove enum_type arg to map_groups__first() Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 32/52] perf symbols: Remove map_type arg from dso__find_symbol() Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 33/52] perf thread: Remove addr_type arg from thread__find_cpumode_addr_location() Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 34/52] perf machine: Use machine__find_kernel_function() instead of open coded version Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 35/52] perf thread: Ditch __thread__find_symbol() Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 36/52] perf thread: Make thread__find_map() search all maps Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 37/52] perf map: Remove map_type arg from map_groups__find() Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 38/52] perf symbols: Store the ELF symbol type in the symbol struct Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 39/52] perf machine: Set PROT_EXEC for executable PERF_RECORD_MMAP records Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 40/52] perf sort: Use mmap->prot on "dcacheline" formatting Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 41/52] perf symbols: No need to special case MAP__FUNCTION in fixup Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 42/52] perf symbols: Use symbol type instead of map->type Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 43/52] perf map: Use map->prot in place of type==MAP__FUNCTION Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 44/52] perf symbols: " Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 45/52] perf symbols: Unify symbol maps Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 46/52] perf symbols: Remove needless goto Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 47/52] perf symbols: Split kernel symbol processing from dso__load_sym() Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 48/52] perf symbols: Remove unused dso__load_all_kallsyms() 'map' parameter Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 49/52] perf symbols: kallsyms__delta() needs the kmap, not the map Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 50/52] perf symbols: Move split_kallsyms to struct map_groups Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 51/52] perf tools: Fix spelling mistake: "builid" -> "buildid" Arnaldo Carvalho de Melo 2018-05-02 15:19 ` [PATCH 52/52] perf machine: Ditch find_kernel_function variants Arnaldo Carvalho de Melo
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=20180502151942.20542-3-acme@kernel.org \ --to=acme@kernel.org \ --cc=acme@redhat.com \ --cc=alexander.shishkin@linux.intel.com \ --cc=kjlx@templeofstupid.com \ --cc=kstewart@linuxfoundation.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-perf-users@vger.kernel.org \ --cc=mhiramat@kernel.org \ --cc=mingo@kernel.org \ --cc=namhyung@kernel.org \ --cc=peterz@infradead.org \ --cc=pombredanne@nexb.com \ --cc=ravi.bangoria@linux.vnet.ibm.com \ --cc=tglx@linutronix.de \ --cc=uneedsihyeon@gmail.com \ --cc=williams@redhat.com \ /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: linkBe 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; as well as URLs for NNTP newsgroup(s).