Received: by 10.192.165.156 with SMTP id m28csp1398950imm; Mon, 16 Apr 2018 21:15:55 -0700 (PDT) X-Google-Smtp-Source: AIpwx49+tSUOEwEdZndIN1UszYdUVh+GRmUUqZNVw+GMfI2lIT0ZAUlQq8o19CEuvmeCeKbpBofp X-Received: by 10.99.103.67 with SMTP id b64mr503477pgc.14.1523938554929; Mon, 16 Apr 2018 21:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523938554; cv=none; d=google.com; s=arc-20160816; b=BW6DkYIr+to0d8BCWLtWB7QF7iVtsv0sYv+oiQMsM7rXICQxRKISxagpMuYeGQoiD1 dQBDV4S/mcoNDiaIyhdRDFfOrSTFXsyJyZZ2LjOizMV6jGCr5s6Axppecua/aAEY/GLK u0Xelkzfj4PlBao3ce+iTD0zjG17tkQkfJRxihEszSw08HsT5xcxvpPFSvDfTnDMDRvc vqnEfbufzYky31TI+pUacrMeYDdsdGEKh3Ay/0Lk2qvNdTEuL/V2idjviBI4/FsaIoKZ bxCB7XRASjzRM7SK8Zo3rjRzmvS2fwpkj/1kuHjcPCT+U3MXZqtomQIMQxY3XLNxxJgH Yahw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=MbZ9L/9EclGQN4kf0MKqR68zr3J+IN/TMHh9hGs4za0=; b=dOxOL0Jvpz167ngVIRN1vA0uE3F0sqGnJ/IyOFU0zmwK9w++od+T6UuaUEAt4Ar5YV Qi0yoqdh4vNMsrcrbjp0Dn3XzTq55465jFdQyrTdzQfxa8uWSZ8t25fYtXCZJCA5pIF/ D+HroN+cxvagYsiPHWW58FR1UwG8rtDzZx1iiREhOp9DJqXBB9g9uqhr8ZlYmTEtqa11 vhgK+Ei38Bm/nkiXtFlTHgEcIKIKXzv2BnHqsOIZn3Wtg0nqj8ulepP+19IV78GAL378 rqfko1a5JfO3WDw7DBneZ0UQvRAvi+PmJQhk4/pwOvnNesT16qHVRtjKLDxS3OYYVehD yayA== 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q74si12436640pfg.295.2018.04.16.21.15.41; Mon, 16 Apr 2018 21:15:54 -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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752649AbeDQEOV (ORCPT + 99 others); Tue, 17 Apr 2018 00:14:21 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38138 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750802AbeDQEOT (ORCPT ); Tue, 17 Apr 2018 00:14:19 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3H4EIgm032531 for ; Tue, 17 Apr 2018 00:14:18 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hd6g070jh-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Tue, 17 Apr 2018 00:14:10 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 Apr 2018 05:14:09 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 17 Apr 2018 05:14:04 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3H4E4Te46399674; Tue, 17 Apr 2018 04:14:04 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BDF82A404D; Tue, 17 Apr 2018 05:06:13 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6330CA4057; Tue, 17 Apr 2018 05:06:11 +0100 (BST) Received: from bangoria.in.ibm.com (unknown [9.124.31.151]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 17 Apr 2018 05:06:11 +0100 (BST) From: Ravi Bangoria To: mhiramat@kernel.org, jolsa@redhat.com, acme@redhat.com Cc: 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, Ravi Bangoria Subject: [PATCH v2 3/3] perf/buildid-cache: Support --purge-all option Date: Tue, 17 Apr 2018 09:43:46 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180417041346.5617-1-ravi.bangoria@linux.vnet.ibm.com> References: <20180417041346.5617-1-ravi.bangoria@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041704-0044-0000-0000-00000548FF83 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041704-0045-0000-0000-000028890AC2 Message-Id: <20180417041346.5617-4-ravi.bangoria@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-17_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804170039 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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..d11226f76fbc 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; + 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