Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4968291rdb; Tue, 12 Dec 2023 15:02:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFB9e19Clb4uifuj8rMF0decx+d/QQI3uGXljdA9JW1oLKLMQQq3vOLIx6HhP4RVAsAy0Pb X-Received: by 2002:a05:6a00:1a8f:b0:693:3d55:2bb3 with SMTP id e15-20020a056a001a8f00b006933d552bb3mr5185828pfv.26.1702422174766; Tue, 12 Dec 2023 15:02:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702422174; cv=none; d=google.com; s=arc-20160816; b=bHkIdsJ8Yo6xng/4aBG21UC0nSNRNSWdrwwlXr16hUActCPqcx24PN7hO0CqRhIlH3 VwMRYXMlcnBnimO+L+5FY6Dm995giSn03dM9OtXqPPBM1pLimzeu4ZuFqDES/sXojIyA hP3G2XgOyOdZdLvt8Q+J4v3rdc/+Gcdwy2yvDdIifmJ8W+BrA1gbgolPn1gCz92Sq/AR n4ntW6kIlNJ4fJ5TV/nYlUYQ8ROS62RCBDZzpUKUUwLSAaz+GAmbH9LNErQDwLYI9xru oHwjE7HHbZinzadJxcFftfrPA+m+hejXV9LxDCpeIXKgnVlA8yNxpDtpzBfiSYGE8f1f OSjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qIlswBWNOCKtmRcS7pVIKp+ruzBRyOtChBEO8quDCDE=; fh=fjecWn2tsXHKF5pPtw+gI2dQE/iSXdFsWSc8KUP/zmc=; b=KfFBzqYwGJNYmPhBr/GfHo8LGzU4OSA5cp4ZxQE9tM+md+6UGsLFrjscSx7GaBgsne BT4pDbIHXmom5vrnWz1PuwSfD6a78kwPakjrebkXMkAq4h5zENsQAxBnTIslBPsdfRLn qUy1Y/aOfNzR8L+yw2e4dwb9G1rRGaarXsfB2xH4zwR3/QZkglX4aCoQP38wh7iogzLu uh2kdqG61MwiY1Q7pK7SKEq534p0Rle9u+cLVPt+3kcD2x6yW7J8FQwSdtY6qJ/DvMYY UkDDRj+6umfC7ELtA9r55mBgySDckW9+OHi1DBrDO9SyfCcfsK2/VThiaOY3+lj33w92 5zMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hQmXu4sy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id m12-20020a056a00080c00b006bceac424f7si8612321pfk.102.2023.12.12.15.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 15:02:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hQmXu4sy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 41D6980B2301; Tue, 12 Dec 2023 15:02:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235259AbjLLXCk (ORCPT + 99 others); Tue, 12 Dec 2023 18:02:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232365AbjLLXCg (ORCPT ); Tue, 12 Dec 2023 18:02:36 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0315EAA; Tue, 12 Dec 2023 15:02:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702422163; x=1733958163; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Mg+P2jY7Sr7zhOxLFP+JV08Ptf4BsGSYsE7b4VU9GGU=; b=hQmXu4sycG4/DtD6XGocoKYTLbgzwR/UcrC70LG3QKF6miBwon9K+iBY 2ZHWyYB6/PwOaDMfSnkVmm10+zPekQn83lTxKBCdkwesUeeWWpSm/Rugf xUqtpr9lsDjV5hriGXwjLwnAspaND5KUCb8guKDiuyxknP25JYbCjEAYy kvs3ucI6vxrGbm2sdnWb8LHBI2HD+P7/azBBJh/HAnE5RV/SygLl1lhqf YTq/2y/fQU9O+mYCFdRTskpCbkvOz8XiF8OFh/aWkb949U4O2oz1JyL7L lMxAaPVt7GdWJwVf66FxNc9Wbwehsjolr6VScLPDSCgIZ+ukPtV4kBTXG g==; X-IronPort-AV: E=McAfee;i="6600,9927,10922"; a="392055871" X-IronPort-AV: E=Sophos;i="6.04,271,1695711600"; d="scan'208";a="392055871" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2023 15:02:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10922"; a="864391944" X-IronPort-AV: E=Sophos;i="6.04,271,1695711600"; d="scan'208";a="864391944" Received: from node-10329.jf.intel.com ([10.54.34.22]) by FMSMGA003.fm.intel.com with ESMTP; 12 Dec 2023 15:02:41 -0800 From: weilin.wang@intel.com To: weilin.wang@intel.com, Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Kan Liang Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Perry Taylor , Samantha Alt , Caleb Biggers , Mark Rutland , Yang Jihong Subject: [RFC PATCH v3 01/18] perf stat: Add new field in stat_config to enable hardware aware grouping. Date: Tue, 12 Dec 2023 15:02:06 -0800 Message-Id: <20231212230224.1473300-2-weilin.wang@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231212230224.1473300-1-weilin.wang@intel.com> References: <20231212230224.1473300-1-weilin.wang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 12 Dec 2023 15:02:53 -0800 (PST) From: Weilin Wang Hardware counter and event information could be used to help creating event groups that better utilize hardware counters and improve multiplexing. Signed-off-by: Weilin Wang --- tools/perf/builtin-stat.c | 8 ++++++++ tools/perf/util/metricgroup.c | 5 +++++ tools/perf/util/metricgroup.h | 1 + tools/perf/util/stat.h | 1 + 4 files changed, 15 insertions(+) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index d8e5d6f7a87a..a7a8018c3511 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2061,6 +2061,7 @@ static int add_default_attributes(void) stat_config.metric_no_threshold, stat_config.user_requested_cpu_list, stat_config.system_wide, + stat_config.hardware_aware_grouping, &stat_config.metric_events); } @@ -2094,6 +2095,7 @@ static int add_default_attributes(void) stat_config.metric_no_threshold, stat_config.user_requested_cpu_list, stat_config.system_wide, + stat_config.hardware_aware_grouping, &stat_config.metric_events); } @@ -2128,6 +2130,7 @@ static int add_default_attributes(void) /*metric_no_threshold=*/true, stat_config.user_requested_cpu_list, stat_config.system_wide, + stat_config.hardware_aware_grouping, &stat_config.metric_events) < 0) return -1; } @@ -2169,6 +2172,7 @@ static int add_default_attributes(void) /*metric_no_threshold=*/true, stat_config.user_requested_cpu_list, stat_config.system_wide, + stat_config.hardware_aware_grouping, &stat_config.metric_events) < 0) return -1; @@ -2502,6 +2506,9 @@ int cmd_stat(int argc, const char **argv) (const char **) stat_usage, PARSE_OPT_STOP_AT_NON_OPTION); + /* Set hardware_aware_grouping to false on default before completely enable it.*/ + stat_config.hardware_aware_grouping = false; + if (stat_config.csv_sep) { stat_config.csv_output = true; if (!strcmp(stat_config.csv_sep, "\\t")) @@ -2702,6 +2709,7 @@ int cmd_stat(int argc, const char **argv) stat_config.metric_no_threshold, stat_config.user_requested_cpu_list, stat_config.system_wide, + stat_config.hardware_aware_grouping, &stat_config.metric_events); zfree(&metrics); } diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 0484736d9fe4..dfbcdb517b78 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -1690,12 +1690,17 @@ int metricgroup__parse_groups(struct evlist *perf_evlist, bool metric_no_threshold, const char *user_requested_cpu_list, bool system_wide, + bool hardware_aware_grouping, struct rblist *metric_events) { const struct pmu_metrics_table *table = pmu_metrics_table__find(); if (!table) return -EINVAL; + if (hardware_aware_grouping) { + pr_debug("Use hardware aware grouping instead of traditional metric grouping method\n"); + } + return parse_groups(perf_evlist, pmu, str, metric_no_group, metric_no_merge, metric_no_threshold, user_requested_cpu_list, system_wide, diff --git a/tools/perf/util/metricgroup.h b/tools/perf/util/metricgroup.h index d5325c6ec8e1..779f6ede1b51 100644 --- a/tools/perf/util/metricgroup.h +++ b/tools/perf/util/metricgroup.h @@ -77,6 +77,7 @@ int metricgroup__parse_groups(struct evlist *perf_evlist, bool metric_no_threshold, const char *user_requested_cpu_list, bool system_wide, + bool hardware_aware_grouping, struct rblist *metric_events); int metricgroup__parse_groups_test(struct evlist *evlist, const struct pmu_metrics_table *table, diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 325d0fad1842..f97d6282ba3d 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -87,6 +87,7 @@ struct perf_stat_config { bool metric_no_group; bool metric_no_merge; bool metric_no_threshold; + bool hardware_aware_grouping; bool stop_read_counter; bool iostat_run; char *user_requested_cpu_list; -- 2.39.3