From nobody Wed Dec 10 21:11:58 2025 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.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 1AEDF2D192B for ; Tue, 2 Dec 2025 17:51:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764697906; cv=none; b=N2TxRqOABsatVmryF5kmixiOMxpd5AOOT0B3MHghWz9WAS/saEJYCzQbm1WsI3QwNIZw8g0MW8T8TMq82fV26TD2Zdyki9IljV6H8v+7yTtD0LCB836vWR+xw6TV5CotQAM8iP2g7dM8D6r1zyDLU8+WYkbHUPplSGviNNveBKQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764697906; c=relaxed/simple; bh=BP5K1yNmV+fzvwoM7+qXdRZARDVkRPG6KnFEWZqwj8M=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=RKerWsGEHha1CD10Rn0NtbrOCfVaQkZlZyGwEslWBCe/XUVwhTUcS4C3WJHy4kR317LlFZ282LaVV2u7UjgGb6qsynXIs4O0euiHgDSMI8JlrD8su6bUULmzlU07UXEof7J+tiua83S1C21pYkXUue0vjJCYVT9QXzy4PWq3U78= 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=ED9vMH5Y; arc=none smtp.client-ip=209.85.210.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="ED9vMH5Y" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-7b82c2c2ca2so8784629b3a.1 for ; Tue, 02 Dec 2025 09:51:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764697904; x=1765302704; 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=MIeUnJ76mKBdAthG0dR8rS5beZM54LxeWcR6Dr60V84=; b=ED9vMH5YQ+mO61r436I57XXM53OrvePH6qY/X4CREaeRcq0QfXjKmpqLjKaS6mpsTT RP1C7BJb7UwN/+ESMdnZs53vGkI9caLHdrofy/2+Wwdq63vj6iTlQTKgWmi3r3vQLhdq CqKbApSjbLMHopDMSeO117UoccJmuOWOcyeEjSUuhlLc8nBGA+tkO/GTD7SdcUDheD44 pgreP5xaEdXTVcHsEyv/OHaORR1nBnt/jtnrwzvGTTqJpz2FNzdHFyY2ym1JMHMbLloj f50Ia9v/lxAe0J6EwB6ajwhIZwQkONjMbw/rsisnFhiDZEnphgKBOqWtue/wfndHTAqc l8NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764697904; x=1765302704; 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=MIeUnJ76mKBdAthG0dR8rS5beZM54LxeWcR6Dr60V84=; b=qZViLeraNDzT1BAwuqwLm0ENAU5/SmvBHFcUr6OOrh5TWROYKulJS6PvvFjhwDn33V CEQ7IyW049wgf/2Jx6IAokq3oT9Ee8su99x3jk3k+XjHoe+fy50DStiibP98XN+63If8 n7KEHJSWOBVu1pUbAMFc3dpwWb51IyCM/+3/PUmtR/Ie3DEqSW1I1I+OQHenQFKk24gx w5Z/qya7r7+ONftPmJssarG1M+888Z5BiLDXUStwPZejMA2/pQYRJu2t2xHH8rqI1ErK OfbGmOxoP6rbUTLzMyEWuh7ONTkAJ5sT/wdxL/kwMdUJNl0PAJHNJFIQC5P4WnqJStr3 OSag== X-Forwarded-Encrypted: i=1; AJvYcCVVOmZUda5tpIxNxav6TH3Q186Ve05VVN69JkYnYQISfiTLG3MlLMeVbYCJGHoilIJbNACwJPf5XgnSTZg=@vger.kernel.org X-Gm-Message-State: AOJu0YxcFg7QBpuE6xTIRcS/vNhMI7YlcLfZyo9zJ4OcdsenyQM9hC8C WUbOoAkNg+y/09uSrzLqB04bolYbXBsm4xTeVgo29DvSKbSTGPK45TRgv5iHSH0DArFAy1r2ciC ZzUsDJbB1dQ== X-Google-Smtp-Source: AGHT+IHvb1qeaxiTG81I4noZ/gle4HLUSIqMbbC+FqzFhdsIxKzhepumNWxOHgHA+a0wGz5hw9lu4ub+cam7 X-Received: from pfblg22.prod.google.com ([2002:a05:6a00:7096:b0:7dd:8bba:63a0]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:3291:b0:35f:aa1b:bbfb with SMTP id adf61e73a8af0-363f3a15315mr440587637.50.1764697904358; Tue, 02 Dec 2025 09:51:44 -0800 (PST) Date: Tue, 2 Dec 2025 09:50:04 -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-10-irogers@google.com> Subject: [PATCH v9 09/48] perf jevents: Add threshold expressions to Metric 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" Allow threshold expressions for metrics to be generated. Signed-off-by: Ian Rogers Tested-by: Thomas Falcon --- tools/perf/pmu-events/metric.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric= .py index 0f4e67e5cfea..e81fed2e29b5 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -430,13 +430,15 @@ class Metric: expr: Expression scale_unit: str constraint: MetricConstraint + threshold: Optional[Expression] =20 def __init__(self, name: str, description: str, expr: Expression, scale_unit: str, - constraint: MetricConstraint =3D MetricConstraint.GROUPED_E= VENTS): + constraint: MetricConstraint =3D MetricConstraint.GROUPED_E= VENTS, + threshold: Optional[Expression] =3D None): self.name =3D name self.description =3D description self.expr =3D expr.Simplify() @@ -447,6 +449,7 @@ class Metric: else: self.scale_unit =3D f'1{scale_unit}' self.constraint =3D constraint + self.threshold =3D threshold self.groups =3D set() =20 def __lt__(self, other): @@ -473,6 +476,8 @@ class Metric: } if self.constraint !=3D MetricConstraint.GROUPED_EVENTS: result['MetricConstraint'] =3D self.constraint.name + if self.threshold: + result['MetricThreshold'] =3D self.threshold.ToPerfJson() =20 return result =20 --=20 2.52.0.158.g65b55ccf14-goog