From nobody Fri Nov 29 00:47:50 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 B53EF1494AC for ; Thu, 26 Sep 2024 17:41:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372473; cv=none; b=hpXC71mCEc+sxz5V4aTOOzoW/kz1ojA9I9mqcFc1HFZs8goH23ybJA+Xde6PKkTBzP62ETzeZe0jZksSRaAJOs0UdGgA3T71HKdXXyJPq9CWgsoC91GaurHER4ZH23lJLE2yNaMmWNDl3x2zd3r2B7JjPfXteiclbs5ZiupwE0A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372473; c=relaxed/simple; bh=mFTVg8j/2TtNOjQAzKLb7iKFXXB4OcAiF3vc13n5L/U=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=U3TQYsML50aJIBomNUelwDQxga9dw6kn3bTuF55/DKuEHhBoVyavU3ZuQkCL2i/UzKfCREYn36U7v2qNK9t5ROf0ZIn6s99pl9Qq6CbPEHxYhtyc1j47IOvVll4y1f6i/Kl0oWMcA2JnQW7Zq+HQho6jAO4aGxvg8wG3DTmoSB4= 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=VKOGfK3n; arc=none smtp.client-ip=209.85.128.201 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="VKOGfK3n" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e20993a03dso19287567b3.2 for ; Thu, 26 Sep 2024 10:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727372471; x=1727977271; 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=mkBPEGtCIqqpDTU10F4DiWYCLZlPnDuDYEfthWZqk8w=; b=VKOGfK3nbJ7kiHyGDrbvJp4kNLMXgZsMCBtQna0cZUy8GcTuhc3isduvQTxcf9xpbd QJWwXifL+stCW67Y/MunYMH24A31RFuM7ZYr8GTHreyOD0SQWjLf/BJTdF/Tisgd5hgu CPxeqcFo5M7qclPZLYywo+Zr9s4tKxX128JicfFkXWvuhvhj1SJeTJJN5EKd/77V4h52 qxrs8Z/TMykV8VxqYyNW8Q/cYN+RswvBJGgs/29Hja2NSKV+IEbrb6i6+k+/i2ntEeQj WUDrosVJ+4BR7BsS1ekDlkgPTe5ObHWCq869c2tSk4zL5eBPrsVFqrHZ6JN2zgBoK4YS ILuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727372471; x=1727977271; 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=mkBPEGtCIqqpDTU10F4DiWYCLZlPnDuDYEfthWZqk8w=; b=bUs6Eos4+weg/VneqHS5XyJ5gKXQsZlGyESkmW0269Sdnaxu4TvSq6pl21GsROiO4P dR4Wxx9GYy6r61NfvW0uHCdIB4gFyHwc3dBSNWIPYs5f8aH7xeeKNHjRS4dUaG/oBgTN SqkUUR62RWKeQfnPXKNI/rf5u2kzLYlwmbdwVV9+uSx+sSBjxsmLn9K/Vw68Uev9scHs vMq0GzLTFrY5gnd5qTigG2xgka6S8Pp3lRkMLiQ6wd5B3WG0QiH52p2w94ca48YZNC4f NT7I4KAEbAaasu/MJqU4Jmih5M690b4zP8y9mtNVsAPZXWE/ZO8wy72zwk8gqvB5//mR arXg== X-Forwarded-Encrypted: i=1; AJvYcCUciuF8MCSgmy9XpqLGGVNyMBCnoi9436bdcR7HDWN0QqTbgg0ln8Vx45UGck9jNzZ0dBvKDAkLbOE/fbs=@vger.kernel.org X-Gm-Message-State: AOJu0Yy1fqRH9AgDJofVfedFwaKQJpDEOssvELlIFIN06dAb8GUKUorv Xc+trCA5y1ZY4E9nUBajNFbms7PRHsgqE7NrAR71TlHsRikX9MLCCd4pC2K87ZrXNSF9m4y9jdX 9PszNBw== X-Google-Smtp-Source: AGHT+IEsDmssvQzOzmmDQdM5hEeFK3/Hl8Kz/QYxQji/WFLMpyjk+anR4B/fLMlnQmOaBrUNCkDYFubVGPsv X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8872:3585:18ed:a056]) (user=irogers job=sendgmr) by 2002:a05:690c:6892:b0:6db:89f0:b897 with SMTP id 00721157ae682-6e2475a33eemr24147b3.4.1727372470702; Thu, 26 Sep 2024 10:41:10 -0700 (PDT) Date: Thu, 26 Sep 2024 10:40:50 -0700 In-Reply-To: <20240926174101.406874-1-irogers@google.com> Message-Id: <20240926174101.406874-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: <20240926174101.406874-1-irogers@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Subject: [PATCH v4 01/12] perf jevents: Add RAPL event metric for AMD zen models From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Jing Zhang , Sandipan Das , Benjamin Gray , 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 power per second metrics based on RAPL. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 31 +++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/a= md_metrics.py index 4f728e7aae4a..fd420466b999 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -1,14 +1,37 @@ #!/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 # Global command line arguments. _args =3D None =20 +interval_sec =3D Event("duration_time") + +def Rapl() -> MetricGroup: + """Processor socket power consumption estimate. + + Use events from the running average power limit (RAPL) driver. + """ + # Watts =3D joules/second + # Currently only energy-pkg is supported by AMD: + # https://lore.kernel.org/lkml/20220105185659.643355-1-eranian@google.co= m/ + pkg =3D Event("power/energy\-pkg/") + cond_pkg =3D Select(pkg, has_event(pkg), math.nan) + scale =3D 2.3283064365386962890625e-10 + metrics =3D [ + Metric("cpu_power_pkg", "", + d_ratio(cond_pkg * scale, interval_sec), "Watts"), + ] + + return MetricGroup("cpu_power", metrics, + description=3D"Processor socket power consumption est= imates") + + def main() -> None: global _args =20 @@ -31,7 +54,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.46.1.824.gd892dcdcdd-goog