Messages in this thread Patch in this message | | | Date | Wed, 13 Mar 2024 22:59:03 -0700 | Subject | [PATCH v3 04/20] perf jevents: Add CheckPmu to see if a PMU is in loaded json events | From | Ian Rogers <> |
| |
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@google.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 03312cd6d491..e1847cccfdb0 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", @@ -24,12 +26,18 @@ def LoadEvents(directory: str) -> None: filename = os.fsdecode(file) if filename.endswith(".json"): 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: all_events.add(x["ArchStdEvent"]) +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.44.0.278.ge034bb2e1d-goog
| |