Received: by 10.223.185.116 with SMTP id b49csp304695wrg; Fri, 2 Mar 2018 19:49:27 -0800 (PST) X-Google-Smtp-Source: AG47ELv1hksSGmA9y9GZdB99f1XRsci2y5A6q41NMHAD6FSe6AQSdSBF6lDzuvULIMw1IyuORzZp X-Received: by 10.99.122.74 with SMTP id j10mr6068568pgn.84.1520048967382; Fri, 02 Mar 2018 19:49:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520048967; cv=none; d=google.com; s=arc-20160816; b=ktMSoFqhY6E+m24liyVji2Qd7CbOKw0FEAsgA27BntfA+nQU6G5u3xCW74LX2dHtec ++FN8YMaa9cQIgXd9Mg9WzxzkXm1883K5tWVBydF2BajUux9CBpDsRlfwMaGxrwun8LJ b7QbHPbZ+B5jgQ6Rc7AcbEpJuCL837VX80YQjvcKflrFOzZprUj6nbkN207BUbK4oGxx V78Q1OZF5EaBEnzsaksSMUOhBVV/JKJhxQUb+xsPGcikoAgv6PDDYjejCDW+WJ+sHe+S q/nBHwmOUb1P8e9PP4yMG/WOrXRI8/3hJwmZXJfQtJkul87hw5QnmLQV/yv9WKxoJRJX CEug== 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=MBPKCOXypl9/59WuIIrTMciLGUgB1koNIL8u3hwWMdE=; b=FTsV37NqsUwVpvWTs2VuqL2LrYJEytfvCv5tZcBtrS84xxMI+QTn3D4iWBqj9eFXmE FE0GSeOU2iHINPoyjvulLeHlJbZCgmpJzPDHSets4MLrknm+xWSopONwUwgHL+ilmY4T BGwIkKMNbISwLcPYPnpuxbjRV3GlXWuzBgfilM0JhKvxB5EninuH3iPqKtyDbnLoyabc 8g7YF8tS6kL1Sn/eIUftacpMMbCX1VVnFo+Y3Cva/2kbMMoM0x3QxWLe5I4pAX4IwghV d9CFeR9Jvl0gYr2KFM08TzZoVdZRH75HlgYnIN867yGjGPUyjkHoem0JWnlmODtb1t5G B9Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=EJ6OlZ6x; dkim=pass header.i=@codeaurora.org header.s=default header.b=OatACMzj; 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 o11-v6si5858004pll.158.2018.03.02.19.49.13; Fri, 02 Mar 2018 19:49:27 -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=EJ6OlZ6x; dkim=pass header.i=@codeaurora.org header.s=default header.b=OatACMzj; 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 S934879AbeCBXmh (ORCPT + 99 others); Fri, 2 Mar 2018 18:42:37 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:48802 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934790AbeCBXly (ORCPT ); Fri, 2 Mar 2018 18:41:54 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7687C60848; Fri, 2 Mar 2018 23:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520034114; bh=eNbYDGvyN0TEDIXL1lbuAROVqQ2pVqKw5ixRzHyS+Qg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EJ6OlZ6xmOPs9g02YxQjaV2GBbYltmZaokHMD9SYnY7QI+c3YvuLxutNDZQEsxgSs flufyf5ahedBK9tdMs9yfIKpANm0VLokNWDym4t5eBkDYJNlpPQQw52HJU2ymEz5jP 2t7fdoMWqeYe6sLYTSQ880OumGLGeuRvUiGlvifE= 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 DE2976076C; Fri, 2 Mar 2018 23:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520034113; bh=eNbYDGvyN0TEDIXL1lbuAROVqQ2pVqKw5ixRzHyS+Qg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OatACMzjbtHiiKCm8fYWoXgH5fq9duPOgtWH3Ieq12XcWIshFdcCSxtsNX3iidQ1m UOBV3SCcbDucCLOnTu2DLzJ3MmfB9h7v+Vod96DDtsYaz2iA0qUOX4felg0B5OEcn9 0d/DlWndxNFSqtoK9VQa+4I6jGwY1aZmQqfpSKgo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org DE2976076C 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 V2 1/3] perf, tools: Support wildcards on pmu name in dynamic pmu events Date: Fri, 2 Mar 2018 18:41:30 -0500 Message-Id: <1520034092-35275-2-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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Starting on v4.12 event parsing code for dynamic pmu events already supports prefix-based matching of multiple pmus when creating dynamic events. E.g., in a system with the following dynamic pmus: mypmu_0 mypmu_1 mypmu_2 mypmu_4 passing mypmu// as an event spec will result in the creation of the event in all of the pmus. This change expands this matching through the use of fnmatch so glob-like expressions can be used to create events in multiple pmus. E.g., in the system described above if a user only wants to create the event in mypmu_0 and mypmu_1, mypmu_[01]// can be passed. Signed-off-by: Agustin Vega-Frias --- tools/perf/Documentation/perf-list.txt | 8 +++++++- tools/perf/Documentation/perf-stat.txt | 12 ++++++++++++ tools/perf/util/parse-events.l | 2 +- tools/perf/util/parse-events.y | 3 ++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/tools/perf/Documentation/perf-list.txt b/tools/perf/Documentation/perf-list.txt index e2a897a..2549c34 100644 --- a/tools/perf/Documentation/perf-list.txt +++ b/tools/perf/Documentation/perf-list.txt @@ -141,7 +141,13 @@ on the first memory controller on socket 0 of a Intel Xeon system Each memory controller has its own PMU. Measuring the complete system bandwidth would require specifying all imc PMUs (see perf list output), -and adding the values together. +and adding the values together. To simplify creation of multiple events, +prefix and glob matching is supported in the PMU name, and the prefix +'uncore_' is also ignored when performing the match. So the command above +can be expanded to all memory controllers by using the syntaxes: + + perf stat -C 0 -a imc/cas_count_read/,imc/cas_count_write/ -I 1000 ... + perf stat -C 0 -a *imc*/cas_count_read/,*imc*/cas_count_write/ -I 1000 ... This example measures the combined core power every second diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt index 823fce7..49983a7 100644 --- a/tools/perf/Documentation/perf-stat.txt +++ b/tools/perf/Documentation/perf-stat.txt @@ -49,6 +49,12 @@ report:: parameters are defined by corresponding entries in /sys/bus/event_source/devices//format/* + Note that the last two syntaxes support prefix and glob matching in + the PMU name to simplify creation of events accross multiple instances + of the same type of PMU (e.g. memory controller PMU) in large systems. + Multiple PMU instances are typical for uncore PMUs, so the prefix + 'uncore_' is also ignored when performing this match. + -i:: --no-inherit:: child tasks do not inherit counters @@ -246,6 +252,12 @@ 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. + --smi-cost:: Measure SMI cost if msr/aperf/ and msr/smi/ events are supported. diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index 655ecff..a1a01b1 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l @@ -175,7 +175,7 @@ bpf_source [^,{}]+\.c[a-zA-Z0-9._]* num_dec [0-9]+ num_hex 0x[a-fA-F0-9]+ num_raw_hex [a-fA-F0-9]+ -name [a-zA-Z_*?][a-zA-Z0-9_*?.]* +name [a-zA-Z_*?\[\]][a-zA-Z0-9_*?.\[\]]* name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.:]* drv_cfg_term [a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*?\.:]+)? /* If you add a modifier you need to update check_modifier() */ diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index e81a20e..c528469 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -8,6 +8,7 @@ #define YYDEBUG 1 +#include #include #include #include @@ -241,7 +242,7 @@ PE_NAME opt_event_config if (!strncmp(name, "uncore_", 7) && strncmp($1, "uncore_", 7)) name += 7; - if (!strncmp($1, name, strlen($1))) { + 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)) -- 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.