From patchwork Thu Feb 29 00:17:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208099 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp90003dyb; Wed, 28 Feb 2024 16:21:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVdiY7p9xPjOxxAF0CZPrySIz4Tpd+3kDBa7Ranz/k4BdEfoeIcl1AvGl0SbDqORRxaNlPFueJskp0MV7BYhAE7o7cqLA== X-Google-Smtp-Source: AGHT+IEHoau+/KUC4c6ywsVEpLZC2TkNnv435pOnCoPmqFbunaJFVjJIhJ1oFSbDjm39OcuTOhsW X-Received: by 2002:a17:902:f813:b0:1dc:bcb3:f552 with SMTP id ix19-20020a170902f81300b001dcbcb3f552mr496002plb.66.1709166115899; Wed, 28 Feb 2024 16:21:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166115; cv=pass; d=google.com; s=arc-20160816; b=MJuAbSp602eZQUk2RjudQdEk7GzO9tpSg/8zlP01o9IiU+5wuyKpiT5pMwQxhF/OMk 9IxNKTq9KrSPv9Gh/STi22mHLDaihtVL/KONUI+IqXQJl9Nb9DaRAk5PoI5Z3rCCJJpR /UO57VNYweQEesV1MUV5u6vyARv/NdB86MjrCi+wkD70HqEj+3C8x6u8svSgDBA1Z8fd xg3nVdRliRo3Jeu/DrPKRCTbmjtpCixykGwM80RYwJHub3fzWQ/WB3l9v7Pra7xSkKFd K6tTjBe51AQEQNNGBIcAJemqWlEDNpRCi+1Trl44vyaCvyTqhh/Srvo7DORR864Z2gBp OkWg== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85894-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b8-20020a170903228800b001dc75ea0f70si115663plh.341.2024.02.28.16.21.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:21:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85894-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85894-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D7FB3B2308B for ; Thu, 29 Feb 2024 00:19:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9569D36B01; Thu, 29 Feb 2024 00:18:33 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792190569168229551 X-GMAIL-MSGID: 1792190569168229551 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(), ])