[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ef20fc6501c57d932024ad31323f90165caeae28.camel@intel.com>
Date: Wed, 17 Sep 2025 18:02:45 +0000
From: "Falcon, Thomas" <thomas.falcon@...el.com>
To: "Baker, Edward" <edward.baker@...el.com>, "Wang, Weilin"
<weilin.wang@...el.com>, "alexander.shishkin@...ux.intel.com"
<alexander.shishkin@...ux.intel.com>, "xu.yang_2@....com"
<xu.yang_2@....com>, "Biggers, Caleb" <caleb.biggers@...el.com>, "Hunter,
Adrian" <adrian.hunter@...el.com>, "Taylor, Perry" <perry.taylor@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-perf-users@...r.kernel.org" <linux-perf-users@...r.kernel.org>,
"mingo@...hat.com" <mingo@...hat.com>, "irogers@...gle.com"
<irogers@...gle.com>, "sandipan.das@....com" <sandipan.das@....com>,
"james.clark@...aro.org" <james.clark@...aro.org>,
"kan.liang@...ux.intel.com" <kan.liang@...ux.intel.com>,
"mark.rutland@....com" <mark.rutland@....com>, "peterz@...radead.org"
<peterz@...radead.org>, "john.g.garry@...cle.com" <john.g.garry@...cle.com>,
"bgray@...ux.ibm.com" <bgray@...ux.ibm.com>, "Alt, Samantha"
<samantha.alt@...el.com>, "renyu.zj@...ux.alibaba.com"
<renyu.zj@...ux.alibaba.com>, "acme@...nel.org" <acme@...nel.org>,
"jolsa@...nel.org" <jolsa@...nel.org>, "namhyung@...nel.org"
<namhyung@...nel.org>
Subject: Re: [PATCH v6 05/22] perf jevents: Mark metrics with experimental
events as experimental
On Wed, 2025-09-03 at 21:46 -0700, Ian Rogers wrote:
> When metrics are made with experimental events it is desirable the
> metric description also carries this information in case of metric
> inaccuracies.
>
> Suggested-by: Perry Taylor <perry.taylor@...el.com>
Does this need a Signed-off-by?
Thanks,
Tom
> ---
> tools/perf/pmu-events/metric.py | 44 +++++++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py
> index 62d1a1e1d458..2029b6e28365 100644
> --- a/tools/perf/pmu-events/metric.py
> +++ b/tools/perf/pmu-events/metric.py
> @@ -10,11 +10,13 @@ from typing import Dict, List, Optional, Set, Tuple, Union
>
> all_pmus = set()
> all_events = set()
> +experimental_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
> + global experimental_events
> all_events = {
> "context\\-switches",
> "cpu\\-cycles",
> @@ -32,6 +34,8 @@ def LoadEvents(directory: str) -> None:
> all_pmus.add(x["Unit"])
> if "EventName" in x:
> all_events.add(x["EventName"])
> + if "Experimental" in x and x["Experimental"] == "1":
> + experimental_events.add(x["EventName"])
> elif "ArchStdEvent" in x:
> all_events.add(x["ArchStdEvent"])
> except json.decoder.JSONDecodeError:
> @@ -61,6 +65,18 @@ def CheckEvent(name: str) -> bool:
> return name in all_events
>
>
> +def IsExperimentalEvent(name: str) -> bool:
> + global experimental_events
> + if ':' in name:
> + # Remove trailing modifier.
> + name = name[:name.find(':')]
> + elif '/' in name:
> + # Name could begin with a PMU or an event, for now assume it is not experimental.
> + return False
> +
> + return name in experimental_events
> +
> +
> class MetricConstraint(Enum):
> GROUPED_EVENTS = 0
> NO_GROUP_EVENTS = 1
> @@ -82,6 +98,10 @@ class Expression:
> """Returns a simplified version of self."""
> raise NotImplementedError()
>
> + def HasExperimentalEvents(self) -> bool:
> + """Are experimental events used in the expression?"""
> + raise NotImplementedError()
> +
> def Equals(self, other) -> bool:
> """Returns true when two expressions are the same."""
> raise NotImplementedError()
> @@ -249,6 +269,9 @@ class Operator(Expression):
>
> return Operator(self.operator, lhs, rhs)
>
> + def HasExperimentalEvents(self) -> bool:
> + return self.lhs.HasExperimentalEvents() or self.rhs.HasExperimentalEvents()
> +
> def Equals(self, other: Expression) -> bool:
> if isinstance(other, Operator):
> return self.operator == other.operator and self.lhs.Equals(
> @@ -297,6 +320,10 @@ class Select(Expression):
>
> return Select(true_val, cond, false_val)
>
> + def HasExperimentalEvents(self) -> bool:
> + return (self.cond.HasExperimentalEvents() or self.true_val.HasExperimentalEvents() or
> + self.false_val.HasExperimentalEvents())
> +
> def Equals(self, other: Expression) -> bool:
> if isinstance(other, Select):
> return self.cond.Equals(other.cond) and self.false_val.Equals(
> @@ -345,6 +372,9 @@ class Function(Expression):
>
> return Function(self.fn, lhs, rhs)
>
> + def HasExperimentalEvents(self) -> bool:
> + return self.lhs.HasExperimentalEvents() or (self.rhs and self.rhs.HasExperimentalEvents())
> +
> def Equals(self, other: Expression) -> bool:
> if isinstance(other, Function):
> result = self.fn == other.fn and self.lhs.Equals(other.lhs)
> @@ -384,6 +414,9 @@ class Event(Expression):
> global all_events
> raise Exception(f"No event {error} in:\n{all_events}")
>
> + def HasExperimentalEvents(self) -> bool:
> + return IsExperimentalEvent(self.name)
> +
> def ToPerfJson(self):
> result = re.sub('/', '@', self.name)
> return result
> @@ -416,6 +449,9 @@ class MetricRef(Expression):
> def Simplify(self) -> Expression:
> return self
>
> + def HasExperimentalEvents(self) -> bool:
> + return False
> +
> def Equals(self, other: Expression) -> bool:
> return isinstance(other, MetricRef) and self.name == other.name
>
> @@ -443,6 +479,9 @@ class Constant(Expression):
> def Simplify(self) -> Expression:
> return self
>
> + def HasExperimentalEvents(self) -> bool:
> + return False
> +
> def Equals(self, other: Expression) -> bool:
> return isinstance(other, Constant) and self.value == other.value
>
> @@ -465,6 +504,9 @@ class Literal(Expression):
> def Simplify(self) -> Expression:
> return self
>
> + def HasExperimentalEvents(self) -> bool:
> + return False
> +
> def Equals(self, other: Expression) -> bool:
> return isinstance(other, Literal) and self.value == other.value
>
> @@ -527,6 +569,8 @@ class Metric:
> self.name = name
> self.description = description
> self.expr = expr.Simplify()
> + if self.expr.HasExperimentalEvents():
> + self.description += " (metric should be considered experimental as it contains experimental events)."
> # Workraound valid_only_metric hiding certain metrics based on unit.
> scale_unit = scale_unit.replace('/sec', ' per sec')
> if scale_unit[0].isdigit():
Powered by blists - more mailing lists