summaryrefslogtreecommitdiff
path: root/tools/perf/pmu-events/jevents.py
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2023-02-19 01:28:05 -0800
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-02-19 08:03:24 -0300
commit900536349d12516114eed9f5b47d30c362e68cdc (patch)
tree8ecf4ab1987630e5098e470a6474bf051b39bc95 /tools/perf/pmu-events/jevents.py
parent207f7df7271c346da4a421c5b8cdadda99a37964 (diff)
downloadlinux-900536349d12516114eed9f5b47d30c362e68cdc.tar.gz
linux-900536349d12516114eed9f5b47d30c362e68cdc.tar.bz2
linux-900536349d12516114eed9f5b47d30c362e68cdc.zip
perf pmu-events: Make the metric_constraint an enum
Rename metric_constraint to event_grouping to better explain what the variable is used for. Switch to use an enum for encoding instead of a string. Rather than just no constraint/grouping information or "NO_NMI_WATCHDOG", have 4 enum values. The values encode whether to group or not, and two cases where the behavior is dependent on either the NMI watchdog being enabled or SMT being enabled. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com> Cc: Andrii Nakryiko <andrii@kernel.org> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Cc: Caleb Biggers <caleb.biggers@intel.com> Cc: Eduard Zingerman <eddyz87@gmail.com> Cc: Florian Fischer <florian.fischer@muhq.space> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jing Zhang <renyu.zj@linux.alibaba.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Perry Taylor <perry.taylor@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Sandipan Das <sandipan.das@amd.com> Cc: Sean Christopherson <seanjc@google.com> Cc: Stephane Eranian <eranian@google.com> Cc: Suzuki Poulouse <suzuki.poulose@arm.com> Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com> Cc: linux-arm-kernel@lists.infradead.org Cc: linux-stm32@st-md-mailman.stormreply.com Link: https://lore.kernel.org/r/20230219092848.639226-9-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/pmu-events/jevents.py')
-rwxr-xr-xtools/perf/pmu-events/jevents.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
index 2da55408398f..dc0c56dccb5e 100755
--- a/tools/perf/pmu-events/jevents.py
+++ b/tools/perf/pmu-events/jevents.py
@@ -51,8 +51,8 @@ _json_event_attributes = [
# Attributes that are in pmu_metric rather than pmu_event.
_json_metric_attributes = [
- 'metric_name', 'metric_group', 'metric_constraint', 'metric_expr', 'desc',
- 'long_desc', 'unit', 'compat', 'aggr_mode'
+ 'metric_name', 'metric_group', 'metric_expr', 'desc',
+ 'long_desc', 'unit', 'compat', 'aggr_mode', 'event_grouping'
]
def removesuffix(s: str, suffix: str) -> str:
@@ -204,6 +204,18 @@ class JsonEvent:
}
return aggr_mode_to_enum[aggr_mode]
+ def convert_metric_constraint(metric_constraint: str) -> Optional[str]:
+ """Returns the metric_event_groups enum value associated with the JSON string."""
+ if not metric_constraint:
+ return None
+ metric_constraint_to_enum = {
+ 'NO_GROUP_EVENTS': '1',
+ 'NO_GROUP_EVENTS_NMI': '2',
+ 'NO_NMI_WATCHDOG': '2',
+ 'NO_GROUP_EVENTS_SMT': '3',
+ }
+ return metric_constraint_to_enum[metric_constraint]
+
def lookup_msr(num: str) -> Optional[str]:
"""Converts the msr number, or first in a list to the appropriate event field."""
if not num:
@@ -288,7 +300,7 @@ class JsonEvent:
self.deprecated = jd.get('Deprecated')
self.metric_name = jd.get('MetricName')
self.metric_group = jd.get('MetricGroup')
- self.metric_constraint = jd.get('MetricConstraint')
+ self.event_grouping = convert_metric_constraint(jd.get('MetricConstraint'))
self.metric_expr = None
if 'MetricExpr' in jd:
self.metric_expr = metric.ParsePerfJson(jd['MetricExpr']).Simplify()
@@ -678,7 +690,7 @@ static void decompress_event(int offset, struct pmu_event *pe)
{
\tconst char *p = &big_c_string[offset];
""")
- enum_attributes = ['aggr_mode', 'deprecated', 'perpkg']
+ enum_attributes = ['aggr_mode', 'deprecated', 'event_grouping', 'perpkg']
for attr in _json_event_attributes:
_args.output_file.write(f'\n\tpe->{attr} = ')
if attr in enum_attributes: