Received: by 10.192.165.156 with SMTP id m28csp667353imm; Fri, 13 Apr 2018 05:56:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Uzl5rhgv3knqYNkGZr+8rf9bvb3ckUneHsVHr9knexBGVlnRKXzCw2O2pqhifWjUUqzsn X-Received: by 2002:a17:902:28c3:: with SMTP id f61-v6mr5230569plb.114.1523624206446; Fri, 13 Apr 2018 05:56:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523624206; cv=none; d=google.com; s=arc-20160816; b=DyluwatHfaOVoVkHmXxqND3OxrEZJl+5CK8pWbw92ngceOdZwuCyXVAKx43kQAFz+C uvFiarMZZSpT7cRW5NJKpoUfinakFddYR8j4Xhw72RXWQPnSx0P1z+71LYVeERU+PjKd PodrBgzZW6QoyYZGFvsp4L1kZldIU83rGylFgc1P/muaLYBkLLW4fdLEm6x2cmjo9+gD o3XHTNmIntJ1OAJIgDT3Vt06RRJu3fTuZOzKDD3/LrWO7ET03WPqq+pK+QbrlRYezOvX iqrvNP4XOKL65xN4KtPoUOgz3skR1rs/QnjnP9vWnvVOivx1aqJBIof2x1ehB1tUhMkM FI5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=YBzTAC99lX8gYGjN9pJ3UvBfOwXX/GtbeaSSMc0Jv+w=; b=OO5nQbkenSH/5YO9p8Q1mE4O2ZsCIiEQ0yHQV/UJKAeAsCy5Qzegq6rBDHBQCJO1YF 5G+3nyeG3KwjwNKfsbGknnaBtYaTYr72J9kB96If1eRs+Qkw3uVujsjtlQ2pnRVW26ek M8kPTmXhbeI9fh8lowV0Vzod6QdPOVXm2s8Jk67xGWxkoNMgDzjDbcuwGwmzIuoA8Ctk VNgm8T5TUrGZya6aKbfSf0AYQjFUFNenKrKIzWjJ4++iLMqO7w+UWo941kkP8Bwm5Ot2 T7j/5SwZxW5Vcp+fucJe4b3mX8E4vuLqVXB2fiUpTmHuwYn8l2fFwWXWARjvibEm6hjX nftw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v13si4060435pgq.478.2018.04.13.05.56.31; Fri, 13 Apr 2018 05:56:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753914AbeDMMzW (ORCPT + 99 others); Fri, 13 Apr 2018 08:55:22 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44198 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750940AbeDMMzU (ORCPT ); Fri, 13 Apr 2018 08:55:20 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 16C728182D11; Fri, 13 Apr 2018 12:55:20 +0000 (UTC) Received: from krava (unknown [10.40.205.63]) by smtp.corp.redhat.com (Postfix) with SMTP id 9F35210F1BF8; Fri, 13 Apr 2018 12:55:16 +0000 (UTC) Date: Fri, 13 Apr 2018 14:55:15 +0200 From: Jiri Olsa To: Ravi Bangoria Cc: acme@redhat.com, mhiramat@kernel.org, kstewart@linuxfoundation.org, tglx@linutronix.de, pombredanne@nexb.com, linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, namhyung@kernel.org, uneedsihyeon@gmail.com, kjlx@templeofstupid.com Subject: Re: [PATCH 2/3] perf/buildid-cache: Support --list option Message-ID: <20180413125515.GE28241@krava> References: <20180409110633.20767-1-ravi.bangoria@linux.vnet.ibm.com> <20180409110633.20767-3-ravi.bangoria@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180409110633.20767-3-ravi.bangoria@linux.vnet.ibm.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 13 Apr 2018 12:55:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 13 Apr 2018 12:55:20 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jolsa@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 09, 2018 at 04:36:32PM +0530, Ravi Bangoria wrote: > Perf buildid-cache allows to add/remove files into cache but there > is no option to list all cached files. Add --list option to list > all _valid_ cached files. > > Ex, > # perf buildid-cache --add /tmp/a.out > # perf buildid-cache -l > /tmp/a.out (8a86ef73e44067bca52cc3f6cd3e5446c783391c) could you please make them displayed the same way as in perf buildid-list [jolsa@krava perf]$ ./perf buildid-list 8b581c1243ade7d7b0f535add0b89405c89dd170 [kernel.kallsyms] 050d0ac0b68aebdcace1290ed4007442ecaef562 /usr/lib64/libc-2.25.so ac4597b8b29cc9b89a3afbac37332a5d954ee6a4 /usr/lib64/libpthread-2.25.so thanks, jirka > > Signed-off-by: Ravi Bangoria > --- > tools/perf/Documentation/perf-buildid-cache.txt | 4 ++- > tools/perf/builtin-buildid-cache.c | 41 +++++++++++++++++++++++-- > 2 files changed, 41 insertions(+), 4 deletions(-) > > diff --git a/tools/perf/Documentation/perf-buildid-cache.txt b/tools/perf/Documentation/perf-buildid-cache.txt > index 73c2650bd0db..3f285ba6e1f9 100644 > --- a/tools/perf/Documentation/perf-buildid-cache.txt > +++ b/tools/perf/Documentation/perf-buildid-cache.txt > @@ -59,7 +59,9 @@ OPTIONS > exactly same build-id, that is replaced by new one. It can be used > to update kallsyms and kernel dso to vmlinux in order to support > annotation. > - > +-l:: > +--list:: > + List all valid binaries from cache. > -v:: > --verbose:: > Be more verbose. > diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c > index 41db2cba77eb..50db05bd0cc6 100644 > --- a/tools/perf/builtin-buildid-cache.c > +++ b/tools/perf/builtin-buildid-cache.c > @@ -25,6 +25,7 @@ > #include "util/session.h" > #include "util/symbol.h" > #include "util/time-utils.h" > +#include "util/probe-file.h" > > static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid) > { > @@ -297,6 +298,25 @@ static int build_id_cache__update_file(const char *filename, struct nsinfo *nsi) > return err; > } > > +static void build_id_cache__show_all(void) > +{ > + struct strlist *bidlist; > + struct str_node *nd; > + char *buf; > + > + bidlist = build_id_cache__list_all(true); > + if (!bidlist) { > + pr_debug("Failed to get buildids: -%d\n", errno); > + return; > + } > + strlist__for_each_entry(nd, bidlist) { > + buf = build_id_cache__origname(nd->s); > + printf("%s (%s)\n", buf, nd->s); > + free(buf); > + } > + strlist__delete(bidlist); > +} > + > int cmd_buildid_cache(int argc, const char **argv) > { > struct strlist *list; > @@ -304,6 +324,8 @@ int cmd_buildid_cache(int argc, const char **argv) > int ret = 0; > int ns_id = -1; > bool force = false; > + bool list_files = false; > + bool opts_flag = false; > char const *add_name_list_str = NULL, > *remove_name_list_str = NULL, > *purge_name_list_str = NULL, > @@ -327,6 +349,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('l', "list", &list_files, "list all cached files"), > OPT_STRING('M', "missing", &missing_filename, "file", > "to find missing build ids in the cache"), > OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), > @@ -344,11 +367,18 @@ int cmd_buildid_cache(int argc, const char **argv) > argc = parse_options(argc, argv, buildid_cache_options, > buildid_cache_usage, 0); > > - if (argc || (!add_name_list_str && !kcore_filename && > - !remove_name_list_str && !purge_name_list_str && > - !missing_filename && !update_name_list_str)) > + opts_flag = add_name_list_str || kcore_filename || > + remove_name_list_str || purge_name_list_str || > + missing_filename || update_name_list_str; > + > + if (argc || !(list_files || opts_flag)) > usage_with_options(buildid_cache_usage, buildid_cache_options); > > + /* -l is exclusive. It can not be used with other options. */ > + if (list_files && opts_flag) > + usage_with_options_msg(buildid_cache_usage, > + buildid_cache_options, "-l is exclusive.\n"); > + > if (ns_id > 0) > nsi = nsinfo__new(ns_id); > > @@ -366,6 +396,11 @@ int cmd_buildid_cache(int argc, const char **argv) > > setup_pager(); > > + if (list_files) { > + build_id_cache__show_all(); > + goto out; > + } > + > if (add_name_list_str) { > list = strlist__new(add_name_list_str, NULL); > if (list) { > -- > 2.14.3 >