Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf jevents: Add cycles breakdown metric for arm64/AMD/Intel

Breakdown cycles to user, kernel and guest. Add a common_metrics.py
file for such metrics.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Thomas Falcon <thomas.falcon@intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Benjamin Gray <bgray@linux.ibm.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Edward Baker <edward.baker@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Leo Yan <leo.yan@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Weilin Wang <weilin.wang@intel.com>
Cc: Xu Yang <xu.yang_2@nxp.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
82e53e7a e74f72a7

+28 -2
+1 -1
tools/perf/pmu-events/Build
··· 52 52 $(call rule_mkdir) 53 53 $(Q)$(call echo-cmd,gen)$(PYTHON) $(LEGACY_CACHE_PY) > $@ 54 54 55 - GEN_METRIC_DEPS := pmu-events/metric.py 55 + GEN_METRIC_DEPS := pmu-events/metric.py pmu-events/common_metrics.py 56 56 57 57 # Generate AMD Json 58 58 ZENS = $(shell ls -d pmu-events/arch/x86/amdzen*)
+2
tools/perf/pmu-events/amd_metrics.py
··· 4 4 import math 5 5 import os 6 6 from typing import Optional 7 + from common_metrics import Cycles 7 8 from metric import (d_ratio, has_event, max, Event, JsonEncodeMetric, 8 9 JsonEncodeMetricGroupDescriptions, Literal, LoadEvents, 9 10 Metric, MetricGroup, Select) ··· 476 475 AmdItlb(), 477 476 AmdLdSt(), 478 477 AmdUpc(), 478 + Cycles(), 479 479 Idle(), 480 480 Rapl(), 481 481 UncoreL3(),
+4 -1
tools/perf/pmu-events/arm64_metrics.py
··· 4 4 import os 5 5 from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, LoadEvents, 6 6 MetricGroup) 7 + from common_metrics import Cycles 7 8 8 9 # Global command line arguments. 9 10 _args = None ··· 35 34 directory = f"{_args.events_path}/arm64/{_args.vendor}/{_args.model}/" 36 35 LoadEvents(directory) 37 36 38 - all_metrics = MetricGroup("", []) 37 + all_metrics = MetricGroup("", [ 38 + Cycles(), 39 + ]) 39 40 40 41 if _args.metricgroups: 41 42 print(JsonEncodeMetricGroupDescriptions(all_metrics))
+19
tools/perf/pmu-events/common_metrics.py
··· 1 + # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) 2 + from metric import (d_ratio, Event, Metric, MetricGroup) 3 + 4 + 5 + def Cycles() -> MetricGroup: 6 + cyc_k = Event("cpu\\-cycles:kHh") # exclude user and guest 7 + cyc_g = Event("cpu\\-cycles:G") # exclude host 8 + cyc_u = Event("cpu\\-cycles:uH") # exclude kernel, hypervisor and guest 9 + cyc = cyc_k + cyc_g + cyc_u 10 + 11 + return MetricGroup("lpm_cycles", [ 12 + Metric("lpm_cycles_total", "Total number of cycles", cyc, "cycles"), 13 + Metric("lpm_cycles_user", "User cycles as a percentage of all cycles", 14 + d_ratio(cyc_u, cyc), "100%"), 15 + Metric("lpm_cycles_kernel", "Kernel cycles as a percentage of all cycles", 16 + d_ratio(cyc_k, cyc), "100%"), 17 + Metric("lpm_cycles_guest", "Hypervisor guest cycles as a percentage of all cycles", 18 + d_ratio(cyc_g, cyc), "100%"), 19 + ], description="cycles breakdown per privilege level (users, kernel, guest)")
+2
tools/perf/pmu-events/intel_metrics.py
··· 6 6 import os 7 7 import re 8 8 from typing import Optional 9 + from common_metrics import Cycles 9 10 from metric import (d_ratio, has_event, max, source_count, CheckPmu, Event, 10 11 JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, 11 12 Literal, LoadEvents, Metric, MetricConstraint, MetricGroup, ··· 1096 1095 LoadEvents(directory) 1097 1096 1098 1097 all_metrics = MetricGroup("", [ 1098 + Cycles(), 1099 1099 Idle(), 1100 1100 Rapl(), 1101 1101 Smi(),