From nobody Sun Feb 8 20:00:14 2026 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 C610B39AF6 for ; Fri, 1 Mar 2024 18:56:16 +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=1709319378; cv=none; b=KBszHy4O87rUEuC0tfFsAOTrJywBT6iVCAv25MUrtQmLXvLS/Sg3XomRNwSKyAd0sgW7lVo9aV0JwfNlPKbKdMhNgw2RYQax0RxuBFbZ0cgwxMOAs5CT2uMJFYw/QDD8pgrabviJ3l7fHORl+dnMUwsgivEU+/pfAZdY8u0/OFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319378; c=relaxed/simple; bh=eVUKJulxTaDZWA+5YoZDb5UoIVwFCiPRNSmcWb0uoWM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Vd8yGnSn3f1sAoZd0pRnkbFbdy1LsyFRAjC50JP8LiVb/5UYSQjKID5PXCxjIg1mkaL252HrNuJ4zkx3EAA9dF9Q8Q5OtuxGGMK8RQ8VHOsfrcPPeQPR+0btKnDa1jM+sP7PZeh14t81GPh/EM0EUxKvn8qBMziSBkxmyQnv8uI= 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=RzbY4fVJ; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RzbY4fVJ" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-608852fc324so36524647b3.2 for ; Fri, 01 Mar 2024 10:56:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319376; x=1709924176; 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=h3PxAWhsu0Wk1JCVDmtXtAqqbWoqISlhy4eOUAXnDEI=; b=RzbY4fVJ7zUHUvVgAM/nw25wC+77DsGSmfgkChOQLUetdOw/nCv+yAEMMdF/yAt72l nbGePWgeSbzdSSJ73Tzz3OLZI6XNbwMTGXR3z1MS7fsYPovCgfPmWNEEMT+rLdNj4jka nSM9POwdiNaevK3qiVHALU/FMsMJp0DZDd1djusC8vM6xwqAxuv8tdhQlZos6iyRmcmR khjwT6uqvm8ksWtd48NQgRuUgQ7hB385GI/WvWTmhLhkE0jaSfHTGZuz12vachSrsbqc mOoALSkyeROFmJYsRk9Zmm8IEwf9NCxWzEg5QbezZ1ZiuWPR7A8J5j9jdyqKs5kd/TPn oO1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319376; x=1709924176; 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=h3PxAWhsu0Wk1JCVDmtXtAqqbWoqISlhy4eOUAXnDEI=; b=sr5EYUsnnOMN1hysx1ThipjRh41wuKn+Irs/A3LFj4xgxIdUSPq/fOwQspkIjr313e ikYvu9F+4T6BK9DOlFtTdYcEPXtO/pGvBvuZkWNwIIFwKoaqz4P6tc+IBGW2zij45eUW HCcgEO6cwKEBfXFIvAujs5bqqH/NRtX++1ad20eDQUPzhgpOIONOgG3wTpiDz6trxkCc 2HDwLxilu4MNwqO8TqdI7CGbPA9kWYmYVGPDkzg8mX1Lxa+ClNlsKbWeMh7etkQ0KkPE gzLvN9U5opVNgxyCiAxIlFVFvQKv9lSDh1PihO8CFqEH1AVE3ts9oMgG/NoTZ+PkZhv7 //Nw== X-Forwarded-Encrypted: i=1; AJvYcCXboPYJAVSZKc8X5jFa+uW6/IKkad1wnEVYBdRNe8PN0wta4xf9zexwWSR72SiJJxqhMP8Z8Euz9+ItUZYSqOwHjGODKzSWSkXnf4O8 X-Gm-Message-State: AOJu0YyNMwFbhns4oId1DByGz99S7YnIDD0JbFbsTj/rSXa6+mTFuhwA feSqnDbULM0b5eBTS/KkdXRFndPbmHxla38Mt9SqEjBRGBkbPFPJH4QMtNPBOBnBngY/cNqppJB bcE/3Gg== X-Google-Smtp-Source: AGHT+IES9Y1Xr3gfHjAX5zvXMI5CI2HyGaPo5BkbPzzc8IGg72mN9khRsEKwQw260K0Ns0HNNtDGlAvCLrsN X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:6902:724:b0:dcc:5a91:aee9 with SMTP id l4-20020a056902072400b00dcc5a91aee9mr537791ybt.7.1709319375833; Fri, 01 Mar 2024 10:56:15 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:40 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-2-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 01/20] perf jevents: Add RAPL metrics for all Intel models From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian 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. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 45 ++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events= /intel_metrics.py index 4fbb31c9eccd..7704c170a7db 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -1,9 +1,10 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, L= oadEvents, - MetricGroup) +from metric import (d_ratio, has_event, Event, JsonEncodeMetric, JsonEncod= eMetricGroupDescriptions, + LoadEvents, Metric, MetricGroup, Select) import argparse import json +import math import os =20 parser =3D argparse.ArgumentParser(description=3D"Intel perf json generato= r") @@ -14,7 +15,45 @@ args =3D parser.parse_args() directory =3D f"{os.path.dirname(os.path.realpath(__file__))}/arch/x86/{ar= gs.model}/" LoadEvents(directory) =20 -all_metrics =3D MetricGroup("",[]) +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("cpu_power_pkg", "", + d_ratio(cond_pkg * scale, interval_sec), "Watts"), + Metric("cpu_power_cores", "", + d_ratio(cond_cores * scale, interval_sec), "Watts"), + Metric("cpu_power_ram", "", + d_ratio(cond_ram * scale, interval_sec), "Watts"), + Metric("cpu_power_gpu", "", + d_ratio(cond_gpu * scale, interval_sec), "Watts"), + Metric("cpu_power_psys", "", + d_ratio(cond_psys * scale, interval_sec), "Watts"), + ] + + return MetricGroup("cpu_power", metrics, + description=3D"Running Average Power Limit (RAPL) pow= er consumption estimates") + + +all_metrics =3D MetricGroup("", [ + Rapl(), +]) =20 if args.metricgroups: print(JsonEncodeMetricGroupDescriptions(all_metrics)) --=20 2.44.0.278.ge034bb2e1d-goog