linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Andi Kleen <ak@linux.intel.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Thomas Richter <tmricht@linux.ibm.com>,
	James Clark <james.clark@arm.com>,
	Miaoqian Lin <linmq006@gmail.com>,
	John Garry <john.garry@huawei.com>,
	Zhengjun Xing <zhengjun.xing@linux.intel.com>,
	Florian Fischer <florian.fischer@muhq.space>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	perry.taylor@intel.com, caleb.biggers@intel.com,
	kshipra.bopardikar@intel.com
Cc: Stephane Eranian <eranian@google.com>, Ian Rogers <irogers@google.com>
Subject: [PATCH v1 0/8] Add core wide metric literal
Date: Tue, 30 Aug 2022 09:48:38 -0700	[thread overview]
Message-ID: <20220830164846.401143-1-irogers@google.com> (raw)

It is possible to optimize metrics when all SMT threads (CPUs) on a
core are measuring events in system wide mode. For example, TMA
metrics [1] defines CORE_CLKS for Sandybrdige as:
    
if SMT is disabled:
  CPU_CLK_UNHALTED.THREAD
if SMT is enabled and recording on all SMT threads (for all processes):
  CPU_CLK_UNHALTED.THREAD_ANY / 2
if SMT is enabled and not recording on all SMT threads:
  (CPU_CLK_UNHALTED.THREAD/2)*
  (1+CPU_CLK_UNHALTED.ONE_THREAD_ACTIVE/CPU_CLK_UNHALTED.REF_XCLK )
    
That is two more events are necessary when not gathering counts on all
SMT threads. To distinguish all SMT threads on a core vs system wide
(all CPUs) call the new property core wide.

As this literal requires the user requested CPUs and system wide to be
present, the parsing of metrics is delayed until after command line
option processing. As events are used to compute the evlist maps, and
metrics create events, the data for core wide must come from the target.

This patch series doesn't correct the Intel metrics to use #core_wide,
which will be done in follow up work. To see the two behaviors
currently you need an Intel CPU between Sandybridge and before
Icelake, then compare the events for tma_backend_bound_percent and
Backend_Bound_SMT where the former assumes recording on all SMT
threads and the latter assumes not recording on all SMT threads. The
future work will just have a single backend bound metric for both
cases determined using #core_wide.

[1] https://download.01.org/perfmon/TMA_Metrics.xlsx Note, #EBS_Mode
is false when recording on all SMT threads and all processes which is
 #core_wide true in this change.

Ian Rogers (8):
  perf smt: Tidy header guard add SPDX
  perf metric: Return early if no CPU PMU table exists
  perf expr: Move the scanner_ctx into the parse_ctx
  perf smt: Compute SMT from topology
  perf topology: Add core_wide
  perf stat: Delay metric parsing
  perf metrics: Wire up core_wide
  perf test: Add basic core_wide expression test

 tools/perf/builtin-stat.c     |  57 +++++++++++++-----
 tools/perf/tests/expr.c       |  37 +++++++++---
 tools/perf/util/cputopo.c     |  61 +++++++++++++++++++
 tools/perf/util/cputopo.h     |   5 ++
 tools/perf/util/expr.c        |  26 ++++----
 tools/perf/util/expr.h        |  14 +++--
 tools/perf/util/expr.l        |   6 +-
 tools/perf/util/metricgroup.c |  92 +++++++++++++++++++++-------
 tools/perf/util/metricgroup.h |   4 +-
 tools/perf/util/smt.c         | 110 ++++++++--------------------------
 tools/perf/util/smt.h         |  19 ++++--
 tools/perf/util/stat-shadow.c |  13 ++--
 tools/perf/util/stat.h        |   2 +
 13 files changed, 286 insertions(+), 160 deletions(-)

-- 
2.37.2.672.g94769d06f0-goog


             reply	other threads:[~2022-08-30 16:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-30 16:48 Ian Rogers [this message]
2022-08-30 16:48 ` [PATCH v1 1/8] perf smt: Tidy header guard add SPDX Ian Rogers
2022-08-31 14:46   ` Arnaldo Carvalho de Melo
2022-08-30 16:48 ` [PATCH v1 2/8] perf metric: Return early if no CPU PMU table exists Ian Rogers
2022-08-31 12:21   ` Arnaldo Carvalho de Melo
2022-08-31 12:30   ` Arnaldo Carvalho de Melo
2022-08-30 16:48 ` [PATCH v1 3/8] perf expr: Move the scanner_ctx into the parse_ctx Ian Rogers
2022-08-30 16:48 ` [PATCH v1 4/8] perf smt: Compute SMT from topology Ian Rogers
2022-08-30 16:48 ` [PATCH v1 5/8] perf topology: Add core_wide Ian Rogers
2022-08-31 14:40   ` Arnaldo Carvalho de Melo
2022-08-31 15:58     ` Ian Rogers
2022-08-31 16:20       ` Arnaldo Carvalho de Melo
2022-08-31 16:42         ` Ian Rogers
2022-08-30 16:48 ` [PATCH v1 6/8] perf stat: Delay metric parsing Ian Rogers
2022-08-31 14:42   ` Arnaldo Carvalho de Melo
2022-08-31 16:13     ` Ian Rogers
2022-08-30 16:48 ` [PATCH v1 7/8] perf metrics: Wire up core_wide Ian Rogers
2022-08-31 14:44   ` Arnaldo Carvalho de Melo
2022-08-31 16:38     ` Ian Rogers
2022-08-30 16:48 ` [PATCH v1 8/8] perf test: Add basic core_wide expression test Ian Rogers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220830164846.401143-1-irogers@google.com \
    --to=irogers@google.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=caleb.biggers@intel.com \
    --cc=eranian@google.com \
    --cc=florian.fischer@muhq.space \
    --cc=james.clark@arm.com \
    --cc=john.garry@huawei.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=kshipra.bopardikar@intel.com \
    --cc=linmq006@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=perry.taylor@intel.com \
    --cc=peterz@infradead.org \
    --cc=tmricht@linux.ibm.com \
    --cc=zhengjun.xing@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).