From patchwork Thu Mar 8 19:49:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 10269027 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 D0E2C60594 for ; Thu, 8 Mar 2018 19:53:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C03F929945 for ; Thu, 8 Mar 2018 19:53:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4AAD29950; Thu, 8 Mar 2018 19:53:10 +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=ham 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 05CC129949 for ; Thu, 8 Mar 2018 19:53:10 +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=B3rHfdiqQgspvxQIivgsfJyudUhotEhDp+X9/JmQKYw=; b=TttikVat1oQLnXVs99E3t413uo d7Vkx68Gu/231HJKu44/g9wPpi/ZsZkaeHmrZkxR5pS28RUfoXj8LziJH/cGKHwM23YljeEKMWxvo IxnkEW3m+wAED6R7plaOlgdlXA9H3sW2xBN1JUTYY0+vzp+jZBBvuSez0fhwsSJlsH2TNhPtg9nrm hIO+NuD4/eiW4El6Z0SFedxC8QyxfesD9KRGAyAIeFFP0dkpCTF+GYfGfDNBnLwv5cKV29zV4pLim fCJofqMe6F/v44ElslX2Q+HFWJUUY7lzuCXvo7uOz1xJDTyZk/AbAdLXYB/ACA4gQoF8+cIhRg3Fw Ja5RbGYw==; 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 1eu1b2-0002sg-Ah; Thu, 08 Mar 2018 19:53:00 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eu1Zo-0002BP-Gi for linux-arm-kernel@lists.infradead.org; Thu, 08 Mar 2018 19:51:55 +0000 Received: from jouet.infradead.org (unknown [190.15.121.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6AB552177C; Thu, 8 Mar 2018 19:51:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6AB552177C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=acme@kernel.org From: Arnaldo Carvalho de Melo To: Ingo Molnar Subject: [PATCH 21/54] perf pmu: Auto-merge PMU events created by prefix or glob match Date: Thu, 8 Mar 2018 16:49:56 -0300 Message-Id: <20180308195029.14991-22-acme@kernel.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180308195029.14991-1-acme@kernel.org> References: <20180308195029.14991-1-acme@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180308_115144_974878_6D49C228 X-CRM114-Status: GOOD ( 13.19 ) 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: Arnaldo Carvalho de Melo , Alexander Shishkin , Timur Tabi , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Peter Zijlstra , Namhyung Kim , linux-arm-kernel@lists.infradead.org, Agustin Vega-Frias 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 From: Agustin Vega-Frias 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 Acked-by: Andi Kleen Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Timur Tabi Cc: linux-arm-kernel@lists.infradead.org Change-Id: I0a47eed54c05e1982ca964d743b37f50f60c508c Link: http://lkml.kernel.org/r/1520345084-42646-4-git-send-email-agustinv@codeaurora.org Signed-off-by: Arnaldo Carvalho de Melo --- 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(-) diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt index 628026dbedc5..f15b306be183 100644 --- a/tools/perf/Documentation/perf-stat.txt +++ b/tools/perf/Documentation/perf-stat.txt @@ -267,11 +267,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 bafc91edcb44..4e80ca320399 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 88108cd11b4c..5015cfd58277 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 dedf184b5bed..7afeb80cc39e 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; char *pattern; @@ -251,7 +251,7 @@ PE_NAME opt_event_config free(pattern); 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); }