From patchwork Fri Mar 2 23:41:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Agustin Vega-Frias X-Patchwork-Id: 10255853 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2B06A60211 for ; Fri, 2 Mar 2018 23:43:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19C56285E4 for ; Fri, 2 Mar 2018 23:43:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E173285F2; Fri, 2 Mar 2018 23:43:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 88FC5285E4 for ; Fri, 2 Mar 2018 23:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=t8QCA6LDp55iwPj+Fq+Wq4k9t3d5pUo+chcM/xXkqew=; b=qrfFOQ8N+odCnAr+Jlz0JUyQ94 uLub6qcpYkxjcfVNvXT3O2CWbRl1p2OWRW6Eq+J1mdKjaUd3m9nFuAq/PtTMij3C5VHYoyK2OFp/o 4XxIqJkEG8LHcpF3BbYfwudopV6Bzq/JY+mln6pkY6F0FJ0HfUobke3LbC3sHRdI9mxoz8EdZDzCd RimLFis+cfgnWI/JeGhfA+zgTxuV2glh8+r1j3cE3unH3yFHq5WIsE1kgP3QsfhqETAV47dSP/hXw v3BDHXNP9u5YjCd/rAl7T3yIjn0WeIeZh87lKF4Rk1BxMKXnSiNed74NzvA6bl+VUFPeMabSd1Hv9 oDQU5FdQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eruKS-0005DQ-8o; Fri, 02 Mar 2018 23:43:08 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eruJQ-0004c9-65 for linux-arm-kernel@lists.infradead.org; Fri, 02 Mar 2018 23:42:08 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C0AE7600E6; Fri, 2 Mar 2018 23:41:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520034117; bh=/QAdiDq6tzYIjeUdRK0vwDHGdvYo7t2ZFJNok/vnlA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m6KPhQ4mX9JpgIjjJF1YrJeKHVpokFPMnI6k6Lzzfcx4nZYnRlWvzBtLWKdm0p9a2 9iqTkumCo2t5UraXYE7LptQL+AbbUoS3BvHvJS4vA5fTX++aHBOM8/vLTehN8V+YFi cSTigQR+6YFUJ5mJ+8Dbu+vat/tk+IesrJhfesX4= Received: from ral-tools-sdp4.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: agustinv@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 80A4E6076C; Fri, 2 Mar 2018 23:41:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520034116; bh=/QAdiDq6tzYIjeUdRK0vwDHGdvYo7t2ZFJNok/vnlA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W8VP4kAIIbDLTig4GLR04BPvigcCByTXKytMhwT7A67TStYumvYaIyacJjcbxmTrG +BrzLUzFa6P2h6Cc9ChAOd1l7g1V4O25vgqidifR8hdGeZLKU/YZ2cFSKwu3MgmEvs sCgEooM4D/eBQA2fxU0ra6OW6HLVLgxAhOgxc7JM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 80A4E6076C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=agustinv@codeaurora.org From: Agustin Vega-Frias To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Andi Kleen , Alexander Shishkin , Jiri Olsa , Namhyung Kim Subject: [RFC V2 3/3] perf pmu: Auto-merge PMU events created by prefix or glob match Date: Fri, 2 Mar 2018 18:41:32 -0500 Message-Id: <1520034092-35275-4-git-send-email-agustinv@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520034092-35275-1-git-send-email-agustinv@codeaurora.org> References: <1520034092-35275-1-git-send-email-agustinv@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180302_154204_437464_4C6FA4A0 X-CRM114-Status: GOOD ( 13.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: timur@codeaurora.org, agustinv@codeaurora.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Auto-merge for these events was disabled when auto-merging of non-alias events was disabled in commit 63ce844 (perf stat: Only auto-merge events that are PMU aliases). Non-merging of legacy events is preserved: $ ./perf stat -ag -e cache-misses,cache-misses sleep 1 Performance counter stats for 'system wide': 86,323 cache-misses 86,323 cache-misses 1.002623307 seconds time elapsed But prefix or glob matching auto-merges the events created: $ ./perf stat -a -e l3cache/read-miss/ sleep 1 Performance counter stats for 'system wide': 328 l3cache/read-miss/ 1.002627008 seconds time elapsed $ ./perf stat -a -e l3cache_0_[01]/read-miss/ sleep 1 Performance counter stats for 'system wide': 172 l3cache/read-miss/ 1.002627008 seconds time elapsed As with events created with aliases, auto-merging can be suppressed with the --no-merge option: $ ./perf stat -a -e l3cache/read-miss/ --no-merge sleep 1 Performance counter stats for 'system wide': 67 l3cache/read-miss/ 67 l3cache/read-miss/ 63 l3cache/read-miss/ 60 l3cache/read-miss/ 1.002622192 seconds time elapsed Signed-off-by: Agustin Vega-Frias --- tools/perf/Documentation/perf-stat.txt | 14 +++++++++----- tools/perf/util/parse-events.c | 13 +++---------- tools/perf/util/parse-events.h | 2 +- tools/perf/util/parse-events.y | 4 ++-- 4 files changed, 15 insertions(+), 18 deletions(-) -- Qualcomm Datacenter Technologies, Inc. on behalf of the Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project. diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt index 49983a7..ae406f7 100644 --- a/tools/perf/Documentation/perf-stat.txt +++ b/tools/perf/Documentation/perf-stat.txt @@ -252,11 +252,15 @@ taskset. --no-merge:: Do not merge results from same PMUs. -When multiple events are created from a single event alias, stat will, -by default, aggregate the event counts and show the result in a single -row. This option disables that behavior and shows the individual events -and counts. Aliases are listed immediately after the Kernel PMU events -by perf list. +When multiple events are created from a single event specification, +stat will, by default, aggregate the event counts and show the result +in a single row. This option disables that behavior and shows +the individual events and counts. + +Multiple events are created from a single event specification when: +1. Prefix or glob matching is used for the PMU name. +2. Aliases, which are listed immediately after the Kernel PMU events + by perf list, are used. --smi-cost:: Measure SMI cost if msr/aperf/ and msr/smi/ events are supported. diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index bafc91e..4e80ca3 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1217,7 +1217,7 @@ int parse_events_add_numeric(struct parse_events_state *parse_state, get_config_name(head_config), &config_terms); } -static int __parse_events_add_pmu(struct parse_events_state *parse_state, +int parse_events_add_pmu(struct parse_events_state *parse_state, struct list_head *list, char *name, struct list_head *head_config, bool auto_merge_stats) { @@ -1287,13 +1287,6 @@ static int __parse_events_add_pmu(struct parse_events_state *parse_state, return evsel ? 0 : -ENOMEM; } -int parse_events_add_pmu(struct parse_events_state *parse_state, - struct list_head *list, char *name, - struct list_head *head_config) -{ - return __parse_events_add_pmu(parse_state, list, name, head_config, false); -} - int parse_events_multi_pmu_add(struct parse_events_state *parse_state, char *str, struct list_head **listp) { @@ -1323,8 +1316,8 @@ int parse_events_multi_pmu_add(struct parse_events_state *parse_state, return -1; list_add_tail(&term->list, head); - if (!__parse_events_add_pmu(parse_state, list, - pmu->name, head, true)) { + if (!parse_events_add_pmu(parse_state, list, + pmu->name, head, true)) { pr_debug("%s -> %s/%s/\n", str, pmu->name, alias->str); ok++; diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index 88108cd..5015cfd 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -167,7 +167,7 @@ int parse_events_add_breakpoint(struct list_head *list, int *idx, void *ptr, char *type, u64 len); int parse_events_add_pmu(struct parse_events_state *parse_state, struct list_head *list, char *name, - struct list_head *head_config); + struct list_head *head_config, bool auto_merge_stats); int parse_events_multi_pmu_add(struct parse_events_state *parse_state, char *str, diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index c528469..b51278f 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -232,7 +232,7 @@ PE_NAME opt_event_config YYABORT; ALLOC_LIST(list); - if (parse_events_add_pmu(_parse_state, list, $1, $2)) { + if (parse_events_add_pmu(_parse_state, list, $1, $2, false)) { struct perf_pmu *pmu = NULL; int ok = 0; @@ -245,7 +245,7 @@ PE_NAME opt_event_config if (!strncmp($1, name, strlen($1)) || !fnmatch($1, name, 0)) { if (parse_events_copy_term_list(orig_terms, &terms)) YYABORT; - if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms)) + if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms, true)) ok++; parse_events_terms__delete(terms); }