linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/7] Add core wide metric literal
@ 2022-08-31 17:49 Ian Rogers
  2022-08-31 17:49 ` [PATCH v2 1/7] perf metric: Return early if no CPU PMU table exists Ian Rogers
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Ian Rogers @ 2022-08-31 17:49 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Andi Kleen, Kan Liang, Thomas Richter, James Clark, Miaoqian Lin,
	John Garry, Zhengjun Xing, Florian Fischer, linux-perf-users,
	linux-kernel, perry.taylor, caleb.biggers, kshipra.bopardikar,
	ahmad.yasin
  Cc: Stephane Eranian, Ian Rogers

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.

v2. Add error handling for ENOMEM to more strdup cases as suggested by
    Arnaldo. Init the shadow stats if running "perf stat report",
    issue caught by the stat shell test.

Ian Rogers (7):
  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     |  66 +++++++++++++----
 tools/perf/tests/expr.c       |  37 +++++++---
 tools/perf/util/cputopo.c     |  61 +++++++++++++++
 tools/perf/util/cputopo.h     |   5 ++
 tools/perf/util/expr.c        |  29 +++++---
 tools/perf/util/expr.h        |  14 ++--
 tools/perf/util/expr.l        |   6 +-
 tools/perf/util/metricgroup.c | 135 ++++++++++++++++++++++++----------
 tools/perf/util/metricgroup.h |   4 +-
 tools/perf/util/smt.c         | 109 ++++++---------------------
 tools/perf/util/smt.h         |  12 ++-
 tools/perf/util/stat-shadow.c |  13 +++-
 tools/perf/util/stat.h        |   2 +
 13 files changed, 318 insertions(+), 175 deletions(-)

-- 
2.37.2.672.g94769d06f0-goog


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-09-09 18:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-31 17:49 [PATCH v2 0/7] Add core wide metric literal Ian Rogers
2022-08-31 17:49 ` [PATCH v2 1/7] perf metric: Return early if no CPU PMU table exists Ian Rogers
2022-08-31 17:49 ` [PATCH v2 2/7] perf expr: Move the scanner_ctx into the parse_ctx Ian Rogers
2022-08-31 17:49 ` [PATCH v2 3/7] perf smt: Compute SMT from topology Ian Rogers
2022-08-31 17:49 ` [PATCH v2 4/7] perf topology: Add core_wide Ian Rogers
2022-09-02  6:29   ` Namhyung Kim
2022-09-06 18:56     ` Ian Rogers
2022-09-09 18:29       ` Namhyung Kim
2022-08-31 17:49 ` [PATCH v2 5/7] perf stat: Delay metric parsing Ian Rogers
2022-08-31 17:49 ` [PATCH v2 6/7] perf metrics: Wire up core_wide Ian Rogers
2022-08-31 17:49 ` [PATCH v2 7/7] perf test: Add basic core_wide expression test Ian Rogers

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).