From nobody Mon Feb 9 05:40:08 2026 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (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 ABC2B32D0FD for ; Thu, 8 Jan 2026 19:11:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767899516; cv=none; b=Q4tH/6kX8Q5QqFthWYfgg3bFtzqbNQcFUyrGhhygKCKdDfLCrHNC7705MCqx3gEAWIgFfgwQrywwC3QprhGcPSySSo7kRusTC+ftRqi+PshsPRzUt3MSiNBvUszDCk3KrCl0P69w7WzbAVp7lf1BURTaWRYq1OEfVGYpS1nMYbw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767899516; c=relaxed/simple; bh=4YZdNHoD4OVwl+Z+UboY1dxnW9GaDyHi2p47czxKHP8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=TeQLpPtE08+ddQtohpWSyahQ0OYKZOMyF5OEmizvGVUIs8kozvbs9vh3rB1+aZvLE9R9rZ6UJT2wzTcmmEuAiGYLTftljREv38TzxA7lLoI93BUBJk8H8F4kcr/zCr7PqJU54MYwd4EcjGBHAs2zBNmK3wHAzDnGdX+jCfRjrKw= 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=ZGTvF5Yh; arc=none smtp.client-ip=74.125.82.73 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="ZGTvF5Yh" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-1219f27037fso13559135c88.1 for ; Thu, 08 Jan 2026 11:11:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1767899509; x=1768504309; 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=Ml2Rrb34ZIoAiVgzhWpgKhiTIZVKvjCF+KWI69P37pc=; b=ZGTvF5YhduVU4Gis7/cljVJ2pQGGHoiNFofLNEfaOtCRs6c6wrDq9zE8tXm++fXQCZ p5w52CcKmF8oh/LJPKni0aA01M69OLlC/TBaqp3+kULmdcQMHaoa+UYjC390iJpc5xZ6 pmWnedvNWnwQHKH4VY6rXES2vI9BYoCc9dQx03zChbQqsFjEfmaP6yH7QIDa+3U28FUk DkN5WTdHIbtAxO8Y9pvspVzmMqL9s92KNQ6rDslDKJrbIhrSEs4fsi41/VESm8KKFKgb N6AaisrsxGXsBbEnkoIF3ywawax5/hRDB1ZBveGz/ykolr3nTH4bSdrrNSGISj/x82l7 WC/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767899509; x=1768504309; 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=Ml2Rrb34ZIoAiVgzhWpgKhiTIZVKvjCF+KWI69P37pc=; b=Ctmchzn/WOaFIQ7y0v8JkqQJ3ObvF0kykjmRyfYcMRKpjW3iIYb3La5dpoWhCEGIHi 7Fyu/oRbJHNZCYDy/B+i50GKmCRx5Hp+zUknOB6fKduVNgzT9PfS1XVMJ9JdROjZvdkj lT3TFbm0gxoE+aa0EjXDAFjm+RxkjYjRHTvKGK4fQGP35uUtoGjP3yIJOfeW+gEWejyS ce2IxshWxMykY3STPZdHh9Idu4IUHpjidHW8n1sGNpQTMT5UFy4MQp7lkfv3ulBoHpw6 s2kvnt386x1vHyPzrc0JUBBk5SsxdsJ1PRKP8WCgAt5Nx/o7ADK/VcfVB2YlXHgIMtRv bBZQ== X-Forwarded-Encrypted: i=1; AJvYcCXp7OBmV43u8IbbA+Nq7tTE1CdbrpMdbyyTjaziM0cSLDqJf6Xxgc3vgP1K9QrahQjlYJrdzseugARcZW4=@vger.kernel.org X-Gm-Message-State: AOJu0YxLEWY2uGg51EN7Gi5Qglz/MQmBA+6KyzPqGwuJaRgKTQCthsU4 D5mD4wCaf13Uv3+znjH1QDGfkx2oyM2euXTWcILoSEIC40bzkNSkQokmM8ghHql13kVTtm/VUfd MBEJ0mFLS3g== X-Google-Smtp-Source: AGHT+IHoiPGHBovETyUcjQ2WmUMUU3CaN+Uazo3cs7yqtLWEn8FJr6Btj82A1YTfCuiVTgb+PwR3cXLrlNJU X-Received: from dycaj16.prod.google.com ([2002:a05:7300:fb90:b0:2a4:7a56:1730]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:2215:b0:11b:9386:7ed1 with SMTP id a92af1059eb24-121f8b72712mr4738901c88.46.1767899509296; Thu, 08 Jan 2026 11:11:49 -0800 (PST) Date: Thu, 8 Jan 2026 11:10:42 -0800 In-Reply-To: <20260108191105.695131-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: <20260108191105.695131-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260108191105.695131-13-irogers@google.com> Subject: [PATCH v10 12/35] perf jevents: Add RAPL metrics for all Intel models 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" Add a 'cpu_power' metric group that computes the power consumption from RAPL events if they are present. Tested-by: Thomas Falcon Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 44 ++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events= /intel_metrics.py index b287ef115193..61778deedfff 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -1,12 +1,48 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) import argparse +import math import os -from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, L= oadEvents, - MetricGroup) +from metric import (d_ratio, has_event, Event, JsonEncodeMetric, JsonEncod= eMetricGroupDescriptions, + LoadEvents, Metric, MetricGroup, Select) =20 # Global command line arguments. _args =3D None +interval_sec =3D Event("duration_time") + + +def Rapl() -> MetricGroup: + """Processor power consumption estimate. + + Use events from the running average power limit (RAPL) driver. + """ + # Watts =3D joules/second + pkg =3D Event("power/energy\\-pkg/") + cond_pkg =3D Select(pkg, has_event(pkg), math.nan) + cores =3D Event("power/energy\\-cores/") + cond_cores =3D Select(cores, has_event(cores), math.nan) + ram =3D Event("power/energy\\-ram/") + cond_ram =3D Select(ram, has_event(ram), math.nan) + gpu =3D Event("power/energy\\-gpu/") + cond_gpu =3D Select(gpu, has_event(gpu), math.nan) + psys =3D Event("power/energy\\-psys/") + cond_psys =3D Select(psys, has_event(psys), math.nan) + scale =3D 2.3283064365386962890625e-10 + metrics =3D [ + Metric("lpm_cpu_power_pkg", "", + d_ratio(cond_pkg * scale, interval_sec), "Watts"), + Metric("lpm_cpu_power_cores", "", + d_ratio(cond_cores * scale, interval_sec), "Watts"), + Metric("lpm_cpu_power_ram", "", + d_ratio(cond_ram * scale, interval_sec), "Watts"), + Metric("lpm_cpu_power_gpu", "", + d_ratio(cond_gpu * scale, interval_sec), "Watts"), + Metric("lpm_cpu_power_psys", "", + d_ratio(cond_psys * scale, interval_sec), "Watts"), + ] + + return MetricGroup("lpm_cpu_power", metrics, + description=3D"Running Average Power Limit (RAPL) p= ower consumption estimates") =20 =20 def main() -> None: @@ -33,7 +69,9 @@ def main() -> None: directory =3D f"{_args.events_path}/x86/{_args.model}/" LoadEvents(directory) =20 - all_metrics =3D MetricGroup("", []) + all_metrics =3D MetricGroup("", [ + Rapl(), + ]) =20 if _args.metricgroups: print(JsonEncodeMetricGroupDescriptions(all_metrics)) --=20 2.52.0.457.g6b5491de43-goog