From nobody Thu Dec 11 19:08:05 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 5792D2D4B5A for ; Tue, 2 Dec 2025 17:53:18 +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=1764697999; cv=none; b=SErnUMUWZgdSMAKRElbPnXcucP3qipoCtIzHsMy/Fe0wWv4LGILylyD7kSk6c5VMwWk8+Si7PRQy1HkWw8u/4TagXaCOyARCM/+JuYviiZn/CmxyifEtoNouRyQCz41KGKZawzUSlGgHDDf2bxMz0CykED7XmBrGc4m8MzBlwE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764697999; c=relaxed/simple; bh=0DvT/kiE3vDrT5HO98Kd9HGHFwaVslnLeu4gouFC/WU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=dO7enLHT7ABzTs3c8tlgfBbpAQIUALU4iaMCXA4m0wrlQ5DeZ6csupkz1QvwqC0PXB4Px4HKlwaeUfJFK22Qp4MolgLzSVrXq3TzpLJDM4kldL1deiiTezGTFLMLGC0zRSsN3isRigjApI9un9UU2c2qA18UPO/MujL7JAaqez4= 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=1JBoHo6O; 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="1JBoHo6O" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-b98e6ff908aso12794854a12.2 for ; Tue, 02 Dec 2025 09:53:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764697998; x=1765302798; 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=XkviML1WbWjNToyw1Pdo6Gg+vsZfxTwblnh9KfvYqw4=; b=1JBoHo6O9+oMe/ARGxUBOAVQ3JUIVnh10oTcAVR7Nem9tJdsz/WDYXqUXww/ubB0+K DhZTYq4qRAq1QASEcA5d7Zv2B0hrzmoMK5867UjAJ4kM8tiYhbiFYOJndbUgaEEBFWDW t8cg58JCPKeYvLsP1qrpP8/Ip/omp2GOFU2c/0wS/trSUUR6QWEburfqWtihiG6kRLvd GehSXiOubvLdo9RshfdnCFHg+qErLpz6ABDyhLLSMKOIj6sscc18mGUhf86JaSfL+P8o T2/4KKllVJFR5Q3FssCo9dfWkAAMk+vSUsjJ5vpo44San6oCKHbGZdL4uEQQgoE7CodY WfHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764697998; x=1765302798; 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=XkviML1WbWjNToyw1Pdo6Gg+vsZfxTwblnh9KfvYqw4=; b=aWwx2QxboO2MK6oIq0rJ3xRPxuRH8p0kPP5XzNOewjD30iYucRzB40vo36DZ+cAHWB LVvAJLNXQ1Z4Y9bQ0HNCjQuQfobagn4EFcdhxlUPpUxf+6omhqeaogC/WA8+Go1tbHos 3PE2ckmu6dGZQPMJ6sTi6FgiRxUqu/K9yd2CknGs5sUkOc1QSVl71gXcY8UiVQVnz/7o cvHxw3Px9c9wZetWAJv+JTGnf/q6nTtIaE6BkezRS7fcmm4G5ilnRgmIhe9x/pCoDsr8 GQINXBLRc1zhxD4SYhFLiU+4RptaT+AfIS3BS8hLs2xEYpc9OHQVpzBB5JluOvlxf5Ie vlPA== X-Forwarded-Encrypted: i=1; AJvYcCXmJ4eAv+xUWQ54O5GgMrcV0cdYmQiqKAyIeXCzPlRtcdmDKHcPlBdHIDby4XtLznQK6019xla6WDq5bMU=@vger.kernel.org X-Gm-Message-State: AOJu0YymFeDQ/0qDWsD33xqJIn6ZsSWZkLyjliv60rXFah8MXNfimeae 6OAuIJfDQemEq/vBcWZx+T7AjBuCGZsPT12QaCP9ve/pnzF73cghaODgKds2Ki0LF2c1h3KZpdL y2HNTWq7hDQ== X-Google-Smtp-Source: AGHT+IHooDxEK5JcM/PYoCMjCixu2mwH53pk8hETZAz0niJvf+nPh0Zz8qPLbKKgt0PCgIxZiDzXSuWuD1Ea X-Received: from dybfx7.prod.google.com ([2002:a05:7300:c387:b0:2a4:75c7:9884]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:6424:b0:2a4:3592:cf5c with SMTP id 5a478bee46e88-2a9413be9c5mr17153733eec.0.1764697997595; Tue, 02 Dec 2025 09:53:17 -0800 (PST) Date: Tue, 2 Dec 2025 09:50:21 -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-27-irogers@google.com> Subject: [PATCH v9 26/48] perf jevents: Add CheckPmu to see if a PMU is in loaded json events 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" CheckPmu can be used to determine if hybrid events are present, allowing for hybrid conditional metrics/events/pmus to be premised on the json files rather than hard coded tables. Signed-off-by: Ian Rogers Tested-by: Thomas Falcon --- tools/perf/pmu-events/metric.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric= .py index e33e163b2815..62d1a1e1d458 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -8,10 +8,12 @@ import re from enum import Enum from typing import Dict, List, Optional, Set, Tuple, Union =20 +all_pmus =3D set() all_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 all_events =3D { "context\\-switches", @@ -26,6 +28,8 @@ def LoadEvents(directory: str) -> None: if filename.endswith(".json"): try: for x in json.load(open(f"{directory}/{filename}")): + if "Unit" in x: + all_pmus.add(x["Unit"]) if "EventName" in x: all_events.add(x["EventName"]) elif "ArchStdEvent" in x: @@ -36,6 +40,10 @@ def LoadEvents(directory: str) -> None: pass =20 =20 +def CheckPmu(name: str) -> bool: + return name in all_pmus + + def CheckEvent(name: str) -> bool: """Check the event name exists in the set of all loaded events""" global all_events --=20 2.52.0.158.g65b55ccf14-goog