Received: by 10.223.185.116 with SMTP id b49csp3850263wrg; Tue, 6 Mar 2018 06:06:56 -0800 (PST) X-Google-Smtp-Source: AG47ELsHkLiQd9OkaqVbq46TrsPuscF0Pnvili3vV5xLVSiDfCtrRjsnBu37T9c7FKNi8Iql6JeY X-Received: by 10.101.68.82 with SMTP id e18mr15135339pgq.329.1520345216562; Tue, 06 Mar 2018 06:06:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520345216; cv=none; d=google.com; s=arc-20160816; b=0laZoIlX/fGl5kI9yvvZiQYZCMrBcIHPI7f1ecY+JOz4XEhzf1Wh0uE56NKv3sRdYj ccH0L9WBaQqg8RXiEgp8d6Rl7wQhyyQy0gsn7vrKs8+QHuKCr4rIY3C07vzmCMRwJwpA vG+cJIEYGrVDlrujWfHcfnCFOGfjz9TO/FDnJ0gkhN+jh9foj0ifm46pTg4Et2D7EPfa m/MHzW7rW3Cx6bkUba4nRpj80/Es+EvcfLK/nci8cV3MvTfH7LhV18DaZODm4JbdDlEw oDRSbn444Xv98VFZhNqiHvB0a9xDMAdscfiSTyKBlVlUJuZ0IHilmYmCzMwVLNULPnjV MOag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=gn01t0b6Sa0Gx2w75eEhwKZl1Qa2syJwcOewUOyTm6E=; b=FRfC8zYSfwbwAfEVJZZWJCnaS3gA7AixOSe0EsPVNyj/GaevCiAJdAqTdqvrT024+b QZHgYeq+M89pb+0Z8xSigRtPuZv/JU/qR/mWNSqWBZbgyX4ceR4YZrqKvPXLOANVIHkz 2jfd9tDwOW6qULIIOkhB8+LuuBp4wFl9Hnfh2+HEzXV0O5yh2a64wvLIkSic+rxdu2bZ lDTFIyk6xToZrxgw4GC8yRYdBVD0l5Koo5UJZuyNXCUo+ZSRvNwKSWRT+DKDgDhYS/7T ICi4+EkO18GbxEy6RBkRVlYeWmA0DkpNG+zhV7o/PBLFJLkNlabdNOtx7+OcSIn1ErO4 l7sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=a+2bMw7U; dkim=pass header.i=@codeaurora.org header.s=default header.b=W5c13M6W; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n7si2710469pgv.831.2018.03.06.06.06.41; Tue, 06 Mar 2018 06:06:56 -0800 (PST) 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; dkim=pass header.i=@codeaurora.org header.s=default header.b=a+2bMw7U; dkim=pass header.i=@codeaurora.org header.s=default header.b=W5c13M6W; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932926AbeCFOFN (ORCPT + 99 others); Tue, 6 Mar 2018 09:05:13 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:52652 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932533AbeCFOFJ (ORCPT ); Tue, 6 Mar 2018 09:05:09 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id BAD5660A05; Tue, 6 Mar 2018 14:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520345108; bh=o+NNB97U3Mu/wSfiM6ROjRPzm9Dny6HeWUhsmNdj3kM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a+2bMw7UoGCkmIzZUiRs4vYyPLpDWm/H+BAImD1TWd3UbbmEri0OiIVG7cH2hPfWh OseRlLy0j920UYF/GfjSkrt8xBN0/7h6SPcJe+cgthHKWsKNHVsjXrOceFs4sleRea DLw8Mo4au7QRi5u6W61P7fl5zFdM0AQb/LSDPvhA= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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 D787960817; Tue, 6 Mar 2018 14:05:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520345107; bh=o+NNB97U3Mu/wSfiM6ROjRPzm9Dny6HeWUhsmNdj3kM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W5c13M6W/6c2lD3Fh4wEiLTrtYVMYQfALLFSad1mNC0ifxcxKg5AwBi1pQZPNp42/ SJq4klosGBFIYXY6EH3IiO+Vv5fwpxB/n6G9AK9XfrQlYXEH4sJay03oQLdRI2UsYN nEXeNHFMTdwI7W1G2opr+e39IP0JLBsjxBC+UJyo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D787960817 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 Cc: timur@codeaurora.org, agustinv@codeaurora.org Subject: [RFC V3 3/3] perf pmu: Auto-merge PMU events created by prefix or glob match Date: Tue, 6 Mar 2018 09:04:44 -0500 Message-Id: <1520345084-42646-4-git-send-email-agustinv@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520345084-42646-1-git-send-email-agustinv@codeaurora.org> References: <1520345084-42646-1-git-send-email-agustinv@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Change-Id: I0a47eed54c05e1982ca964d743b37f50f60c508c 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(-) diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt index 5ee954f..e9d671a 100644 --- a/tools/perf/Documentation/perf-stat.txt +++ b/tools/perf/Documentation/perf-stat.txt @@ -253,11 +253,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 316ac07..0c8db46 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; @@ -246,7 +246,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); } -- 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.