From patchwork Sat Mar 2 00:59:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209155 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp247761dyc; Fri, 1 Mar 2024 17:00:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVQBXAQk92arojzarTAxYLbBkfmoN0EXPFqSGQ6NVfq78IARgmiL2tlMNhLOwjw2CaUmaONUsMDSCtptwxWjvMwpvmxdQ== X-Google-Smtp-Source: AGHT+IHbMvzLR+AXNp9iGK5wQF2xMV8TkjMSiMTBhJYM2owlwo1SWwvLo0Qbwq04IB81Y4VHzs78 X-Received: by 2002:a17:906:a404:b0:a3f:cd6b:80fd with SMTP id l4-20020a170906a40400b00a3fcd6b80fdmr2653111ejz.7.1709341248709; Fri, 01 Mar 2024 17:00:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341248; cv=pass; d=google.com; s=arc-20160816; b=KoeOwLTRu/IbL2EygggNsgb/mKqA1n1/qC7qt9c6J7EI4mUYExwnzDz+Wfv9Xj0vVW nEsIB3tQA3FTgCyqNVbjCJ+Qpfn+jWX1zLZPiWW6LjRckkSisZv5xKmaTHC5DzMRbufX 2rnlkB1CkQuJ1TSUT2Fi2wsXGj6V5un3CdiMCoZW0x7ReOEcGHVZl9Pv0Vtb7PQsYdYp bgvLeIhp1m28vH5ldYPNCt5EniteIiZH5KgI7831Wt6+jaI0l+4H3kA2+AwyYcA0bCLu IRGrKUgoFx1DDAQhaeYafHq/kJ5QRYbi6NzdB6y8AS8XIafEMEqVh0k7ldqWIfCNcEdL UB0Q== 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=KxFo9HXrMBHPfRGQr1WhtYDEqITe1Fw0obEsjgP5vwk=; fh=RKhnVfKIBOQliE8+phZT4a0jWwfr3Q2yN9YRmZliIGE=; b=WqoeBWdcnMiIFJ6YvDh8+PPsAPkjAvzjtPgJs80dKw96ZhIatXxXfI5hQ7w4a34H/K KQ6htgQ9FDbgiA6hxxAE0wdo572SJKwyv6u4R6T/32hhp8W0fTi/8gwl8Ra9owsY0Nst 8weQdeUcFKUojTqyHdn82RJPY5KDbNJQoBkYtl5N57EbFvRwC4jHXDAQCjSv2rQOHICb pq+wUyOgqxS4ethw/bsKU05cerCqApbnk2KwBGJ+Vyltmu98VQfJA74o9uuYJzwD4anD luoaF/ikT4PBQyUZxsRnt7nm7aBOeJxuO2n9JaTGH6v9qiYeK+xmDvQZb7LE0cYmccTT IP9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=AFk8W1dH; 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-89276-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89276-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 s8-20020a170906354800b00a441a40c035si1872379eja.279.2024.03.01.17.00.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:00:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89276-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=AFk8W1dH; 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-89276-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89276-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 559FA1F23ACF for ; Sat, 2 Mar 2024 01:00:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03991101F7; Sat, 2 Mar 2024 01:00:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AFk8W1dH" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.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 926B25CA1 for ; Sat, 2 Mar 2024 01:00:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341205; cv=none; b=MjSeVe2uHrCmOok3zwfMP8tkOue8Q1x4y2DLCOwANhpZARmrdC2cYyeioqV6uaodKE7nOkowPoMWsEESV1IIupBIhDQLYDKhXSyt62AI2wTwPDlZXV6v3rnGPtE6ITRR+ptej4wOePU4ffTQ9rMe+JhH/dy6GpAdFd4j9Z9tDUE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341205; c=relaxed/simple; bh=hLfRLYYEBDGHVllbq1W2MRKFt2uEVseZ3ckqP7HQcJs=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=CIgsCuCFekDqrEB4qp4fXEDQ15wc+pBDqFD6nSrqQE6U7LRjKJIoIVQnkapd03y7rRwbYNUEclBoQFlkFdSSXTt4PjKc/YBui2W0RYKDbEvba1ZQwZyXUvSOTEZB+bAt8bWWM1hcAbbDf2mKx9wvVzsKd5xRWboiGBEGRaQI/wA= 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=AFk8W1dH; arc=none smtp.client-ip=209.85.219.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-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6dbdcfd39so5227213276.2 for ; Fri, 01 Mar 2024 17:00:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341203; x=1709946003; 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=KxFo9HXrMBHPfRGQr1WhtYDEqITe1Fw0obEsjgP5vwk=; b=AFk8W1dHLucI1lzV9klBxz+8G+cQ/sXQjH2CxBpRsZQwpR38Ri68XuEv5uSefbaDDv 9PusemxFaGn+WxpkCXDjwhcrLlrA7+lXHeOJLdsLFWohYIJo2Ao1mbK6YztCF8NeuR1P 9wibUWh2mP6xD94pZ8fVzbhpG+bBkgCEudKC3epFPaAXvOtYAYUBt+Jr6Dn5/Uz3WNPg ESSkDfNL4qPCNvJPZPwPFBFW/A2HAznQvxis7ROGx2CAcREa2h8pPMZEMcKaN6qK6S8N DegiEgPqYqmzNZOMuldmg3Ci2iNzN6QcsRleOYlKEuGM3/Yy97nKFR7NWXP5YIqppC2u EzuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341203; x=1709946003; 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=KxFo9HXrMBHPfRGQr1WhtYDEqITe1Fw0obEsjgP5vwk=; b=gld+wDFPDGfVEQ3fPcp4SxKSKujrMtIAnf1+S3utd4NufjUEdS00kYXzMB5nS12ezp xzjDqzo/4osYJlj1jKpBszHJ4wAPF+V79eukRZpDiYCoE8NmvovDeuukrk4oe0kE4xRP j4OSARCwSDsN6BqSy/gojVZJHgIuMqf2Fdb+tx9QnsrOVGe3uJEnNe1Uvs9ly/inoSBi UHSn3B0uSdSqwzRXPTVKXCC0TppyBtwc7QaCgs2gwvdZiiekOAlJ1p35zIAp8cx0EBFu HpW+uahT57UAdQbkeACyXOztAyxYqUQyjVbQsulWAGtB3uGGjEka4d6bG/lYA6MY6PdW +pgw== X-Forwarded-Encrypted: i=1; AJvYcCX8jNnTt7zz8LFTblqn7BeDEbRsseN20e6g9BFTqOXCUSV01fUYgzBWfAZ3DNRSBQ0P3nCz9GPDGqCJuznGp8dkSZODiUw8VqGyBhUm X-Gm-Message-State: AOJu0YyR+56u/dJpQflA47iJicFW9Uy8md9ddrsC/5SgiAAj5/W/lHhX lajYZJpSwEqrEBIEB4aVPvkwAMY05PxI/JOEgbFymtySMbVY+5p+CngWaltSPfY6ZZDEerWheyx TnZZLTA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a05:6902:100a:b0:dc7:5aad:8965 with SMTP id w10-20020a056902100a00b00dc75aad8965mr766000ybt.0.1709341202870; Fri, 01 Mar 2024 17:00:02 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:40 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-3-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 02/12] perf jevents: Update metric constraint support 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: 1792374209325575754 X-GMAIL-MSGID: 1792374209325575754 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 --- 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 +class MetricConstraint(Enum): + GROUPED_EVENTS = 0 + NO_GROUP_EVENTS = 1 + NO_GROUP_EVENTS_NMI = 2 + NO_GROUP_EVENTS_SMT = 3 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 def __init__(self, name: str, description: str, expr: Expression, scale_unit: str, - constraint: bool = False): + constraint: MetricConstraint = MetricConstraint.GROUPED_EVENTS): self.name = name self.description = description self.expr = expr.Simplify() @@ -464,8 +470,8 @@ class Metric: 'MetricExpr': self.expr.ToPerfJson(), 'ScaleUnit': self.scale_unit } - if self.constraint: - result['MetricConstraint'] = 'NO_NMI_WATCHDOG' + if self.constraint != MetricConstraint.GROUPED_EVENTS: + result['MetricConstraint'] = self.constraint.name return result