mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-29 03:24:53 -04:00
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>
20 lines
956 B
Python
20 lines
956 B
Python
# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
|
|
from metric import (d_ratio, Event, Metric, MetricGroup)
|
|
|
|
|
|
def Cycles() -> MetricGroup:
|
|
cyc_k = Event("cpu\\-cycles:kHh") # exclude user and guest
|
|
cyc_g = Event("cpu\\-cycles:G") # exclude host
|
|
cyc_u = Event("cpu\\-cycles:uH") # exclude kernel, hypervisor and guest
|
|
cyc = cyc_k + cyc_g + cyc_u
|
|
|
|
return MetricGroup("lpm_cycles", [
|
|
Metric("lpm_cycles_total", "Total number of cycles", cyc, "cycles"),
|
|
Metric("lpm_cycles_user", "User cycles as a percentage of all cycles",
|
|
d_ratio(cyc_u, cyc), "100%"),
|
|
Metric("lpm_cycles_kernel", "Kernel cycles as a percentage of all cycles",
|
|
d_ratio(cyc_k, cyc), "100%"),
|
|
Metric("lpm_cycles_guest", "Hypervisor guest cycles as a percentage of all cycles",
|
|
d_ratio(cyc_g, cyc), "100%"),
|
|
], description="cycles breakdown per privilege level (users, kernel, guest)")
|