Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1315106rdg; Fri, 13 Oct 2023 18:52:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQT8O6fYlOnBWByCRy/dibiBgyKHqEry8uTvWUxKspfh5Yj6D3h32RHVeUU97o0+smZorD X-Received: by 2002:a17:903:2301:b0:1ca:119f:2686 with SMTP id d1-20020a170903230100b001ca119f2686mr2666431plh.16.1697248366374; Fri, 13 Oct 2023 18:52:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697248366; cv=none; d=google.com; s=arc-20160816; b=gMLtA6nZ5+V8rcjSqc0rTKqczJ4K/eCp889iBonbK1tDci6jtPeamSeftOCwVLnvHE I3c4kBpTGEuexwL01GoO0PjXWtv9i3TO16iy7FTM+YVDp0zwpfOJ6gUazNcE7uHwmAmL OS+7TPFtjt/vrGG/s9Cz2HPaRXoUCFbX25sAza9+oLtF5hPDQ3a50IM18qRlwTO4dGk4 zDdz+TGVm4kkyCjieqqoFGlz8bJGStgSTvhrY2vD89V0bBl6sOvI/rMwcCq1fPv86aJe UZTRnkViuz7r2rzuG9RKsC5farf5F7kE/fPeB3C/Cg90io0reWC7DLpoLaWJxHiulSYN 2KMg== 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=/u4Z4HFLaYc15qKZPB60DYTWm579olO/q3Ai1mEDSds=; fh=fjecWn2tsXHKF5pPtw+gI2dQE/iSXdFsWSc8KUP/zmc=; b=JghG/66M7aPmVj6Y13Y+w+JzXlWfYFAS754HzqauhxgXXDy6QwAk01Ylq9qfcJWwFG bT2wxs39sECNtB79R54MrU08oaB7dXUMBnVxgWJGvOYR7N8F4k+qiOi0endvVqMyjFmk Rpo/wO0EXzd2GCq/+v80qpqwQNJ56siWaOPboQ7C1q2OdxS5ifmd36YQOeWHWxVg6g3h u0M5aFaPqF6nDbkFpdctsX/AmqZZDFNjhC2yF+vQpdR/Dy5EHBv8q0uCtpDBn/me6n60 AYEbAw41dKn/ZdAxmNDNxziVHkq057zrUA/i7mZZnu3hDhVylUiX283nbIPO+AB/aqC5 ve6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EluK0MZ+; 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 k20-20020a635a54000000b0057808a9b0besi5563365pgm.664.2023.10.13.18.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 18:52:46 -0700 (PDT) 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=EluK0MZ+; 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 D58F48350FD3; Fri, 13 Oct 2023 18:52:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232710AbjJNBwZ (ORCPT + 99 others); Fri, 13 Oct 2023 21:52:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232592AbjJNBwV (ORCPT ); Fri, 13 Oct 2023 21:52:21 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16797C2; Fri, 13 Oct 2023 18:52:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697248339; x=1728784339; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7XqP6SyggdnemV9DhcZdlkFXAm0Nusd1RKnygUt9iRQ=; b=EluK0MZ++iay80xRTm81wo+yi1WJkpSVwbrFNw81tDT/XPbdqBR8pOAV kx8L1c1Q6ErEtFem3594iKlTytGC/oUFr6Uk5lphbpnaq/aGae5SfsgpZ ksS3/VwC5AIAnV3hADrLcqKGdz/leEISyCjOQe5mjt7KJKiCbWjDy5qPq weoXqIVWZVl56NnPJT/P00dyOt7KchZlDIS0lvrnsCUjJ1JMgO+wZNnkD Q+3CxIg4BXev1JV1V5KyZ+RpokVaFYJN7s3iOs3OTwol/OL4JIPijGixw TDBUEWPlEjtZAfp0P6O3BJwGhSa3s7WxOpID13XHI28ZNuG9a9n8llSVD Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10862"; a="389154670" X-IronPort-AV: E=Sophos;i="6.03,223,1694761200"; d="scan'208";a="389154670" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2023 18:52:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10862"; a="731565654" X-IronPort-AV: E=Sophos;i="6.03,223,1694761200"; d="scan'208";a="731565654" Received: from b49691a75598.jf.intel.com ([10.54.34.22]) by orsmga006.jf.intel.com with ESMTP; 13 Oct 2023 18:52:15 -0700 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 v2 01/17] perf stat: Add hardware-grouping cmd option to perf stat Date: Fri, 13 Oct 2023 18:51:46 -0700 Message-Id: <20231014015202.1175377-2-weilin.wang@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231014015202.1175377-1-weilin.wang@intel.com> References: <20231014015202.1175377-1-weilin.wang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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]); Fri, 13 Oct 2023 18:52:45 -0700 (PDT) From: Weilin Wang Hardware counter and event information could be used to help creating event groups that better utilize hardware counters and improve multiplexing. Add a cmd option to allow user to choose this new metric grouping method. $ perf stat -M TopdownL1 -a --hardware-grouping Signed-off-by: Weilin Wang --- tools/perf/builtin-stat.c | 7 +++++++ tools/perf/util/metricgroup.c | 5 +++++ tools/perf/util/metricgroup.h | 1 + tools/perf/util/stat.h | 1 + 4 files changed, 14 insertions(+) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 07b48f6df..1a7dbfff5 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -1256,6 +1256,8 @@ static struct option stat_options[] = { "don't try to share events between metrics in a group"), OPT_BOOLEAN(0, "metric-no-threshold", &stat_config.metric_no_threshold, "don't try to share events between metrics in a group "), + OPT_BOOLEAN(0, "hardware-grouping", &stat_config.hardware_aware_grouping, + "Use hardware aware metric grouping method"), OPT_BOOLEAN(0, "topdown", &topdown_run, "measure top-down statistics"), OPT_UINTEGER(0, "td-level", &stat_config.topdown_level, @@ -2061,6 +2063,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 +2097,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 +2132,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 +2174,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; @@ -2702,6 +2708,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 6231044a4..b08af6860 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 d5325c6ec..779f6ede1 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 325d0fad1..f97d6282b 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