Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp358546pxb; Fri, 16 Apr 2021 07:25:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6DkW52IsIGQ6oXrrQk77JfC0l3z42SplyoqBkhEtvGlrON8B34LKi55lJ4s57zXrsbOsh X-Received: by 2002:a17:906:3e54:: with SMTP id t20mr8581701eji.53.1618583145963; Fri, 16 Apr 2021 07:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618583145; cv=none; d=google.com; s=arc-20160816; b=EwpoVe+hzTEBv0b99yPPSbgAbvqXJhce7HLEDLjlv2ZxIQM3TunTccIW8aRWUuy2ms 5i7I295q5yfneSVqo7S5g/1+fptXNEXRWZX/pw5rrdgP6imsImP56yUTeIf1Z0i67Mnk 0DrkOEhXmihc55Lepaw+ls/RpOs8BTn+skcCQBL95kCel4p4OSKQQolQ2VC1JcYkEt2l /hn0cR62X+DA0SOv6/0KvetpVb4l+6aqKSoWUZdV/vjH6SAcYsdsgS0PxQPX6zOst6dW bGR/6h0r5nqvhdW/zngwh0YcSSTtZSw5rl+XOcQQ2QlziF17RDsGiaogi5R4JUXy9FsM Zf9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=VKsc1ucKurw4POCrG8CZHT1lWStP/hBM1Rj+jkG9YVw=; b=YFUZVyt35FLell9vcQnY9PB/UyZwkkGx/6mctrcrBHXbSiTnt7Rc5tOD8syrpOr8Mb Kuna5w3wUcmn7nClpMub1qkPWa0dlyq6shP+qeEzbp9a4if+OYEhZxzQO5QnbqD6IjAv dndWIT7FmPcdPq5I309wJcmqhYooI2/ximZCaI+hlsqVDFvFR8F10snU+mBfQxZ1t886 LQWIF4JX32yOM7GL8OleYovFltY6bRRX67WuqachlEtHBIaoJ7NhrVGSpcTrUhKRpdtf 2BC5OkcL/zICh7PZwmWzzG3IAEpOZYEqN1wta5UA5Dr+kwWDlOjAkJQUsdVQOjCxb97w JOHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g18si4763244ejt.696.2021.04.16.07.25.22; Fri, 16 Apr 2021 07:25:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244285AbhDPOIH (ORCPT + 99 others); Fri, 16 Apr 2021 10:08:07 -0400 Received: from mga11.intel.com ([192.55.52.93]:23099 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236348AbhDPOHZ (ORCPT ); Fri, 16 Apr 2021 10:07:25 -0400 IronPort-SDR: 0fOZMKzbKiOe7NkxAV6Zln5iz2X7I0l4zTOg9qfBjkymcrfitXJOdV5VDxJKQWZA74L2J5lLS5 xgP05q+8OppA== X-IronPort-AV: E=McAfee;i="6200,9189,9956"; a="191854337" X-IronPort-AV: E=Sophos;i="5.82,226,1613462400"; d="scan'208";a="191854337" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2021 07:07:01 -0700 IronPort-SDR: YCx63q1A9h0aVW/LAWa0TfKY3Frv4BN2dgfjAfEH72fSRlx8Sc3ZT3c6xDEcS/drcQseptSH2Q qeMpMbXrADQQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,226,1613462400"; d="scan'208";a="612766834" Received: from kbl-ppc.sh.intel.com ([10.239.159.163]) by fmsmga006.fm.intel.com with ESMTP; 16 Apr 2021 07:06:58 -0700 From: Jin Yao To: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com, Jin Yao Subject: [PATCH v4 15/25] perf stat: Filter out unmatched aggregation for hybrid event Date: Fri, 16 Apr 2021 22:05:07 +0800 Message-Id: <20210416140517.18206-16-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416140517.18206-1-yao.jin@linux.intel.com> References: <20210416140517.18206-1-yao.jin@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org perf-stat has supported some aggregation modes, such as --per-core, --per-socket and etc. While for hybrid event, it may only available on part of cpus. So for --per-core, we need to filter out the unavailable cores, for --per-socket, filter out the unavailable sockets, and so on. Before: # perf stat --per-core -e cpu_core/cycles/ -a -- sleep 1 Performance counter stats for 'system wide': S0-D0-C0 2 479,530 cpu_core/cycles/ S0-D0-C4 2 175,007 cpu_core/cycles/ S0-D0-C8 2 166,240 cpu_core/cycles/ S0-D0-C12 2 704,673 cpu_core/cycles/ S0-D0-C16 2 865,835 cpu_core/cycles/ S0-D0-C20 2 2,958,461 cpu_core/cycles/ S0-D0-C24 2 163,988 cpu_core/cycles/ S0-D0-C28 2 164,729 cpu_core/cycles/ S0-D0-C32 0 cpu_core/cycles/ S0-D0-C33 0 cpu_core/cycles/ S0-D0-C34 0 cpu_core/cycles/ S0-D0-C35 0 cpu_core/cycles/ S0-D0-C36 0 cpu_core/cycles/ S0-D0-C37 0 cpu_core/cycles/ S0-D0-C38 0 cpu_core/cycles/ S0-D0-C39 0 cpu_core/cycles/ 1.003597211 seconds time elapsed After: # perf stat --per-core -e cpu_core/cycles/ -a -- sleep 1 Performance counter stats for 'system wide': S0-D0-C0 2 210,428 cpu_core/cycles/ S0-D0-C4 2 444,830 cpu_core/cycles/ S0-D0-C8 2 435,241 cpu_core/cycles/ S0-D0-C12 2 423,976 cpu_core/cycles/ S0-D0-C16 2 859,350 cpu_core/cycles/ S0-D0-C20 2 1,559,589 cpu_core/cycles/ S0-D0-C24 2 163,924 cpu_core/cycles/ S0-D0-C28 2 376,610 cpu_core/cycles/ 1.003621290 seconds time elapsed Signed-off-by: Jin Yao --- v4: - No change. tools/perf/util/stat-display.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 5255d78b1c30..15eafd249e46 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -643,6 +643,20 @@ static void aggr_cb(struct perf_stat_config *config, } } +static bool aggr_id_hybrid_matched(struct perf_stat_config *config, + struct evsel *counter, struct aggr_cpu_id id) +{ + struct aggr_cpu_id s; + + for (int i = 0; i < evsel__nr_cpus(counter); i++) { + s = config->aggr_get_id(config, evsel__cpus(counter), i); + if (cpu_map__compare_aggr_cpu_id(s, id)) + return true; + } + + return false; +} + static void print_counter_aggrdata(struct perf_stat_config *config, struct evsel *counter, int s, char *prefix, bool metric_only, @@ -656,6 +670,12 @@ static void print_counter_aggrdata(struct perf_stat_config *config, double uval; ad.id = id = config->aggr_map->map[s]; + + if (perf_pmu__has_hybrid() && + !aggr_id_hybrid_matched(config, counter, id)) { + return; + } + ad.val = ad.ena = ad.run = 0; ad.nr = 0; if (!collect_data(config, counter, aggr_cb, &ad)) -- 2.17.1