From nobody Wed Dec 10 21:11:57 2025 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (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 00D882D0601 for ; Tue, 2 Dec 2025 17:51:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764697877; cv=none; b=flOOCPGnIgw2sELzdM1OcPqczFchFzwyfaXBHWdDoluz6ZJMnFixP2lPTrxGex3MW/TR4E66vKyV0r9+oh3eKPqojmI0GUdIU6qV7k1+vgCHTIrNRLoThV28bXPoZKrMmeiqkXWBDFXFisbEX2BJpCl5eKKI3NEDVcIBl1Ssi+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764697877; c=relaxed/simple; bh=zWsUZ4Jd4Lkf2jf3z0CVAWHU02kQFxP6PvAOmYI09OI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=KOhW4hC2HHiEy4bpnpI3cPc47EGHK7TV83Hm1ZpmfOtfgUqWzn0v+sAwv1dc56QgSntW1Kvm+miICH0e3lmnlDRi3KSS1k3PD+THSoioJx1SbpUvfm85N+5KsWUZ4EaOnylrjyBPZRrV698eKK7CMqPbbO5n3uQ0wm5I8HjeOyQ= 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=QKqxWUS3; arc=none smtp.client-ip=209.85.215.202 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="QKqxWUS3" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-b99f6516262so13924946a12.3 for ; Tue, 02 Dec 2025 09:51:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764697875; x=1765302675; 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=6aZdi80Fw/yhQHCdjNqAk6626PinK1Z/Zi9xmvaQPrs=; b=QKqxWUS3EQfFd2MP14UFXPIpXBNeinF5//MY4+uRHuYCBNnU9GO/eBtIyd+rhsmadF Ggc2epk1CbCPUbmUGdzxCUFSFb1nDqTp4WJy388doM384N5Y+/K1ORxt9OusnIx45xlr UxzPD60R8VcRm/wXZ7Amwbng3XgPOLqQHec2FRni/msKiD10sl0K9V9lYi7JTRLJBdTg RNwt3zduM34gDnPtkq0sP4FOs+W4a5aTNssEkFS6zcK7QfqGuwLqUfvsDA4Utpm0BP6V dlRhjoBKB21vOklHAZEOAEq4nkwOudvv2LOMiUWlGAtBzugj19npoxRY9FJ8JYCBhLLc ev8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764697875; x=1765302675; 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=6aZdi80Fw/yhQHCdjNqAk6626PinK1Z/Zi9xmvaQPrs=; b=w/IS8tA1q5CPLztkI6aktAmj1JHLujMsAi3lQSTUK54HDFqxXL7trzLiWmzCQiChcX 6GRFfDWn3UvUZdN65PzYqo352CreGo/MExfXjh8XL7xq8LGkuUs2g6UPYayVybaNuvQA irwJtJwqZ19hnifo6/56vJBihSJIluqcwZz3BmyccIZ3uV31ni2D45BViv0Ncgv7b0Uo gUHssFFLZpTUztm4FySjaT6622lK04imCM7YN6AxaDzh2zu5xz4FcnBGrkaWqVcdAMiB n4mfuzmDvXyT/uLd8ToLlVEBAckAgGzn1xRNZpLA+ae0sXlPSAOg6VX4X/AFyhphauqc 655w== X-Forwarded-Encrypted: i=1; AJvYcCU3Rxt8orjXPYeefZ3pxoZtoqUAHzJM9bbABsh73us8yTI62avKbGzdjXNtLTZrrQIcA3O2ppCE0acGLfo=@vger.kernel.org X-Gm-Message-State: AOJu0Yz7miaUVwX/vgmX4tlwEXvm1N3dEnM7Ab1izczEgZA91piGcMws hCChwf1FmgX+oMttuZZ/XSLtQXMWr6HZmKxaKmthBjIjDJ6Ip2VSRGiyN+wAg5y1vtlv3rn0oZr HgxByEB3lOg== X-Google-Smtp-Source: AGHT+IHQ3drzwVFWP9Rr4fIeRTF6kB1LO25LBjckRv84mcshBe+KzpJd8FyPPHJt4tRinWRy6ElTcBm0c6S3 X-Received: from dycsa11.prod.google.com ([2002:a05:7301:10cb:b0:2a7:2596:88c5]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:3c15:b0:2a4:3592:cf79 with SMTP id 5a478bee46e88-2a94189a935mr23692758eec.29.1764697875166; Tue, 02 Dec 2025 09:51:15 -0800 (PST) Date: Tue, 2 Dec 2025 09:49:59 -0800 In-Reply-To: <20251202175043.623597-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: <20251202175043.623597-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.158.g65b55ccf14-goog Message-ID: <20251202175043.623597-5-irogers@google.com> Subject: [PATCH v9 04/48] perf jevents: Update metric constraint support 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" Previous metric constraints were binary, either none or don't group when the NMI watchdog is present. Update to match the definitions in 'enum metric_event_groups' in pmu-events.h. Signed-off-by: Ian Rogers Tested-by: Thomas Falcon --- tools/perf/pmu-events/metric.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric= .py index 92acd89ed97a..8a718dd4b1fe 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -4,8 +4,14 @@ import ast import decimal import json import re +from enum import Enum from typing import Dict, List, Optional, Set, Tuple, Union =20 +class MetricConstraint(Enum): + GROUPED_EVENTS =3D 0 + NO_GROUP_EVENTS =3D 1 + NO_GROUP_EVENTS_NMI =3D 2 + NO_GROUP_EVENTS_SMT =3D 3 =20 class Expression: """Abstract base class of elements in a metric expression.""" @@ -423,14 +429,14 @@ class Metric: groups: Set[str] expr: Expression scale_unit: str - constraint: bool + constraint: MetricConstraint =20 def __init__(self, name: str, description: str, expr: Expression, scale_unit: str, - constraint: bool =3D False): + constraint: MetricConstraint =3D MetricConstraint.GROUPED_E= VENTS): self.name =3D name self.description =3D description self.expr =3D expr.Simplify() @@ -464,8 +470,8 @@ class Metric: 'MetricExpr': self.expr.ToPerfJson(), 'ScaleUnit': self.scale_unit } - if self.constraint: - result['MetricConstraint'] =3D 'NO_NMI_WATCHDOG' + if self.constraint !=3D MetricConstraint.GROUPED_EVENTS: + result['MetricConstraint'] =3D self.constraint.name =20 return result =20 --=20 2.52.0.158.g65b55ccf14-goog