Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4207228pxb; Mon, 8 Feb 2021 10:22:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqC14ZTLoaGXv3eHFXsMcqyxpmI+0jV9EUgYuKmyoOnmSpOMR61zx8oVPuCjKCJCZkLTVZ X-Received: by 2002:a17:906:7d97:: with SMTP id v23mr17591106ejo.222.1612808525627; Mon, 08 Feb 2021 10:22:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612808525; cv=none; d=google.com; s=arc-20160816; b=ZuKGDINXMsvDOzIjkwxlD8kw+3LPj22RtSXf8QBD+PtCy9sTi0rN/kQStcSDyFT+Be 2Jt3RLxnZKiRQwylxLQx6VOVQMstAS72Fc6JJub41ChQRC/4MQhaDXjSdvpviteyFW/7 sYpk4kecCA3s6vMuwnzoef4Uja9HlA6cSrQZiAiM89l7Blh3+SvQstegW0iUqtuKY+Bp 1x3qxQY7b4yPYI0ID5vF1/vULfPZA/lZYNyv1FXHT1SmJi2DzHayNakFdi6lgNAVMXKL a/K/yLGaY8Y9SSCjMPmbtNWEpEVJX0DQM9K0ju9FcjLx1nweNSWV4mG8f/5TIG9jzxdx q9nA== 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=RqXZ0sPp71p1n//epR0YoMsphzKgUWumdfKTq5929E0=; b=jVZ75NbG4+7vliVDCvI1YjBBycas20J44Oz/Hin/KPFI+cz/4x5OKQVp83NdW7z4Oh pW19cRrozOqPk4CDuBIZBW4bvpjxoiHteiX7CclfpdYKinG1uo7X9ryviZjzs1rhflTP 9qfoLJ9V3dQwdf92CN7cFg/4O+qZQuY3r/WSpFqhkt0Jeg6wStgdxqf4P8ZG5K7TTyyU l49eDOx0ULghR4SCRIievVa6qGHO+lOoYpJ8xCLu8K5EJTEfrOieDL3T8ZVRhsTTaZcy Xn0bJNZuEtDciKGa5Gn2oNaYGCiKmXnYhOT6ULSjHz2KLG5z+FjRKKRkxWEMgkhE7DkH o5aw== 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 x5si1041837edi.139.2021.02.08.10.21.42; Mon, 08 Feb 2021 10:22:05 -0800 (PST) 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 S234021AbhBHSVA (ORCPT + 99 others); Mon, 8 Feb 2021 13:21:00 -0500 Received: from mga09.intel.com ([134.134.136.24]:27842 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234096AbhBHPp2 (ORCPT ); Mon, 8 Feb 2021 10:45:28 -0500 IronPort-SDR: a4g9SrE2+9+UxAqqmyao/tcXRNTDXkYgwwb5Us79/6FiSZPCUi/oaNEQfKsv4vOyuHjfl82SZU ZjLBbuvPscVQ== X-IronPort-AV: E=McAfee;i="6000,8403,9889"; a="181874632" X-IronPort-AV: E=Sophos;i="5.81,162,1610438400"; d="scan'208";a="181874632" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2021 07:30:37 -0800 IronPort-SDR: mmZOV23r7U4XxhQ3Qy0Jo+A/LTHBAD5BeiDY7hGHjRk0ifkFiCixQ52KRdswtRrCzOEGJjfxf4 LbKqIQLmaI1w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,162,1610438400"; d="scan'208";a="358820931" Received: from otc-lr-04.jf.intel.com ([10.54.39.41]) by orsmga003.jf.intel.com with ESMTP; 08 Feb 2021 07:30:37 -0800 From: kan.liang@linux.intel.com To: peterz@infradead.org, acme@kernel.org, mingo@kernel.org, linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, bp@alien8.de, namhyung@kernel.org, jolsa@redhat.com, ak@linux.intel.com, yao.jin@linux.intel.com, alexander.shishkin@linux.intel.com, adrian.hunter@intel.com Subject: [PATCH 45/49] perf stat: Merge event counts from all hybrid PMUs Date: Mon, 8 Feb 2021 07:25:42 -0800 Message-Id: <1612797946-18784-46-git-send-email-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1612797946-18784-1-git-send-email-kan.liang@linux.intel.com> References: <1612797946-18784-1-git-send-email-kan.liang@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jin Yao For hybrid events, by default stat aggregates and reports the event counts per pmu. root@otcpl-adl-s-2:~# ./perf stat -e cycles -a -- sleep 1 Performance counter stats for 'system wide': 17,291,386 cycles [cpu_core] 1,556,803 cycles [cpu_atom] 1.002154118 seconds time elapsed Sometime, it's also useful to aggregate event counts from all PMUs. Create a new option '--hybrid-merge' to enable that behavior and report the counts without PMUs. root@otcpl-adl-s-2:~# ./perf stat -e cycles -a --hybrid-merge -- sleep 1 Performance counter stats for 'system wide': 19,041,587 cycles 1.002195329 seconds time elapsed Reviewed-by: Andi Kleen Signed-off-by: Jin Yao --- tools/perf/Documentation/perf-stat.txt | 7 +++++++ tools/perf/builtin-stat.c | 3 ++- tools/perf/util/stat-display.c | 3 ++- tools/perf/util/stat.h | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt index b0e357d..3d083a3 100644 --- a/tools/perf/Documentation/perf-stat.txt +++ b/tools/perf/Documentation/perf-stat.txt @@ -418,6 +418,13 @@ Multiple events are created from a single event specification when: 2. Aliases, which are listed immediately after the Kernel PMU events by perf list, are used. +--hybrid-merge:: +Merge the hybrid event counts from all PMUs. + +For hybrid events, by default stat aggregates and reports the event counts +per pmu. But sometime, it's also useful to aggregate event counts from all +PMUs. This option enables that behavior and reports the counts without PMUs. + --smi-cost:: Measure SMI cost if msr/aperf/ and msr/smi/ events are supported. diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index bfe7305..d367cfe 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -1184,6 +1184,7 @@ static struct option stat_options[] = { OPT_SET_UINT('A', "no-aggr", &stat_config.aggr_mode, "disable CPU count aggregation", AGGR_NONE), OPT_BOOLEAN(0, "no-merge", &stat_config.no_merge, "Do not merge identical named events"), + OPT_BOOLEAN(0, "hybrid-merge", &stat_config.hybrid_merge, "Merge identical named hybrid events"), OPT_STRING('x', "field-separator", &stat_config.csv_sep, "separator", "print counts with custom separator"), OPT_CALLBACK('G', "cgroup", &evsel_list, "name", @@ -2379,7 +2380,7 @@ int cmd_stat(int argc, const char **argv) evlist__check_cpu_maps(evsel_list); - if (perf_pmu__hybrid_exist()) + if (perf_pmu__hybrid_exist() && !stat_config.hybrid_merge) stat_config.no_merge = true; /* diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 961d5ac..21a3f80 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -568,6 +568,7 @@ static void collect_all_aliases(struct perf_stat_config *config, struct evsel *c !strcmp(alias->pmu_name, counter->pmu_name) || (evsel__is_hybrid_event(alias) && evsel__is_hybrid_event(counter) && + !config->hybrid_merge && strcmp(alias->pmu_name, counter->pmu_name))) break; alias->merged_stat = true; @@ -585,7 +586,7 @@ static bool collect_data(struct perf_stat_config *config, struct evsel *counter, cb(config, counter, data, true); if (config->no_merge) uniquify_event_name(counter); - else if (counter->auto_merge_stats) + else if (counter->auto_merge_stats || config->hybrid_merge) collect_all_aliases(config, counter, cb, data); return true; } diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index d85c292..80f6715 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -123,6 +123,7 @@ struct perf_stat_config { bool ru_display; bool big_num; bool no_merge; + bool hybrid_merge; bool walltime_run_table; bool all_kernel; bool all_user; -- 2.7.4