Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp168865rbe; Wed, 28 Feb 2024 16:19:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUUOGcft4tBy983rc0q11WezhW1itZloEblzpuRjDVWOqmthntVnWo3zWwrpVuwZrPqg8edvKGrsNmYKCOV/MsCq2eQPNZq2PVSYyqykQ== X-Google-Smtp-Source: AGHT+IFk/BZdv+q/wL7Y+f2tSjYuwK8f6zV2lhPLs7kIBbNBejLSV+wAANprM60S5Z4RJlREa0zr X-Received: by 2002:a67:f505:0:b0:472:6685:98ee with SMTP id u5-20020a67f505000000b00472668598eemr423462vsn.30.1709165989350; Wed, 28 Feb 2024 16:19:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165989; cv=pass; d=google.com; s=arc-20160816; b=a+BTZA/WP1Nn5K+fzYQvQVUSCw+blSEoihCchOoVN4TNO3/ST0+7JK1VJny1Bd96l7 KSzRJmz7Uni6F/eQvv4kQPKCieUkuE6hIG5zKft/Z4DxXr/+BIoT6E0NyjuqO+rg9JIe anlrjmE+DILWpiSlru3WcOl48CPcfy3X1DtAdXCg8s4/FMwEU2BDWCstOxRZ2dAvedWm RsDEFRpwGQwrjc7BSXuCnCPPo1hLfkEaYc5D8LVBB6rgX1EInRvPP0+hIUm82l/N6gNx 4o7xn2imR3D8IZEpUDxIcjAhlYRxVtHpB2kz/PIZ+Vsino0s40oYCEl/56Qt2ygpVIpy NH2g== 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=BBsfDPoA8IcXye4Tq39UNHv/YJB+B2Yw2JoEeA/NWlM=; fh=aJcnrIKSGG/PLXQ1IWkHxLUJsKwctPRbZFhcmnWV3N8=; b=kLCBgOUjHaJ503cVIVDCewrFRWFY0mMkn+d6x27iWtbrWfg3nxrhxT2sAsVdxv4Oxw 8FGFUrNjtFHPz68KFhT5R8K3xjmEvxK2ih2U8DIX3q8Uz4jAVlMtMF2gF+72jfkrS4Yo H0ssvqOeYYSB68n5v8Nxq6PG8pxjVSJE0aaKjEnISDYJt4sPUe4mvLil/wZfEGOhQVsf b4r3L9htfVN2gBF5/oVw7x3Vf3JLxQHyuG7CBigzxyz1sNdsuj3zqvirE/8KWiDGhKKI ieyJh/2l74lvXbKj4lUT+sppxy9IkO6nL+fcTVmzd3rlLcNNeIWqyA1RJYIYuvNc+fO+ 7jIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ZUShJLpk; 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-85894-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85894-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 21-20020ac85755000000b0042dfa21270bsi315306qtx.605.2024.02.28.16.19.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:19:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85894-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ZUShJLpk; 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-85894-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85894-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1DDAC1C214A2 for ; Thu, 29 Feb 2024 00:19:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A290C2E414; Thu, 29 Feb 2024 00:18:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ZUShJLpk" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.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 59D5D27451 for ; Thu, 29 Feb 2024 00:18:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165910; cv=none; b=hlIjXIZobT3QG8vVTvFuk31PqrjLYAGxe5PlrjvJrbuHclpBST5ftUIgxGa1ihpPxnvVaHzU579FZtY4U7LN2NrHxzBIU0FkqYBg5hCutAGeCUFlX+MgiR3b8wd2NVlP4KgLMYPXY+QirRelKZzNvO38KVnvkSqoJC9nhLNQARI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165910; c=relaxed/simple; bh=0Tn/XKuGhzhLwIG7EDYrZX1pefqdDM+We6EUBnwMtBM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=WUaTUCCXp9BzKvx6ua64EiLAG0JEVmb7T+kOcLfjU6aPeEDMSPSUk2vno/Lgs+eM+lqch9qOu3Y8Yym8UzwybEWfrj2r7BftdQX4DT0yPUxtJDjUckiR5t1MKEoEv2P1/l2D7UQdkT8TtRCK0vK64wVWlB0sfCoAM0kia9n9u2A= 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=ZUShJLpk; arc=none smtp.client-ip=209.85.219.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 Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc64e0fc7c8so527262276.2 for ; Wed, 28 Feb 2024 16:18:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165908; x=1709770708; 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=BBsfDPoA8IcXye4Tq39UNHv/YJB+B2Yw2JoEeA/NWlM=; b=ZUShJLpk5bXaVGv/VL80hXq3ScNmqcPSBo8M3Pzq0EVTXHcNQi3yQ14zS2t+nXTd3M Iydmv/3GZlZYMTbUwgswjrvEWkEVq83AajGQX4eEUUApQkwM76aggmjret/+evsacPKv 72AZJudzeeoxlgyCcfrKJL56oM3CSZdFZHZhHMXsMcS3fD+f9IYTZzPm0R4vIXauYSwf eWcg69kac+KeklqiN1J/lm6zvigElevbYqaJknZVe278xY3dP+Y5afsTDLgz7maAPv02 eCFuzWfHxZXBrp+oHNCnQZZfTWkZtTR1TZjCZ0FnUGd47wfuwAgimIZScYQ2uzcj56t5 +7sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165908; x=1709770708; 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=BBsfDPoA8IcXye4Tq39UNHv/YJB+B2Yw2JoEeA/NWlM=; b=HfBP7GVrHbMmFMruKqkt4otKpSyRn3Zk/44nqrNtUYf9QKHBWsxdneCth8omOfsoYH EEnBddRyGCMaFXjuEDCuDfGbz6DEjAA25e9DcfZvCM7kkdwqcEhZBDrCFrf87umAe53w 6woYROHAYtqp3OxTuQIfgyv8oyjB/gpIlnWmN2MqSNahJqX9PsGEEcbsIXbaOijo3whi WF8AbT7NXPF9M5T+3DD9RO7Ey78GJnmTJ3Ee7SzFtAkrJbB4LUTTE+G5vc09SYr+5747 FZ7L5tR+xkxDaQn4bP/JV2VrsoPohsKGTvf4WGR2Jadv8q5fMuH7auzoR1BugLlcdocv 6QHQ== X-Forwarded-Encrypted: i=1; AJvYcCWvKhEbh59UK5e5F8aABSUnPX4uYXkyvZammpk7P+ds19ZA+qocWzbbnVkHnb0VGW5EeWNqD6TZeRYnavVm3CThFldi/uMw7h06e1jG X-Gm-Message-State: AOJu0YyJIz7LtkAHjw10ytS8vS9GRChwPjkZtpRarJ0mwxsHV9nPc4um rBwg+c0yepRdrgscWddBBwd+bv3xqRScXtfqozyYwF2yIbMlsmksgXhXdeUNvlvn5ov9sTuwShb CcSHq9A== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:1207:b0:dc6:dfd9:d423 with SMTP id s7-20020a056902120700b00dc6dfd9d423mr42833ybu.3.1709165908591; Wed, 28 Feb 2024 16:18:28 -0800 (PST) Date: Wed, 28 Feb 2024 16:17:47 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-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: <20240229001806.4158429-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 02/20] perf jevents: Add idle metric for Intel models From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Andi Kleen , 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, Stephane Eranian Content-Type: text/plain; charset="UTF-8" Compute using the msr PMU the percentage of wallclock cycles where the CPUs are in a low power state. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 5827f555005f..46866a25b166 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -1,7 +1,8 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -from metric import (d_ratio, has_event, Event, JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, - LoadEvents, Metric, MetricGroup, Select) +from metric import (d_ratio, has_event, max, Event, JsonEncodeMetric, + JsonEncodeMetricGroupDescriptions, LoadEvents, Metric, + MetricGroup, Select) import argparse import json import math @@ -17,6 +18,16 @@ LoadEvents(directory) interval_sec = Event("duration_time") +def Idle() -> Metric: + cyc = Event("msr/mperf/") + tsc = Event("msr/tsc/") + low = max(tsc - cyc, 0) + return Metric( + "idle", + "Percentage of total wallclock cycles where CPUs are in low power state (C1 or deeper sleep state)", + d_ratio(low, tsc), "100%") + + def Rapl() -> MetricGroup: """Processor socket power consumption estimate. @@ -52,6 +63,7 @@ def Rapl() -> MetricGroup: all_metrics = MetricGroup("", [ + Idle(), Rapl(), ]) -- 2.44.0.278.ge034bb2e1d-goog