[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250829041104.4186320-4-irogers@google.com>
Date: Thu, 28 Aug 2025 21:10:44 -0700
From: Ian Rogers <irogers@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>,
Ian Rogers <irogers@...gle.com>, Adrian Hunter <adrian.hunter@...el.com>,
Kan Liang <kan.liang@...ux.intel.com>, James Clark <james.clark@...aro.org>,
Xu Yang <xu.yang_2@....com>, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org, John Garry <john.g.garry@...cle.com>,
Jing Zhang <renyu.zj@...ux.alibaba.com>, Sandipan Das <sandipan.das@....com>,
Benjamin Gray <bgray@...ux.ibm.com>, Perry Taylor <perry.taylor@...el.com>,
Samantha Alt <samantha.alt@...el.com>, Caleb Biggers <caleb.biggers@...el.com>,
Weilin Wang <weilin.wang@...el.com>, Edward Baker <edward.baker@...el.com>,
Thomas Falcon <thomas.falcon@...el.com>
Subject: [PATCH v5 03/22] perf jevents: Add CheckPmu to see if a PMU is in
loaded json events
CheckPmu can be used to determine if hybrid events are present,
allowing for hybrid conditional metrics/events/pmus to be premised on
the json files rather than hard coded tables.
Signed-off-by: Ian Rogers <irogers@...gle.com>
---
tools/perf/pmu-events/metric.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py
index 36e9cb3acf6a..4f62f252abef 100644
--- a/tools/perf/pmu-events/metric.py
+++ b/tools/perf/pmu-events/metric.py
@@ -8,10 +8,12 @@ import re
from enum import Enum
from typing import Dict, List, Optional, Set, Tuple, Union
+all_pmus = set()
all_events = set()
def LoadEvents(directory: str) -> None:
"""Populate a global set of all known events for the purpose of validating Event names"""
+ global all_pmus
global all_events
all_events = {
"context\-switches",
@@ -25,6 +27,8 @@ def LoadEvents(directory: str) -> None:
if filename.endswith(".json"):
try:
for x in json.load(open(f"{directory}/{filename}")):
+ if "Unit" in x:
+ all_pmus.add(x["Unit"])
if "EventName" in x:
all_events.add(x["EventName"])
elif "ArchStdEvent" in x:
@@ -35,6 +39,10 @@ def LoadEvents(directory: str) -> None:
pass
+def CheckPmu(name: str) -> bool:
+ return name in all_pmus
+
+
def CheckEvent(name: str) -> bool:
"""Check the event name exists in the set of all loaded events"""
global all_events
--
2.51.0.318.gd7df087d1a-goog
Powered by blists - more mailing lists