Received: by 10.213.65.68 with SMTP id h4csp2472137imn; Mon, 9 Apr 2018 04:11:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/uljRXPYWMlgsI+rM9/w36ltQJLILW4/EfOLYooNYlTNKY78gydmYnhhH7lo90xgqwDrfu X-Received: by 2002:a17:902:7087:: with SMTP id z7-v6mr39038528plk.315.1523272267432; Mon, 09 Apr 2018 04:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523272267; cv=none; d=google.com; s=arc-20160816; b=E094sozMnWuQaGvsu052NYuaB7NXqkDlf5ND1jIN7cI4JiaNXmQUoEXFkkQ3SBXls+ oNQevzkmazJLzYdxrkUHuKAtGJj2iCn8QqoKN03bEqdaRucMBNQSBt9AMiKl7hCPR2+X ak0cYgxQMNUbP/q15qIlUoxCYdpCd4Jfslyfx4U13SiUL3YnxJDAncHeflYEui2syNYr lW6K1NSsm3hd+cLG/spbuJv31DcY7Qi2av7AowIPS3ezjMgZoAPcTlCq3jwVadeSwbBt HHDa3qKG0+6YG8u/y+L2ciRTxf0vqAGpWkzfo47sY5Pj21JO5ZPcuioHu/7l0iHnBojO mg1Q== 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=8Z6a/M06I7xymTMXAYdpDw7yECnCme4Vt9zvswMiMeM=; b=LtJ0CKzNkg+6yxA9gPwvznc9EbnhsNFVnokEJ21xoxxmkSLIriCYIus9N+f68vNljV tRtlenLbjFf80IdYfLVboSJavJOOx6o9RtbP0j79oLfxW6ZmATiQaQ0Iz4FU7rLyq+tY wZD3xQqcfNd7fbLs04gvvuKg54ZCqsHOXvZTz3cjFqGTyjAigNXBxsmisQn9Kjae/oVW iTf6M+fG1IsN04GT8yY8NbqS3siIGrGZvIG/kw8RubsBsn/rLxyXAJx1enxHlQoMRf0k 9LcUtlmJXm6PucxSccYqsRi14sM8XXqF+nI3kVLTZBHvuEUkErVrzDvMqMQAZMRbdGyh aYmQ== 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 j62si48203pgd.404.2018.04.09.04.10.29; Mon, 09 Apr 2018 04:11:07 -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 S1751942AbeDILHH (ORCPT + 99 others); Mon, 9 Apr 2018 07:07:07 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:45574 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751820AbeDILHF (ORCPT ); Mon, 9 Apr 2018 07:07:05 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w39B5adE128505 for ; Mon, 9 Apr 2018 07:07:05 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2h83ek9pqx-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Mon, 09 Apr 2018 07:07:04 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 9 Apr 2018 12:07:02 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 9 Apr 2018 12:06:58 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w39B6vYp58130594; Mon, 9 Apr 2018 11:06:57 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9085211C04C; Mon, 9 Apr 2018 11:59:05 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4519A11C04A; Mon, 9 Apr 2018 11:59:03 +0100 (BST) Received: from bangoria.in.ibm.com (unknown [9.124.31.66]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 9 Apr 2018 11:59:03 +0100 (BST) From: Ravi Bangoria To: acme@redhat.com Cc: 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, jolsa@redhat.com, namhyung@kernel.org, uneedsihyeon@gmail.com, kjlx@templeofstupid.com, Ravi Bangoria Subject: [PATCH 3/3] perf/buildid-cache: Support --purge-all option Date: Mon, 9 Apr 2018 16:36:33 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180409110633.20767-1-ravi.bangoria@linux.vnet.ibm.com> References: <20180409110633.20767-1-ravi.bangoria@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18040911-0040-0000-0000-0000044B4FCA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18040911-0041-0000-0000-000020EF7379 Message-Id: <20180409110633.20767-4-ravi.bangoria@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-09_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 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-1804090121 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 /tmp/a.out (8a86ef73e44067bca52cc3f6cd3e5446c783391c) /tmp/a.out.1 (ebe71fdcf4b366518cc154d570a33cd461a51c36) # 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 50db05bd0cc6..3b4373cabd49 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]; @@ -326,6 +354,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, @@ -349,6 +378,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"), @@ -369,7 +399,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); @@ -455,6 +486,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