From patchwork Sat Mar 2 00:59:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209160 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp248441dyc; Fri, 1 Mar 2024 17:01:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+qe7fp9BuybUH2BLEgtQvxQWG49FMrAbratHcu4wVk2fR0uZDTlsVw3hq+lafGMDXyUCW/FhDgl1MLRnjDJC/sJg4Uw== X-Google-Smtp-Source: AGHT+IG9TINv1PQSt0S01xH5B4FlN0xRBVekdnmcujMK7GpnkKHN19WihL16g/VX8s75NCwxzZA8 X-Received: by 2002:a17:906:dfc4:b0:a44:c29c:67e4 with SMTP id jt4-20020a170906dfc400b00a44c29c67e4mr792030ejc.70.1709341318255; Fri, 01 Mar 2024 17:01:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341318; cv=pass; d=google.com; s=arc-20160816; b=DDjiA68MTaK/nTZmJU58NugAwHf2lUcJAEdzXmdfL8mYmQZlhKJVikgxigNtPyeYr9 w6gIoZYQeXh5JQ8xGfVEQ1YH++jbN8MSlFYLiJ1ivxd9u9F27aylAKD/XDhkbCYrm5O3 EVP2YekLkCZd8ZPaBhw0ZBU+66D/P0JPx0b6F/wn5eSZcayXyWlsuVJFtwb8d7mXQOv3 LIC6MVaszbjaZ3jtR/3RY8/Jwh0JCoxhOiNJ0OvIDEdBrk+FyvTclRXevC/HTdmGZcqR AfE8hIpUTttDnsx3Oq8SYeM1CTmDHtl3tk9M9E+2EvTfrPeKWNzfTl4kV0NUZ9DaHaXa cLlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=/C1Fptl7F9oJgqV/SnZtPnw4T5ATAHSmXZQvuFpHbZA=; fh=GZQBeunE0+aJePW4qYG6U4AUJN90Cjx23KL/iMgmAzg=; b=XFwUGVYUz5eN7TEEZ6nqqcYX48Ms6qdVK95ZJo9lq3UzIFVU3ox8PJiTwA1aECS+AP bpqvcI/NiGNtR7F72vc9j/HMpgg1Tnvv+sidhD1lO6fVxJAcqcTi4u/ndbaDLglu86v1 zyWw36FYOwn6UDWUkMsXz9/7akYdEl8TMZ0mWt+svmV0SO1imp9VFUF1K11+Hwnu/2H6 JoYJOkLijTdeZ7TFG5zu+frTonZrzzV6iOdEXHZbusXt1fgJv2l7NunrnkFtrdpB4eeK eBkSuLIplygA8xZeZRlX8mMhm5M8/l23ghckjhTvO742+VzsanSK+D+H45QlC8mllQ5j Wepw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qI0xfJRj; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89281-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89281-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qx6-20020a170906fcc600b00a43db2e1acbsi1891193ejb.351.2024.03.01.17.01.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:01:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89281-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qI0xfJRj; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89281-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89281-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DC7C01F23C42 for ; Sat, 2 Mar 2024 01:01:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E2A8E10E3; Sat, 2 Mar 2024 01:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qI0xfJRj" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 8B493F9D3 for ; Sat, 2 Mar 2024 01:00:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341217; cv=none; b=ntCn4NnCAO7SRjxPgIKaHNJCdeqad5nb0h3CW+4cPLQcLjQz54XZ+Nkld37g/b/v6UT8IbT1Ls/i0OMmEDiEppMM/wOOUX1AtOELzKML8CJoQBnoPFqpR4QZbvyO2KDKPOO2Ox2XYiw8fuAoUUMAH3yGp3rkcUCEweyRn63tJR4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341217; c=relaxed/simple; bh=ZXVWxGkn7pnCvmd8l6DV72SPICzKi/Gva//TpBe7PFE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=ZnO/0o83EW72tsbaATHd3gCryuW2TygE9X9hmf2RGBM65FuxknEoG7K4fqdoQ01H6fMYsPSwBDFiXWx3UITKKsMu5pObZ7+JdDmj1MOx6feBK9JUrZuUto3tZUki3hq/BYirrFmZWbMLATZgLzqlAeKly5qpYiPP1EYR7kp/V4Q= 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=qI0xfJRj; arc=none smtp.client-ip=209.85.128.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 Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6098d88e994so11526647b3.0 for ; Fri, 01 Mar 2024 17:00:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341214; x=1709946014; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=/C1Fptl7F9oJgqV/SnZtPnw4T5ATAHSmXZQvuFpHbZA=; b=qI0xfJRjpEdE3s+OWFK/wud9k0lVmfMm3Y19P85FmaYk2SVEokv8w2UtiFTB0o479D gyRES8/ofoCKLPMJkk6sR9qQConnJNRRkLTOBs59Y2MsUQ1StCcM5RpJKkl7S70jyPro DcZUhNWiMF47sQDGMFeXWnTHSesrnIKonsJecsfa97D84lPCmZJgs5X0jVLAv33koySJ jUg087JU2ftUyI3R4y2lRfeHJkULZARZvFz3Zaa6wiPv8ppAceeQBSmhPAx8hb2Z6Zej ZXC8ikBoy+eks3S/cM5fxOmp78Deo0ZMPReQFXWQmeOIECpoOmH8jsEf6VUX0EAgIln7 DS8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341214; x=1709946014; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/C1Fptl7F9oJgqV/SnZtPnw4T5ATAHSmXZQvuFpHbZA=; b=H9kbs794hu/cH/KP/VgBzPJpKGzVlrnTSHQ/2hRs9PdekpEk/MvrOq0IvDRFsK9D7r 7JQ/T+2gmka7pVOObl9uwAxgD4cCK2jB74xlQIKT1pvAelx/dxA2GU9oP9AIt3+UxEWI UkB1R+IDCS0vWcmF8T6oJx6MB2kUlD5RTEgH4/gYOMaRWpvn3xVPGo+3GKu8D6pkp+LU h+ToTy7u66UtBoYY0SfM2LXIRYNyTxQ1cshdlXt7ZdU6aUwPgRisMFUFgn0mhBcsGGCr 7wHJBxgNMzoJU7KVUVHJfjORl1KJck+b7kxi1e9ky8u+EKrYoEpUrCcv4B9EjHgTwBGf ToTg== X-Forwarded-Encrypted: i=1; AJvYcCVuX31xCLSmwdgX0KA5WzjAQQVSma1R65j2n3fB4z429f+7nAZEJzxdd26Di1xlfklgh1xRrV/eX3wO1JnQGYbT6aiH7sVaBT05ZmP+ X-Gm-Message-State: AOJu0Yy7uvmklWiTRUQ0aRW9Ksr8qcvZBoo3FUUb3KYKcv3qiMoxRpEf 11yauFhHda4TLF2JNSww642H/bP6aDH9H2qB5qopIkqry1gbX30+KZ0sFqwyd8y5ypVDN93l57l s1GYZmw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a05:6902:210b:b0:dcc:50ca:e153 with SMTP id dk11-20020a056902210b00b00dcc50cae153mr766214ybb.7.1709341214783; Fri, 01 Mar 2024 17:00:14 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:45 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-8-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 07/12] perf jevents: Add threshold expressions to Metric From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andi Kleen , Kajol Jain , Sandipan Das , Ravi Bangoria , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792374282114521386 X-GMAIL-MSGID: 1792374282114521386 Allow threshold expressions for metrics to be generated. Signed-off-by: Ian Rogers --- 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] def __init__(self, name: str, description: str, expr: Expression, scale_unit: str, - constraint: MetricConstraint = MetricConstraint.GROUPED_EVENTS): + constraint: MetricConstraint = MetricConstraint.GROUPED_EVENTS, + threshold: Optional[Expression] = None): self.name = name self.description = description self.expr = expr.Simplify() @@ -447,6 +449,7 @@ class Metric: else: self.scale_unit = f'1{scale_unit}' self.constraint = constraint + self.threshold = threshold self.groups = set() def __lt__(self, other): @@ -473,6 +476,8 @@ class Metric: } if self.constraint != MetricConstraint.GROUPED_EVENTS: result['MetricConstraint'] = self.constraint.name + if self.threshold: + result['MetricThreshold'] = self.threshold.ToPerfJson() return result