From nobody Sun Feb 8 23:04:21 2026 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7351432ED22 for ; Thu, 8 Jan 2026 19:11:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767899520; cv=none; b=bR1aI5G6FARMZxHP4Ju52NVLEwHLbl4Dx24kccG3SPkpJcalRA2sAU5Pq7hnJGzUPuNydWPkED6fQqIBXgyU48FwFSvqE94S3JV4QyFEd20/D02z6fS3luOJH9pRXmc7hbJ2UUXHJu3iGHHHmIBzc0w99snk258LqNa5Qpyn7bM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767899520; c=relaxed/simple; bh=Tg0u9xgINTvX1H6FGlOJHenHBu6latCGVtmFgleOH30=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=j9wXpLVh1dAy6FJ1ZP72dcOSDEHTo5KCGdkRI87HjulIovVFOBxpfQ4fRCulSRT/mWqikSG+AyWhE9YWZTj6uU2TlbpJnvnKXNh4q2k+BujweH1tQwzsMoN/tQR7QWfTe+AnKCxk8lGMQqcG3DgXv/qFSdQ5lcLxBGrMxD+GAOs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=McqRQs4X; arc=none smtp.client-ip=74.125.82.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="McqRQs4X" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2b062c1aa44so4193636eec.0 for ; Thu, 08 Jan 2026 11:11:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1767899517; x=1768504317; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=U6hcFPxi9yX1voNwD9X4pnHV7jvDzOlcX84euGlTBqw=; b=McqRQs4XGBSIDxm6ORpXgMhX0pSfdIRnxiUJwxqt2scDTi5aaNsvrhwt9vHR1C2M0S Oazphbmn9mhnxL4UGG+c1AuffqjureuwXArTBNcDT8eb8ZwJknlZcAsH8OSll1YOZm65 sHlHpf7Sxb/KujWyIL21OnEfXp9Dczw38TQ2Pwd8nxmKC3huJo4TnzhnWKcSUOXVIqgZ 8MHGNlZMLCHibZrvEYJXiHMNX6CGSNy3lvjzpmfRiKCmEF0KoM8Jjp2pAkGUGGiLYuLE xAkT17Mve0FxOCzPrfRoPywo6qXGbIVWIiV6Cb30llAF2hFwK/Vhc1cxqsasu46dcly7 oUJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767899517; x=1768504317; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=U6hcFPxi9yX1voNwD9X4pnHV7jvDzOlcX84euGlTBqw=; b=u7tqy1cl08UeW4DMxHM55Y9YsR+LVm93xtRaJX73KHPr8Dl+GtF4QjkTG/F8cyZgCr IFGK+1ha63rl/DSCK/Y1bEk9rkU9xfNNqQfs7pqmpL9zlrl16u2iOaDREm3wgpU2xZge +b0U6hmIjXnFAylpvZq9ZFS4g3y5x+r+LR0pdCXvzCa/nnxAKjZGoPIy6ciuCA493L+V KLoEzoNG8dW+xaJSdEXORxlbeOrLliG26LVimk3pmA56SCCCX8zI3mqYRLHotKtRDQx6 7FpcpyyveX+EWmpYGe5d8eDuz1nowmZm4oE3aMDSfliOpA0ZQ2BW6HtFAb7PJS7zcfiH gAeg== X-Forwarded-Encrypted: i=1; AJvYcCXZ5o5uMM1MkqXfw3nn1jpRX/dQKz4yfsC2IcW9yVjprC4SgKl0JXZ4BfNURIsRii4txqjcKUyeKrJeCyU=@vger.kernel.org X-Gm-Message-State: AOJu0YyCBqFU/pO/Mk/kwfn0gkZLLtvfVQMQgMatFc8o7EOobraWwu4+ XKYpLJQkuPCyPhKC3tC9iiGJodcDtmlVFfyuRSiIHm5DfrOJqKQ95xSTrOsaTxgFsYsKco1UAlc OGeW+xNPqMg== X-Google-Smtp-Source: AGHT+IFnXtL98LV7vbdXX6Sbkm44nwMtzEAp7tcF6f64Sgqk2vPXeIucA35xnhOTAotUYtCEXxX1u8HTolEQ X-Received: from dyboe6.prod.google.com ([2002:a05:7301:3d06:b0:2ae:3555:a1b1]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:f54d:b0:2a4:61d1:f451 with SMTP id 5a478bee46e88-2b17d224539mr4078280eec.16.1767899516637; Thu, 08 Jan 2026 11:11:56 -0800 (PST) Date: Thu, 8 Jan 2026 11:10:46 -0800 In-Reply-To: <20260108191105.695131-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260108191105.695131-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260108191105.695131-17-irogers@google.com> Subject: [PATCH v10 16/35] perf jevents: Mark metrics with experimental events as experimental From: Ian Rogers To: Adrian Hunter , Alexander Shishkin , Arnaldo Carvalho de Melo , Benjamin Gray , Caleb Biggers , Edward Baker , Ian Rogers , Ingo Molnar , James Clark , Jing Zhang , Jiri Olsa , John Garry , Leo Yan , Namhyung Kim , Perry Taylor , Peter Zijlstra , Samantha Alt , Sandipan Das , Thomas Falcon , Weilin Wang , Xu Yang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Tested-by: Thomas Falcon Signed-off-by: Ian Rogers --- 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, Un= ion =20 all_pmus =3D set() all_events =3D set() +experimental_events =3D set() =20 def LoadEvents(directory: str) -> None: """Populate a global set of all known events for the purpose of validati= ng Event names""" global all_pmus global all_events + global experimental_events all_events =3D { "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"] =3D=3D "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 =20 =20 +def IsExperimentalEvent(name: str) -> bool: + global experimental_events + if ':' in name: + # Remove trailing modifier. + name =3D name[:name.find(':')] + elif '/' in name: + # Name could begin with a PMU or an event, for now assume it is not ex= perimental. + return False + + return name in experimental_events + + class MetricConstraint(Enum): GROUPED_EVENTS =3D 0 NO_GROUP_EVENTS =3D 1 @@ -82,6 +98,10 @@ class Expression: """Returns a simplified version of self.""" raise NotImplementedError() =20 + 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): =20 return Operator(self.operator, lhs, rhs) =20 + def HasExperimentalEvents(self) -> bool: + return self.lhs.HasExperimentalEvents() or self.rhs.HasExperimentalEve= nts() + def Equals(self, other: Expression) -> bool: if isinstance(other, Operator): return self.operator =3D=3D other.operator and self.lhs.Equals( @@ -297,6 +320,10 @@ class Select(Expression): =20 return Select(true_val, cond, false_val) =20 + def HasExperimentalEvents(self) -> bool: + return (self.cond.HasExperimentalEvents() or self.true_val.HasExperime= ntalEvents() 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): =20 return Function(self.fn, lhs, rhs) =20 + def HasExperimentalEvents(self) -> bool: + return self.lhs.HasExperimentalEvents() or (self.rhs and self.rhs.HasE= xperimentalEvents()) + def Equals(self, other: Expression) -> bool: if isinstance(other, Function): result =3D self.fn =3D=3D 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}") =20 + def HasExperimentalEvents(self) -> bool: + return IsExperimentalEvent(self.name) + def ToPerfJson(self): result =3D re.sub('/', '@', self.name) return result @@ -416,6 +449,9 @@ class MetricRef(Expression): def Simplify(self) -> Expression: return self =20 + def HasExperimentalEvents(self) -> bool: + return False + def Equals(self, other: Expression) -> bool: return isinstance(other, MetricRef) and self.name =3D=3D other.name =20 @@ -443,6 +479,9 @@ class Constant(Expression): def Simplify(self) -> Expression: return self =20 + def HasExperimentalEvents(self) -> bool: + return False + def Equals(self, other: Expression) -> bool: return isinstance(other, Constant) and self.value =3D=3D other.value =20 @@ -465,6 +504,9 @@ class Literal(Expression): def Simplify(self) -> Expression: return self =20 + def HasExperimentalEvents(self) -> bool: + return False + def Equals(self, other: Expression) -> bool: return isinstance(other, Literal) and self.value =3D=3D other.value =20 @@ -527,6 +569,8 @@ class Metric: self.name =3D name self.description =3D description self.expr =3D expr.Simplify() + if self.expr.HasExperimentalEvents(): + self.description +=3D " (metric should be considered experimental as= it contains experimental events)." # Workraound valid_only_metric hiding certain metrics based on unit. scale_unit =3D scale_unit.replace('/sec', ' per sec') if scale_unit[0].isdigit(): --=20 2.52.0.457.g6b5491de43-goog