Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp186026pxj; Tue, 15 Jun 2021 23:31:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB0A/G6Oou3R8jS85xWEqqEeSL9090dG0PjW6U4IT8YDTKIXQ0xQcjkoFOrRCSak2j/Yr5 X-Received: by 2002:a05:6e02:20c2:: with SMTP id 2mr2492691ilq.222.1623825114987; Tue, 15 Jun 2021 23:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623825114; cv=none; d=google.com; s=arc-20160816; b=S7M7tUL72/Ea7uUITMmt0ezcQjgaN0y4/ef12PN4TmquyKIEGrPCVSCjwEJbM8y1r3 jVBENWfeIe8pNpJurSzocqpWrGMQPVFUBVUlqvptNK5zER1LNleahd4TR9I50rKdA+dD 65qcpRo9yoZ4IuiVnm79mb3RLLKvIOajwEN0ATECHZznjC4UDinKuU6e7uHlqQk5Cvqt lbEz+IXqiuUHUMqCfEvA8rDtG1IkRomPa5iygynHyC+d9z0/JX2UWE5eQncLQ36p1Blf 7CnxezMFQzIT4mSeOl6a1m0vqn5iO1E028PtdAcwQUkkmQrBwkkS+4P3wtyxTrVUjQX6 yHJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=05z4HwqnCaX9rl5N6qS514bFtQfBv9MOwtBv4QCgzJA=; b=TM4n+BxjUJFwaWRmQJ63GwppViVHGdqC2ZE7znhePmweD+l6ZGz1Zpzr0rI4L/fg6X LSxD3K7ILOm5b2PCy3xIFNTXwu0EI0ra6W4abZEfxfcriRkjrmQMK/p5nhMz79MzmzXC +CgI5U1L493GkFUu+U4HGNXgQcTRIqKbCdtS25vUeyIXzRLwWmmO1GqirlvllcR6V/+/ iJ8hP1zvZCOaF673S7o3rZEDqQ0Cg68SICDaXWPZttxV4f+GhmQxck0aFCX0Kh/2wO68 wDrb8Ag/LQYk5RQfOBugUk60k+uPx5WxesQSJK3WvW5mdGER7UpaFVdMkBswtMuqD551 6vRg== 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 c15si1849549jam.64.2021.06.15.23.31.42; Tue, 15 Jun 2021 23:31:54 -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 S231453AbhFPGdW (ORCPT + 99 others); Wed, 16 Jun 2021 02:33:22 -0400 Received: from mga09.intel.com ([134.134.136.24]:61585 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231422AbhFPGdO (ORCPT ); Wed, 16 Jun 2021 02:33:14 -0400 IronPort-SDR: 4231z6lXhQnNK0WDmSloWIi7iRslYNNpWfrl1Q3KuITB2lnrj+IH+CXLOeQZ5O/vSu+05plmPn sIuXV0QZ3CzQ== X-IronPort-AV: E=McAfee;i="6200,9189,10016"; a="206081980" X-IronPort-AV: E=Sophos;i="5.83,277,1616482800"; d="scan'208";a="206081980" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2021 23:31:08 -0700 IronPort-SDR: S7oKWZsrLomh6CXYSo/b5nvAOewFNBsUi2PnpKEYjDIAwVepBbKTOnx33wY/nIm0oXHUdVzkXh 1Fjcdy+nebjA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,277,1616482800"; d="scan'208";a="471912867" Received: from kbl-ppc.sh.intel.com ([10.239.159.163]) by fmsmga004.fm.intel.com with ESMTP; 15 Jun 2021 23:31:05 -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] perf stat: Merge uncore events by default for hybrid platform Date: Wed, 16 Jun 2021 14:30:04 +0800 Message-Id: <20210616063004.2824-1-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On hybrid platform, by default stat aggregates and reports the event counts per pmu. For example, # perf stat -e cycles -a true Performance counter stats for 'system wide': 1,400,445 cpu_core/cycles/ 680,881 cpu_atom/cycles/ 0.001770773 seconds time elapsed While for uncore events, that's not a suitable method. Uncore has nothing to do with hybrid. So for uncore events, we aggregate event counts from all PMUs and report the counts without PMUs. Before: # perf stat -e arb/event=0x81,umask=0x1/,arb/event=0x84,umask=0x1/ -a true Performance counter stats for 'system wide': 2,058 uncore_arb_0/event=0x81,umask=0x1/ 2,028 uncore_arb_1/event=0x81,umask=0x1/ 0 uncore_arb_0/event=0x84,umask=0x1/ 0 uncore_arb_1/event=0x84,umask=0x1/ 0.000614498 seconds time elapsed After: # perf stat -e arb/event=0x81,umask=0x1/,arb/event=0x84,umask=0x1/ -a true Performance counter stats for 'system wide': 3,996 arb/event=0x81,umask=0x1/ 0 arb/event=0x84,umask=0x1/ 0.000630046 seconds time elapsed Of course, we also keep the '--no-merge' still works for uncore events. # perf stat -e arb/event=0x81,umask=0x1/,arb/event=0x84,umask=0x1/ --no-merge true Performance counter stats for 'system wide': 1,952 uncore_arb_0/event=0x81,umask=0x1/ 1,921 uncore_arb_1/event=0x81,umask=0x1/ 0 uncore_arb_0/event=0x84,umask=0x1/ 0 uncore_arb_1/event=0x84,umask=0x1/ 0.000575536 seconds time elapsed Signed-off-by: Jin Yao --- tools/perf/builtin-stat.c | 3 --- tools/perf/util/stat-display.c | 29 +++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index f9f74a514315..b67a44982b61 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2442,9 +2442,6 @@ int cmd_stat(int argc, const char **argv) evlist__check_cpu_maps(evsel_list); - if (perf_pmu__has_hybrid()) - stat_config.no_merge = true; - /* * Initialize thread_map with comm names, * so we could print it out on output. diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index b759dfd633b4..c6070f4684ca 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -595,6 +595,19 @@ static void collect_all_aliases(struct perf_stat_config *config, struct evsel *c } } +static bool is_uncore(struct evsel *evsel) +{ + struct perf_pmu *pmu; + + if (evsel->pmu_name) { + pmu = perf_pmu__find(evsel->pmu_name); + if (pmu) + return pmu->is_uncore; + } + + return false; +} + static bool collect_data(struct perf_stat_config *config, struct evsel *counter, void (*cb)(struct perf_stat_config *config, struct evsel *counter, void *data, bool first), @@ -603,10 +616,18 @@ static bool collect_data(struct perf_stat_config *config, struct evsel *counter, if (counter->merged_stat) return false; cb(config, counter, data, true); - if (config->no_merge) - uniquify_event_name(counter); - else if (counter->auto_merge_stats) - collect_all_aliases(config, counter, cb, data); + if (perf_pmu__has_hybrid()) { + if (config->no_merge || !is_uncore(counter)) + uniquify_event_name(counter); + else if (counter->auto_merge_stats) + collect_all_aliases(config, counter, cb, data); + } else { + if (config->no_merge) + uniquify_event_name(counter); + else if (counter->auto_merge_stats) + collect_all_aliases(config, counter, cb, data); + } + return true; } -- 2.17.1