Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3380632pxf; Mon, 29 Mar 2021 00:06:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzpL2cKOSglczb12ZentiPDa2gxEOLkpYVagmLD+GWyWjOVJS7dQSQuR4qI7d84OmWCZUF X-Received: by 2002:a17:906:80ca:: with SMTP id a10mr27333927ejx.297.1617001565468; Mon, 29 Mar 2021 00:06:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617001565; cv=none; d=google.com; s=arc-20160816; b=qkUmtXexjC9mlCYAmuX6eLf5qYYcJpc6Os8fRDI+SkRfSn3tRj5IQAE62ZyW/2G4wQ 2IC0mwL/wrcetAYCWRn/3MkPFktc7lXFWeK7hpx2axBFkGL+EGkW2rD5B0l3jZUrcljP 7FRlHb4wd5lhi3X02va1G9311agat2lOtJITvHosjdQKXE3/mea3Z1lSxh5ZKbN6vLgA PR0OTKCCu3ljawgkapW4HgasPL3bhtXU/fl1CdRV4QYT2J42hOoYn8FoRWRVY+aYbbDO 6i2EPEeMF6EjzFGecyjFfeDLa0PkKFc2hfqhIVJNdVI/jFFwY4IJ4/LYQ4/3ZTgB8d7E o3Pg== 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=X7Ge25o8ocYVHjXvtpgSq4NFWssdyIxktJLnN/WNubo=; b=VAIp9Shh+sA5wY868k9vri6Zk7F0mxZBn6ylSkwNijAleCG6Sb6jrP0MZ60N8qhX5i fb5nCzOo9CMX70wnou1EcY32YpDptxprrhbQAztbuMMIlMtypmmRNHqGi39dub6DTYUq ReCqVjNlfdZU+GS2B8KmwNKHgcOL2dXr1FFPw7qynX5LTnwxMvhyycCpCbCHOG1DsYmF k0zCvShhMwlL8dbEpDBO36Uzx1juGzaMh+iOohFJfinkw1jOSrbVmGHk8CA+UQ/YjVrd 4Srth4Y5/d9aZS+QM1RiQ2FadsKK1AO9YxDVXOuouzD0OEZOMydJh4TwY55fcZEEGuju VcAA== 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 b6si12321591edd.528.2021.03.29.00.05.43; Mon, 29 Mar 2021 00:06:05 -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 S231480AbhC2HDH (ORCPT + 99 others); Mon, 29 Mar 2021 03:03:07 -0400 Received: from mga14.intel.com ([192.55.52.115]:20002 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231185AbhC2HCV (ORCPT ); Mon, 29 Mar 2021 03:02:21 -0400 IronPort-SDR: zmHgYKBNaGyrbuwmZfN0DFmIpCxrDQ8NwbqK7Q0nPJHlyn6cu7QiGAi4Rzg9RJq69SsmgVfsHj Xwyr5erbMHew== X-IronPort-AV: E=McAfee;i="6000,8403,9937"; a="190956274" X-IronPort-AV: E=Sophos;i="5.81,287,1610438400"; d="scan'208";a="190956274" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2021 00:02:20 -0700 IronPort-SDR: EX7Z43J1wPKCIg7BdQrp4Gxxgj7zk+MLNufDVI61glmfg/C9pyX6YJq5IfVgExiuY3hILmbLrO 1Dgs45Vg97dg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,287,1610438400"; d="scan'208";a="444677502" Received: from kbl-ppc.sh.intel.com ([10.239.159.163]) by FMSMGA003.fm.intel.com with ESMTP; 29 Mar 2021 00:02:18 -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 v3 15/27] perf stat: Filter out unmatched aggregation for hybrid event Date: Mon, 29 Mar 2021 15:00:34 +0800 Message-Id: <20210329070046.8815-16-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210329070046.8815-1-yao.jin@linux.intel.com> References: <20210329070046.8815-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 --- v3: - No functional 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 161826938a00..b7ce3c4ae5a8 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -635,6 +635,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, @@ -648,6 +662,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