From patchwork Fri Mar 2 23:41:30 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: 10255851 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 004AF60211 for ; Fri, 2 Mar 2018 23:42:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2B002675C for ; Fri, 2 Mar 2018 23:42:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D706A27E5A; Fri, 2 Mar 2018 23:42:45 +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 506DA2675C for ; Fri, 2 Mar 2018 23:42:45 +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=C5+RFSlznI9TSJaxIO+HmQ4Z70HblHiB1+zvkcyxGyc=; b=md4bg2MHzpqidJO9hqtvQZy5Ia 822fVKCHiy0RPQ0Uqnjq96bvU7+qEVenxcHeHSAKYdcbcZvJUuGfMsuFs9gLWeCM3opIAQSbVFt2I qRwCA6ZJ1izq9nHMlBoIKG9y0DeKYhPy373j72LA280vbx5qscylvAsft61Ik7ShRuBFTfV9roy8o DAu91NSUttaT6K5bYXcI/GpHNWcS66k9cNhQf2FirHq+4+Oes+51/+gRn316jjlrZSOqPKTnH2Mnk RQ/E+/CtlZLeC58pNL34UTXmUsqZkOmp+TW9plGd4pI791WFsB4Cexzng6plg8e6mhoYleJyPj5G9 U2BKA/Lg==; 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 1eruJw-0004tl-7q; Fri, 02 Mar 2018 23:42:36 +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-0004c5-6m for linux-arm-kernel@lists.infradead.org; Fri, 02 Mar 2018 23:42:06 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id EBDD960791; 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= 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180302_154204_417812_CF04A450 X-CRM114-Status: GOOD ( 16.57 ) 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 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(-) -- 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-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))