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(), ]) From patchwork Thu Feb 29 00:17:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208093 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp89426dyb; Wed, 28 Feb 2024 16:20:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX3IQ0U6mm6Hw4hKzAoXJydWUBYfNPH67xBB5677jPZPKX/6bPuDFR8A25b4FgGtGG1W/0Yfz6UptnR/lMXQOXBDQczKg== X-Google-Smtp-Source: AGHT+IEAzF5pYzyYpZFpDUpGikukCSgWYIijll8VSi9t0fzpGoRKf4LyzpeggTqHiM6sI3xlGzu7 X-Received: by 2002:a05:6214:1648:b0:690:34f2:2f7b with SMTP id f8-20020a056214164800b0069034f22f7bmr729188qvw.31.1709166013961; Wed, 28 Feb 2024 16:20:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166013; cv=pass; d=google.com; s=arc-20160816; b=kivml64K8GWLSBQSdpc1wq+av0TshFcVzmC+9TaIJX0q/HL2Kmy0XgxiOxkidL7icL +aiNGLzVMLX/rByaFsB57kGo0JwoppbjTyfJnQSeqQpnZDOr4K5VMRn04xfqw0kT00sy HspqtQ6MTG68GvI5oPaX4CYJpRzyhYKMqFn5VUSrirCpnT5Tug/FmuJ+EUUZmpjG1NmB 3vVIWd2Hm/3XoRqeiM8MzIEi/REfYJy7l6dtYWM+X9xtR5wpQrtbZtdNwoUGDomWvkyd kAfBE25D0DhUlFGk7jAzmoDPc2BUPpfVPHqhxBjuWx7yffrLdgdPQNAnygCmm0TsohNq kpsw== 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=dSyxWL9CUFX3fE6recAd0yV0Q+Es3D3sjDkm1nLuaoo=; fh=V3Ay7NMi+Fjhk0Yw9uh1mb1vsO5xuZ6rM9biBwelcNA=; b=Ccb9AA51qdVFDkvP46/umFebo8p5rm57+BLdb+eJHhJge6X1GDI8agIFQfnkV/b/vf nkZXvSb9No3RzCuYCoNOu0d9cbLuyhUeHHslUbR58p8+2Zncy434Rkdt7AHk9i3FcCgX MtQUrIod1MvPX8hhxSrMzgYjWo+5S087C5kyekmnRobLuafLU7TWGRfGOst+PRWFKyEY BDNZ0v+UcCuaI5b6+NQYBLNS4E8QgEuZBfOvqG1PedVqWJhMVsuDM3YK7estYiQYVaBZ vh5mrLxGBEVdGLdnBbXbIMZXmXC89JQqLONRB9Gsowqhwq9uo1rcWfn8AwMvQbiNSfmv 3Nuw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=0DKo0cfc; 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-85895-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85895-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id if6-20020a0562141c4600b0068f38e7283fsi250021qvb.7.2024.02.28.16.20.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:20:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85895-ouuuleilei=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=0DKo0cfc; 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-85895-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85895-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id BD9381C20E85 for ; Thu, 29 Feb 2024 00:20:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 996C142A9F; Thu, 29 Feb 2024 00:18:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="0DKo0cfc" 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 22C5E2E851 for ; Thu, 29 Feb 2024 00:18:31 +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=1709165913; cv=none; b=LikWfCiyFvqWp0kufmGyIaJk0V3CjOO3R1EYDVOe1lEg3zL8QoF2KihCObwtT4LH6TJ6XRtjntcuUtFoSeBBQJb0rBfDshBJqiyaOWUzcxo2kBnp6/jWbaSo7qb5dbHxC76gtdS3ElJ+yVKP+I3ZFVXzYVoxqMO176tnfBv6tPE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165913; c=relaxed/simple; bh=HP0z9zpsAm/qTeZtLVT9exF49dLNPcCcFWKRdfJf6nA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=qDi3zdGvvq0Lfa4aZMhDCMTmYi45ylKRbZe9QYITgn3ktGNv5bot9/fsXGE54mN9BZ3yT6Z25hFU8c/V4NNkJBjVqXsWhudP+nPb/gZOjZF1Dg5JmH/BtIzSdcivDw6wVXmk14ZCNCuxyL8srSrREsYUEPT2FHBYSiMwuZRNjpM= 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=0DKo0cfc; 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 Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6093c69afafso5830447b3.2 for ; Wed, 28 Feb 2024 16:18:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165911; x=1709770711; 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=dSyxWL9CUFX3fE6recAd0yV0Q+Es3D3sjDkm1nLuaoo=; b=0DKo0cfcYcLlMxdtDJlIhQjM0JdBLbm+JXZENN+2tKejdWX1G7fxC3qGsvv/0o9QfY Kq6wJqvoWwfj7anM2JiTkQ5H/be0aWKSpXJ6TNqhnbatjobhcx2Sg9IvfRzcitJ2oVU2 bJ4ZUSVPWwBjrzOmZmFThh5pDkVBDAP8pDm0hBq5NIJaBuhAggkD/bJnKPnJpKhqmrbY hQluloJt+DHG2MUG5XhJJ1IK+TfO8xrYvOiABGzPJ8MruRpNsYpUEpMVBb8SSx8imRRP T2GyKNxhhIqZ8+BgUsACa7zX5mroqqVkS3ouudEN5f6QtlgkvbTQ2hMMEIV44mDu7mko fCTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165911; x=1709770711; 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=dSyxWL9CUFX3fE6recAd0yV0Q+Es3D3sjDkm1nLuaoo=; b=hX3ryv79EJBWsXCe3ggq00tR7yraZiJlk6H5sIt1XNaaMQIP/zE28qxjJWiqbDsKfk rfk6+5wHHtOikYVA01Pw6pghvgK3pENmz6s4zYC3hfSu8N49UTyNMfYVdPF/BKZFUU3d KhwaaxkvA3PVNBqi1Lc3kCkKUgADoGUcVoA82X6fCzGksZkjBKza0OeL0spKyd1Au1zp H0m6FC+fTUonKX47JYEvWz7VShYrl6MwgtF0Xrq89pJnrdvPEksjH5ynr8PLtH5mXhVC fiqVxn9pwCmCyHgOa/YdPVI6PIcM+9gX4lfQLm0Y0iJmF7nGws7MmdMn5B8BTnV/dfZ0 McEw== X-Forwarded-Encrypted: i=1; AJvYcCWxMHS2kWpC171pU0lZi2m99zA1ygIgX1F7M1gOdA5Add5sKnd7OnNKIZyoGvuOl39Xk40hA+8jd2Jzby/DC9rXl9TmX9UrMuPPkAyt X-Gm-Message-State: AOJu0YxdUGYfCjIxqZIoVTSk8F87fWNa3H7P5ef9UoJv+7FSeVIHFdyx 0dhMCn2hhSYobEjsWBf20Uo+mZwHbSNQ5dt4uZITVFC7Zht9e+SwT6g9jkfFfOLLaVUJVvQR/JD CIKtY9w== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:1885:b0:dc6:b768:2994 with SMTP id cj5-20020a056902188500b00dc6b7682994mr43238ybb.0.1709165911067; Wed, 28 Feb 2024 16:18:31 -0800 (PST) Date: Wed, 28 Feb 2024 16:17:48 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-4-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 03/20] perf jevents: Add smi metric group 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: 1792190462225929229 X-GMAIL-MSGID: 1792190462225929229 Allow duplicated metric to be dropped from json files. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 46866a25b166..20c25d142f24 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) from metric import (d_ratio, has_event, max, Event, JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, LoadEvents, Metric, - MetricGroup, Select) + MetricGroup, MetricRef, Select) import argparse import json import math @@ -62,9 +62,25 @@ def Rapl() -> MetricGroup: description="Processor socket power consumption estimates") +def Smi() -> MetricGroup: + aperf = Event('msr/aperf/') + cycles = Event('cycles') + smi_num = Event('msr/smi/') + smi_cycles = Select((aperf - cycles) / aperf, smi_num > 0, 0) + return MetricGroup('smi', [ + Metric('smi_num', 'Number of SMI interrupts.', + smi_num, 'SMI#'), + # Note, the smi_cycles "Event" is really a reference to the metric. + Metric('smi_cycles', + 'Percentage of cycles spent in System Management Interrupts.', + smi_cycles, '100%', threshold=(MetricRef('smi_cycles') > 0.10)) + ]) + + all_metrics = MetricGroup("", [ Idle(), Rapl(), + Smi(), ]) if args.metricgroups: From patchwork Thu Feb 29 00:17:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208094 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp89521dyb; Wed, 28 Feb 2024 16:20:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWrgdIzelWDc3TS01UXmacRaOY08+JCzBPuBtJc8XcsPDz0ezBJS3Lc0xpmi7tmDJrB8uYnjJUnK7mxr75djtN5vf9MCw== X-Google-Smtp-Source: AGHT+IGRDS14/VIslFZnk3Q7MbbRn9AvUh5Ct+eQj0BmjsC179RtqYxVKlai5uM4SLP/Z8gwPiuX X-Received: by 2002:a05:6870:c38e:b0:21e:b695:dff5 with SMTP id g14-20020a056870c38e00b0021eb695dff5mr496774oao.20.1709166029897; Wed, 28 Feb 2024 16:20:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166029; cv=pass; d=google.com; s=arc-20160816; b=b6+gGsyBgjopKZRBUc+OcjRLfDcGlgqWR8V/mM7dC1ddXijRjDSgYvPQBUTrHpPcvu s1AckBlFj+Vg5KHEL7K7Re2SozYKE4lFuztfaOTT+/vCmiZW3qQa+mKFSqTiPR/4xzX7 YYdPol8FwqOVRjetK+jTjd7cV3gCXovZ1DWz6pgPbpzQJTsEa73GSKj/VZ+VlfeGQXlB hU/HA8EaxmVk0pomADUZaUBT/OYEuBPR1A00/1LExiIqis6NIH5sBbtJJZNJDxpfDdod ldob02PBxcAgpHdDM31HxM1VtZjhbOfVNLa+jqMUzsxViUTsFUgIhK9ph9w5r9nYVxnP WXMw== 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=c0JvchFYB4X0MvBleracqYs3OMeU4l9tJWCec7y6q3w=; fh=5AZBbrzX2ukluy/8lTHjwMkDFHuf1eFJY7O5Gwgz8qo=; b=qawWUqk3UvPaOtrqn35dgE0VN7PKDDX3TrB86nTV9Hvky21cIMbl/Ml6iLoQNPxnm+ GSCV6GhQoDRa8ytFQs1rst+z6dCAm9rRi3Q0qDRwA/Orur5dT960zta+G4riKmX0ZxW6 Kd4TQXyAkJDUINuPjecFyxgG+NQQWPONEFFIb4vrRqRmAQPMi6sWOkw/UGk9clnoTjIn ihFD6Df4jUBsnBkw9+nOJKwiUuLbCsR/aVbgrkZtYiyjWILdG9DWPf2RmfLwhEZYF0Hm ei+kj8zrVmxxfV/OcAjj0HpCh0td/SoP5G6xQvhZkTbA003FpyS4yy9vOXqCs+LJq07m zDkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=kU4+lA1v; 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-85896-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85896-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id n27-20020aa7985b000000b006e4e40f5e2dsi98515pfq.242.2024.02.28.16.20.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:20:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85896-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=kU4+lA1v; 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-85896-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85896-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 177AC28457F for ; Thu, 29 Feb 2024 00:20:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E523445959; Thu, 29 Feb 2024 00:18:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kU4+lA1v" 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 4323E3E47F for ; Thu, 29 Feb 2024 00:18:34 +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=1709165915; cv=none; b=da/YsWPvyzlm0rvQ+C8YacVNfwQDsnkZgswM1skVaADXpjfGqaQALfYjY6ytwen/tcizFXYoLjfuiRc6HICZ+M0PCpsv2dnGPTHrTkq7JOW5JL4CN143Zhuq7dnb2QJhK04GJXlPLhD7ewji760J+XfxqZVo7gX+8fw2L5a2rwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165915; c=relaxed/simple; bh=OmwxBjnIGvz+HpCZV0zi77V/88wRlOeFcpNY7K4ifsw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=tp5WdOTgo80WuINC2zFWM2G0R71jzi21azvGFIZWb5y9HNuDj3JydjTgN454VsBjL5+OXoU0Zsd2+ViCW0aehCXBezW6XLz5thzdKjss3nqIPymCbh7jFl0mtAR9Y+C9oApJ8vyQoU8L5J/djh8gP5B5U6N9hQh4nv4w0sTfYJQ= 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=kU4+lA1v; 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-dcbee93a3e1so605319276.3 for ; Wed, 28 Feb 2024 16:18:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165913; x=1709770713; 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=c0JvchFYB4X0MvBleracqYs3OMeU4l9tJWCec7y6q3w=; b=kU4+lA1vHpZlDtSYyQVmEqdMYtzbTNAl9JAhc+YlQASrTBVwKHTrDpbRrDRvzkd1wa 5m15EGPbVBtoxxaQolL5ls7vXYVOt5lyf7taw91lUTMd7bRN9/PjhnKC6sYb9SfOR7TS UpPOYIwwGN7+KlWO0liZAJyZ+Coxt64rYyNxFUYDQI78mcsmQS25tOrECNYq0Rc5u+/t R3LwjWQgVX5QajjMz1jS07+mbgVTi0cfLBz8Xx2P5pHO3QMeBccy0emf+Q/bpufeoMbW 4KdsmNplZXb3Ec/vJEhmhQ0ajrMnf3axysXmdEebjbFGBtKRLDgB+vnH/LwHekB1kO2R es7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165913; x=1709770713; 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=c0JvchFYB4X0MvBleracqYs3OMeU4l9tJWCec7y6q3w=; b=BzlrI/RxzYmPQMXcFhRIUUsYeRfgrVOlFhvUFZ7FLTiEV7hLFvIv50p+nCex8SAWOu zyj5ia/gCabcT/heaxj8Ce9bD5OSEJ6jjePzmauFl3ZtsrypXm7fKAYvq6lAaRBbLQNb tiHIPuobn9p6CJIdWNWCYKwn8WPIV7CM6WeOGrc5aaXNsZGfVxA0lZNDdpncla7FyGiL ytA2zlO9h6T/MZ0f/9HNC+LS+Ys9AUZfFd0biqr9BrBZDMbbEqpbU6ko+1/vadaHqxlc B6KoeiIoJe0b3R7TsuVIHJ8a8sBpLiIDZLvy0LdXL97+6yGCCJuuLz7bNJuKedRP1bJ9 VBpA== X-Forwarded-Encrypted: i=1; AJvYcCX3FF8++yJWmH3oO5z407akRWZwyDy6iSCVzLsNW18U7xZGBPGQjv7Az8qohcsPlALuSinceIQpaOrq6qUramid7SU1ztM31iVdaBLN X-Gm-Message-State: AOJu0YyG3p4AGo8wqwrqPyBgEcEZHiKXYi8uONWpsWZmZ+yagmSda33k r7KIJfh7G6iIN3ptuaK9oicxT8hGFAtKMceSndSvPBPh+EdYfKHbI1sv17GQdhAQBEH6agetxm6 5dkdo+g== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:1244:b0:dc6:e20f:80cb with SMTP id t4-20020a056902124400b00dc6e20f80cbmr44028ybu.3.1709165913274; Wed, 28 Feb 2024 16:18:33 -0800 (PST) Date: Wed, 28 Feb 2024 16:17:49 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-5-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 04/20] perf jevents: Add tsx metric group 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: 1792190478951509028 X-GMAIL-MSGID: 1792190478951509028 Allow duplicated metric to be dropped from json files. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 51 ++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 20c25d142f24..1096accea2aa 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -7,6 +7,7 @@ import argparse import json import math import os +from typing import Optional parser = argparse.ArgumentParser(description="Intel perf json generator") parser.add_argument("-metricgroups", help="Generate metricgroups data", action='store_true') @@ -77,10 +78,60 @@ def Smi() -> MetricGroup: ]) +def Tsx() -> Optional[MetricGroup]: + if args.model not in [ + 'alderlake', + 'cascadelakex', + 'icelake', + 'icelakex', + 'rocketlake', + 'sapphirerapids', + 'skylake', + 'skylakex', + 'tigerlake', + ]: + return None + + pmu = "cpu_core" if args.model == "alderlake" else "cpu" + cycles = Event('cycles') + cycles_in_tx = Event(f'{pmu}/cycles\-t/') + transaction_start = Event(f'{pmu}/tx\-start/') + cycles_in_tx_cp = Event(f'{pmu}/cycles\-ct/') + metrics = [ + Metric('tsx_transactional_cycles', + 'Percentage of cycles within a transaction region.', + Select(cycles_in_tx / cycles, has_event(cycles_in_tx), 0), + '100%'), + Metric('tsx_aborted_cycles', 'Percentage of cycles in aborted transactions.', + Select(max(cycles_in_tx - cycles_in_tx_cp, 0) / cycles, + has_event(cycles_in_tx), + 0), + '100%'), + Metric('tsx_cycles_per_transaction', + 'Number of cycles within a transaction divided by the number of transactions.', + Select(cycles_in_tx / transaction_start, + has_event(cycles_in_tx), + 0), + "cycles / transaction"), + ] + if args.model != 'sapphirerapids': + elision_start = Event(f'{pmu}/el\-start/') + metrics += [ + Metric('tsx_cycles_per_elision', + 'Number of cycles within a transaction divided by the number of elisions.', + Select(cycles_in_tx / elision_start, + has_event(elision_start), + 0), + "cycles / elision"), + ] + return MetricGroup('transaction', metrics) + + all_metrics = MetricGroup("", [ Idle(), Rapl(), Smi(), + Tsx(), ]) if args.metricgroups: From patchwork Thu Feb 29 00:17:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208095 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp89598dyb; Wed, 28 Feb 2024 16:20:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX2HTWgWtEyxCB5IoERyGBI5Jfk1wfDR1ChpaGb0x6g4MIKOVuHlOgWOpqPqHh6Xfx4RRjgAHUJrCWuY9v4WLWc0tghQA== X-Google-Smtp-Source: AGHT+IE1/JG28CVARMcYsmX12Kl/clRwdcDVeZlpNJGf0lIVoyEC9+IK5PapfdhccBJgxBXoQOr3 X-Received: by 2002:a05:622a:64a:b0:42e:4bfc:26a9 with SMTP id a10-20020a05622a064a00b0042e4bfc26a9mr800174qtb.39.1709166043244; Wed, 28 Feb 2024 16:20:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166043; cv=pass; d=google.com; s=arc-20160816; b=FQa/0TXy00qyIZxTS2JLO4BPMFjTs7h0sOnR/4sBvgNQd+8KqnqF6Pay8QCGTT2pbf J2o50LohHBK2/rH51antSbGPqc8nIVrXCDINn+VAJ636cK+SgpkFp79VOocdVEx8ynID CEZpPvt5LLpPe0A4/yp4ac3TpXdn7Mu7v3r+jjctNA/HXMFIjIKyxxcOIybTZ6Z47O8W lXeQzuwiSYc1tBeAx79l0PWoWjYNMLU9IwuNiROQzwJAy8/tRHe6QnL+dyd5s6W2/XPR m+hc3+1C6ZpFhJXIe/mW8xqSnDIqtIWJ45u431sf9KMiZlQnkZb6flUGou7DWMDffcow QVgQ== 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=FFlMx+oNasYCjHbkgyCsRQrkyODw2CbaRmUxLrBz57E=; fh=gTkc+nY8rurh8pTeVCxGCaloCmhI0b9CUjpTPcu91Fc=; b=izo9fh4ONEhmYoWk4xTFMxAhV6vzr7d/SVNjfBNzlt8AQDysY6vWFe3b3IYHm2COL0 6BMUYtM0ky7R4ZaGpuKVqqMxialsFCciNMJdxFpgR9g4V/Qus6NFo9CCnOW1zkLF6NTf Ksbb9ldqSMszlYNoGyLObCggHG6Qfa9kAKkcTxhd5a6xjGfGZM1YHRWi5vIHYUff8Ow4 RtdoC7CEFwAacwqtq0rS+vJIyh3naLxnTH3JIResuqoDdnqqN4OzpxZiMSx9hehkyjcA ZMtPdQ28tO2JtPq4jFd4TFcdRHf97k7/ljUyopxULmxM5MFQITcTBC7BgWhRcDOaFDq2 kyVg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Dq/cFuI9"; 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-85897-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85897-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b12-20020ac844cc000000b0042e8491ed83si301262qto.201.2024.02.28.16.20.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:20:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85897-ouuuleilei=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="Dq/cFuI9"; 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-85897-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85897-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id F408E1C20E85 for ; Thu, 29 Feb 2024 00:20:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EEDAA535A6; Thu, 29 Feb 2024 00:18:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Dq/cFuI9" 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 5AB2D42A8C for ; Thu, 29 Feb 2024 00:18:36 +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=1709165918; cv=none; b=NUX25ArFumhksiDVitD/pVF4DDPIksIUJ0qJpG4NYvEp212e1LWBkrv+kcwfjiY3FKST8GlsArd7Ijnf2BZa3Xjq+Jc8lMdlqqRVFFuF2m41dQseglV4QCnyvzv9v5vAZ/vI3uIMkUICwsPeyOs2Y++noLSDNU3vQUvYtDqnDjY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165918; c=relaxed/simple; bh=lh38C2ZP3x0TtmsYtzGGwnk35I03kkxZ3DF9a2lkNs8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=vB6mvWELGcoeeJZAjTX8OLIBa6TQ8SsAey89C+j3rNsDMSAldDO7rEvykt2OToxFX8qqfZYrXww8crm1upTdkRgHMRyeQ18/QLmv8erTfOPNscP6QuqZN0tsr07RNMoQWScQZQFoF9BZDlbbYwiSXjszqff0m9EIhPaUlAkCmV0= 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=Dq/cFuI9; 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 Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-607c9677a91so5912027b3.2 for ; Wed, 28 Feb 2024 16:18:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165915; x=1709770715; 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=FFlMx+oNasYCjHbkgyCsRQrkyODw2CbaRmUxLrBz57E=; b=Dq/cFuI9y/evbZOWtKeVWlsfNbNE9w3FhYKZadsSug9L9f0TjF580XkGR40LmE7jZc jwxCSzBX/J0tMtW2NMxy7iUZVkQo/CMiT7S3+xMngLxNQc4k2dfE5pu95Y3fH/Te4Ev9 wmojcVo4zt+NZtwWllb+suCNpJ8SlMbCincehbrfdCXuuXsvDBXGp6CMPERNE32SRzpz wqXxj3tgYkbZ3T+9hiZo14PyocJ4BSjD2Krt2+RwViQdVkPK6W/xRv4h0uWD5hHYcVei MwLm3GuZUiS5SfufhahY/INLH44vbuJGluD8cnoK44IsxEcDqBmvGsT7GOERkX/Ec5as V86Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165915; x=1709770715; 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=FFlMx+oNasYCjHbkgyCsRQrkyODw2CbaRmUxLrBz57E=; b=cgpJnbjX+QfqQsOMSPdfw3aKr3VOp0KOcEZnpFofsPKu2m8HOcoBfXL7xRJsZeUlIK EBglAGy/I110Yqtpog9vXTREo7IMXYUvtrIbuIeJONdCRxA6+JkaHsHb/HU4s8lm+cuF LQtXeQBihz6tehncYpoggXyVWPOO9uf0NGmVUkF4LuZPllvzRxHywIvrVBevUKu3TrQn QL0a3w/m1Rn9LNkc9x8HQ4J1+cJRZnLfunJDI/crItn99GmBak5LEdjZk8ELkQXgTge5 KleM1jRmNW9wu7KXf8H4tJRE3MwZrlwdxldLZuSi9RArIwkt5j6+c8g+pkDPY93fdUn6 YBSw== X-Forwarded-Encrypted: i=1; AJvYcCWrdiCPc/taFlFXP5XSqZdxZ3gS72ePlCBiMMZTqJo+T8Tga/te8TFulphoWHctLpKeeHJwJuA6ZTRfvrH3BN1bVUFzQO7KXMg2Qc2I X-Gm-Message-State: AOJu0YwYZeZqbmJ7N4v+F+6VWfY/1gcZn2j8AOne6AUg02l53tipQpXy C3hpqfcD/oulVJH0y9iDqAY6Dp1Gw9UbfPMOZPB2lN0/SBVHRfsPxltAsfSceJ1eUjqhTTlxgQA 3r/Zu/w== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a81:9849:0:b0:609:3c46:1889 with SMTP id p70-20020a819849000000b006093c461889mr145864ywg.7.1709165915657; Wed, 28 Feb 2024 16:18:35 -0800 (PST) Date: Wed, 28 Feb 2024 16:17:50 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-6-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 05/20] perf jevents: Add br metric group for branch statistics on Intel 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: 1792190493000539189 X-GMAIL-MSGID: 1792190493000539189 The br metric group for branches itself comprises metric groups for total, taken, conditional, fused and far metric groups using json events. Condtional taken and not taken metrics are specific to Icelake and later generations, so a model to generation look up is added. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 139 +++++++++++++++++++++++++ 1 file changed, 139 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 1096accea2aa..bee5da19d19d 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -19,6 +19,7 @@ LoadEvents(directory) interval_sec = Event("duration_time") + def Idle() -> Metric: cyc = Event("msr/mperf/") tsc = Event("msr/tsc/") @@ -127,11 +128,149 @@ def Tsx() -> Optional[MetricGroup]: return MetricGroup('transaction', metrics) +def IntelBr(): + ins = Event("instructions") + + def Total() -> MetricGroup: + br_all = Event ("BR_INST_RETIRED.ALL_BRANCHES", "BR_INST_RETIRED.ANY") + br_m_all = Event("BR_MISP_RETIRED.ALL_BRANCHES", + "BR_INST_RETIRED.MISPRED", + "BR_MISP_EXEC.ANY") + br_clr = None + try: + br_clr = Event("BACLEARS.ANY", "BACLEARS.ALL") + except: + pass + + br_r = d_ratio(br_all, interval_sec) + ins_r = d_ratio(ins, br_all) + misp_r = d_ratio(br_m_all, br_all) + clr_r = d_ratio(br_clr, interval_sec) if br_clr else None + + return MetricGroup("br_total", [ + Metric("br_total_retired", + "The number of branch instructions retired per second.", br_r, + "insn/s"), + Metric( + "br_total_mispred", + "The number of branch instructions retired, of any type, that were " + "not correctly predicted as a percentage of all branch instrucions.", + misp_r, "100%"), + Metric("br_total_insn_between_branches", + "The number of instructions divided by the number of branches.", + ins_r, "insn"), + Metric("br_total_insn_fe_resteers", + "The number of resync branches per second.", clr_r, "req/s" + ) if clr_r else None + ]) + + def Taken() -> MetricGroup: + br_all = Event("BR_INST_RETIRED.ALL_BRANCHES", "BR_INST_RETIRED.ANY") + br_m_tk = None + try: + br_m_tk = Event("BR_MISP_RETIRED.NEAR_TAKEN", + "BR_MISP_RETIRED.TAKEN_JCC", + "BR_INST_RETIRED.MISPRED_TAKEN") + except: + pass + br_r = d_ratio(br_all, interval_sec) + ins_r = d_ratio(ins, br_all) + misp_r = d_ratio(br_m_tk, br_all) if br_m_tk else None + return MetricGroup("br_taken", [ + Metric("br_taken_retired", + "The number of taken branches that were retired per second.", + br_r, "insn/s"), + Metric( + "br_taken_mispred", + "The number of retired taken branch instructions that were " + "mispredicted as a percentage of all taken branches.", misp_r, + "100%") if misp_r else None, + Metric( + "br_taken_insn_between_branches", + "The number of instructions divided by the number of taken branches.", + ins_r, "insn"), + ]) + + def Conditional() -> Optional[MetricGroup]: + try: + br_cond = Event("BR_INST_RETIRED.COND", + "BR_INST_RETIRED.CONDITIONAL", + "BR_INST_RETIRED.TAKEN_JCC") + br_m_cond = Event("BR_MISP_RETIRED.COND", + "BR_MISP_RETIRED.CONDITIONAL", + "BR_MISP_RETIRED.TAKEN_JCC") + except: + return None + + br_cond_nt = None + br_m_cond_nt = None + try: + br_cond_nt = Event("BR_INST_RETIRED.COND_NTAKEN") + br_m_cond_nt = Event("BR_MISP_RETIRED.COND_NTAKEN") + except: + pass + br_r = d_ratio(br_cond, interval_sec) + ins_r = d_ratio(ins, br_cond) + misp_r = d_ratio(br_m_cond, br_cond) + taken_metrics = [ + Metric("br_cond_retired", "Retired conditional branch instructions.", + br_r, "insn/s"), + Metric("br_cond_insn_between_branches", + "The number of instructions divided by the number of conditional " + "branches.", ins_r, "insn"), + Metric("br_cond_mispred", + "Retired conditional branch instructions mispredicted as a " + "percentage of all conditional branches.", misp_r, "100%"), + ] + if not br_m_cond_nt: + return MetricGroup("br_cond", taken_metrics) + + br_r = d_ratio(br_cond_nt, interval_sec) + ins_r = d_ratio(ins, br_cond_nt) + misp_r = d_ratio(br_m_cond_nt, br_cond_nt) + + not_taken_metrics = [ + Metric("br_cond_retired", "Retired conditional not taken branch instructions.", + br_r, "insn/s"), + Metric("br_cond_insn_between_branches", + "The number of instructions divided by the number of not taken conditional " + "branches.", ins_r, "insn"), + Metric("br_cond_mispred", + "Retired not taken conditional branch instructions mispredicted as a " + "percentage of all not taken conditional branches.", misp_r, "100%"), + ] + return MetricGroup("br_cond", [ + MetricGroup("br_cond_nt", not_taken_metrics), + MetricGroup("br_cond_tkn", taken_metrics), + ]) + + def Far() -> Optional[MetricGroup]: + try: + br_far = Event("BR_INST_RETIRED.FAR_BRANCH") + except: + return None + + br_r = d_ratio(br_far, interval_sec) + ins_r = d_ratio(ins, br_far) + return MetricGroup("br_far", [ + Metric("br_far_retired", "Retired far control transfers per second.", + br_r, "insn/s"), + Metric( + "br_far_insn_between_branches", + "The number of instructions divided by the number of far branches.", + ins_r, "insn"), + ]) + + return MetricGroup("br", [Total(), Taken(), Conditional(), Far()], + description="breakdown of retired branch instructions") + + all_metrics = MetricGroup("", [ Idle(), Rapl(), Smi(), Tsx(), + IntelBr(), ]) if args.metricgroups: From patchwork Thu Feb 29 00:17:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208096 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp89664dyb; Wed, 28 Feb 2024 16:20:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUhY+VQrJrOOKXvKNvQtB5qWfaLO3/JHLTKhDWVI2G7yVWBvxxghOfl2iVLiMhjXwJf+JouY3rTIvScP8/C+nkb8YSYyg== X-Google-Smtp-Source: AGHT+IGgy5V1i46We7K9RdeT+oXil3d/jvqJH3ThWMIx4JxxtzuMUa6AQ2fifPh37Ms85dDBReIM X-Received: by 2002:a17:902:ce02:b0:1d9:f83e:3a54 with SMTP id k2-20020a170902ce0200b001d9f83e3a54mr641554plg.64.1709166055495; Wed, 28 Feb 2024 16:20:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166055; cv=pass; d=google.com; s=arc-20160816; b=PE/SQy9WCDbC2CLNKICBXkXp2+l9oFmcJcmxrEYAolPTLL5mUq0MNDb33uXPMI+n6l WIdvth52RijN1GxHz7G8PU4wxGRrm9z9YxtVRWam88oDUEnA/JF+FVGWX11rIrp1iLF1 9yMYCHJ9xmqYlsJNXuhqiOOXM0xXe43T0JZUsXCai0GU1G2dWPJvtC0+1fGmNqMQsSpa FV9fOCO52/U/lciW4nOi2z8/OXXIvhwF/iJKj7A0CVIRUwMbzSv4ji/Y7SelJeKnWDUg FUt3PWNxf2g7I2Dj2IC2O2jUFx0qLUmQkbSDm9WYWktOfvpsmZpixQMD8Fv75VBB9vbS i6fA== 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=QHYTrWPQQfDvRO2Y3kXJ96unWdbam7XTLAS0vgfzft0=; fh=8LZH8zANhwST2YFan8xfpG5o46UJBT1Yl1d4dlzlybA=; b=CG15Wv4Y2WCauGYk49l+CoIfscgDlGbKpp7fhOas1UVZ9YYIfR4ORUVeiVhIcbZe5+ /WMoRnxCD1My+xqGGSW0J3Vq/N+8/M6cjaz/zE0HzyrU6bhCRXMGrNHbc2lNpgmI2yAQ HxH3gAmpDlC8JG0ZmbM0EGu66riTdtIiaxRUhJQdYX+GAOsJVvjvcT+vYPiEOLfHviDZ BGWE0zLaC2fWF6V8xfAHE5ORMjhXdPG/x2ba8DBJ8grhcICN40NlpbuZl/LNDj1LwKdS YyGKoJwX8O5Eg/S0OboVy9ENHLj1Gmat4pFX9mrwhZO0rzNxDHqTSPvfXrryUyosk60M /7Aw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pR06XwA5; 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-85898-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85898-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e17-20020a17090301d100b001d720fa139esi122287plh.17.2024.02.28.16.20.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:20:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85898-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pR06XwA5; 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-85898-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85898-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4B72528107F for ; Thu, 29 Feb 2024 00:20:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C063E55C26; Thu, 29 Feb 2024 00:18:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pR06XwA5" 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 B059E44C9C for ; Thu, 29 Feb 2024 00:18:38 +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=1709165920; cv=none; b=iIOF9L9Umbkb+ksKsS9pu56VqKQbDTRlhmNOHF3BfvNJWYbjCjmACIHWbDEdUnEoJfRgNrGpVuTmeQ8+hVI7YCrsaWIBOm5Q9PVxE+X5h4nt/a3lMwvYCo5jx0eOaMAYH8/+KDqLdLoHjqufCHSycoeUdOZFVzeczUapqwucrBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165920; c=relaxed/simple; bh=OGxEkqtAUV2coFbRq/RJ+uPweZKIEnWlAUORKInoJ9k=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=o1OSfn4TSCNKQoyUDlmR4CxtUbLYRZkxxPq1x46Wl6DyBw8H1Of62gjXflVLGDW25zpaZ9eB1JpW/mC+hDq2D4SdC/pa1QpgkBaOby5xd06npUFimUAmPxe18UJPcYJP2jNa2vXlKMaLfAN4MP1TvO9QJHg8qNeebQS8ULR/Pjs= 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=pR06XwA5; 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 Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-607838c0800so16776767b3.1 for ; Wed, 28 Feb 2024 16:18:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165918; x=1709770718; 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=QHYTrWPQQfDvRO2Y3kXJ96unWdbam7XTLAS0vgfzft0=; b=pR06XwA5lQ9LpnUlZYP7b9tIwA5e47krSbwhi7Nkhfatb4DJAwfubLgO90TwYDmEO4 FgbArula5qk/jcYnL0B9xl4pidhkd7LaDW/9t0NYBJzou60+vBBETmiZU9/x4C4kgg4L HSoavzNP1z4zKcEjKV9DSD2fUAKrNLFvDWXebXOCa8re02Dtsjh0BEzggc407h0ZX8L8 mS7u2VxhhXGkfZEOA6E1hge/ToiGYDDt3cL0b5zMqUR14xMCgvxEq2JRDvsHMe6aU63c Ka++HWop1e36Caj/nGWHNPzq4P1dnHlMaNH+GZiQFgH7lZK/QqOTOxKcdLQ9+EP5VaAe oEQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165918; x=1709770718; 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=QHYTrWPQQfDvRO2Y3kXJ96unWdbam7XTLAS0vgfzft0=; b=fSFUB1vaQKOzeDeUNobJr3jMkIT4PBLLr0G2C6XJ21UBAROVTKiS9bEYZu/wloJ+oj OzqdTJfwlEniQJIckK4+JmN/mL+XD4vsMo9tHL3T+ptLPHnuNKnfxSQCPF0ss6zBBAgt i6aVTLIY5kX/dPPfEHhBl2fZqechdl5BEVjchAB84puDTNtk/wcyc4MGUnOw0uJg4lNU 5iV5DxI1AYuRoZXt0RfNBx/oK2JWumr37jQUF8DKvDablYgbEZIV7w5IORst/UMufBLY 39IJwbQTRRZzv2aa4rw7upQp4gjuDawu+Nr5WqD0bv0UoI5AqZFqH4LdJewrDDSFQRCY pnvQ== X-Forwarded-Encrypted: i=1; AJvYcCWzX5v871M6VNb5FrmhNJXfmN4gxfKkbFCsWc/8xjIPmfwi980LHINlAnwjEQuqHv7AgT5iR8pSKBTesxa0dCj2WKYRSUnXkqmd7nqE X-Gm-Message-State: AOJu0YwjrqezrxKdBgS/IJbvgTFb4KHn4Ahx+6R+NC1uVwLDbcfLCO1w SwN6FuutxJOM/Jd+0uzlaIW21e96N8QPRiNdhvSJj2YLToXAAdzrHMfylOjq09gGe47gIaWexz+ /CELFyg== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:505:b0:dc7:4ca0:cbf0 with SMTP id x5-20020a056902050500b00dc74ca0cbf0mr46479ybs.3.1709165917807; Wed, 28 Feb 2024 16:18:37 -0800 (PST) Date: Wed, 28 Feb 2024 16:17:51 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-7-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 06/20] perf jevents: Add software prefetch (swpf) metric group for Intel 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: 1792190505973753891 X-GMAIL-MSGID: 1792190505973753891 Add metrics that breakdown software prefetch instruction use. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 65 ++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index bee5da19d19d..f11273e9935c 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -265,12 +265,77 @@ def IntelBr(): description="breakdown of retired branch instructions") +def IntelSwpf() -> Optional[MetricGroup]: + ins = Event("instructions") + try: + s_ld = Event("MEM_INST_RETIRED.ALL_LOADS", "MEM_UOPS_RETIRED.ALL_LOADS") + s_nta = Event("SW_PREFETCH_ACCESS.NTA") + s_t0 = Event("SW_PREFETCH_ACCESS.T0") + s_t1 = Event("SW_PREFETCH_ACCESS.T1_T2") + s_w = Event("SW_PREFETCH_ACCESS.PREFETCHW") + except: + return None + + all_sw = s_nta + s_t0 + s_t1 + s_w + swp_r = d_ratio(all_sw, interval_sec) + ins_r = d_ratio(ins, all_sw) + ld_r = d_ratio(s_ld, all_sw) + + return MetricGroup("swpf", [ + MetricGroup("swpf_totals", [ + Metric("swpf_totals_exec", "Software prefetch instructions per second", + swp_r, "swpf/s"), + Metric("swpf_totals_insn_per_pf", + "Average number of instructions between software prefetches", + ins_r, "insn/swpf"), + Metric("swpf_totals_loads_per_pf", + "Average number of loads between software prefetches", + ld_r, "loads/swpf"), + ]), + MetricGroup("swpf_bkdwn", [ + MetricGroup("swpf_bkdwn_nta", [ + Metric("swpf_bkdwn_nta_per_swpf", + "Software prefetch NTA instructions as a percent of all prefetch instructions", + d_ratio(s_nta, all_sw), "100%"), + Metric("swpf_bkdwn_nta_rate", + "Software prefetch NTA instructions per second", + d_ratio(s_nta, interval_sec), "insn/s"), + ]), + MetricGroup("swpf_bkdwn_t0", [ + Metric("swpf_bkdwn_t0_per_swpf", + "Software prefetch T0 instructions as a percent of all prefetch instructions", + d_ratio(s_t0, all_sw), "100%"), + Metric("swpf_bkdwn_t0_rate", + "Software prefetch T0 instructions per second", + d_ratio(s_t0, interval_sec), "insn/s"), + ]), + MetricGroup("swpf_bkdwn_t1_t2", [ + Metric("swpf_bkdwn_t1_t2_per_swpf", + "Software prefetch T1 or T2 instructions as a percent of all prefetch instructions", + d_ratio(s_t1, all_sw), "100%"), + Metric("swpf_bkdwn_t1_t2_rate", + "Software prefetch T1 or T2 instructions per second", + d_ratio(s_t1, interval_sec), "insn/s"), + ]), + MetricGroup("swpf_bkdwn_w", [ + Metric("swpf_bkdwn_w_per_swpf", + "Software prefetch W instructions as a percent of all prefetch instructions", + d_ratio(s_w, all_sw), "100%"), + Metric("swpf_bkdwn_w_rate", + "Software prefetch W instructions per second", + d_ratio(s_w, interval_sec), "insn/s"), + ]), + ]), + ], description="Sofware prefetch instruction breakdown") + + all_metrics = MetricGroup("", [ Idle(), Rapl(), Smi(), Tsx(), IntelBr(), + IntelSwpf(), ]) if args.metricgroups: From patchwork Thu Feb 29 00:17:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208103 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp90336dyb; Wed, 28 Feb 2024 16:22:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCViOWQrJxeHiYzt0Ga5z0P2LLcFcN+v+9fkjKQrQgkLaOTmtVfsTVaEbr/GPbgy2pIeRaOovm2ZBYtWhBrsPUxLIuXtLQ== X-Google-Smtp-Source: AGHT+IH/0NqyXU6ohRvnv7rVOBS9EdoU3tj+c86ey8WZlC9Y8LcVH+sVfUlcruoyR1R+12IdXEbb X-Received: by 2002:a05:6a00:997:b0:6e5:9e9:bcb5 with SMTP id u23-20020a056a00099700b006e509e9bcb5mr1053881pfg.24.1709166169173; Wed, 28 Feb 2024 16:22:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166169; cv=pass; d=google.com; s=arc-20160816; b=VbS9JifNhE9qkjtQKdi9NY7MpQSVEcc96rv6UsKh2UyzcOP5EybttnjIK/yvtT8FEu uUIDIefHsQxQ/RZKac8URXVey6Dm1EIUGhGg0qVNAg1b3y7uld1Uuu/EqWYNmuhHIKsJ KkaBD0MllIQ9HXGmtJbemQ5Gte5WRVP/+ddSMvLAEBleQAB87o+FtFRiSWaCq+eIdgd7 2vIGcMhcTRZSkQTslKjAJP6xeOO4IgMIxkF4kKO6zyTCuSdVJNp3i52uMUDLlxuh07Zy xunc5UE3YB1ZmT/03b230k8qLln9OG/KJLMwg4vok4yXxOkXTp15j8G17U6kpIsopOO9 refw== 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=KevBgsY4J/pffn7xcpMTC+4LgPUcMPV9xIrPsMU+9Ks=; fh=5aNj+EhbvvmXqkLBgWzuVSTPSYkEM0smVDXLH6mreHA=; b=UnWNnNZ932zYlrATNl4QT2XtytXwonjJvAiJytEe0azRiPSOXOx+23HhSNuLTY2NxO OzI7tuPHGZ2cYwSEXLQa01k5eWrRy+YtNNCk9S9guimmComKXvqLeD3Z76ggzLahAm7d EKQF9wBnBaEqY1k1tztIF6DPNPSqO+J21OE2CA8LTvPe3czAFspRxXTgWUajIkG6EQUI F9axrC8fNtc/SbKIF6HfKcChKCxy5G18kseKTQ9w/io2WJYjXqbtM8oqgDq+63oZgFmm nrXshAp+LQlvPLaCGyLZbW2GaGqVEVi0T/tFgIA9gLFhMUE422su44KQDPOfdOSy1XNs biQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TXbLB6zI; 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-85899-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85899-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. [147.75.48.161]) by mx.google.com with ESMTPS id 5-20020a630905000000b005dc4fbfb9acsi171243pgj.583.2024.02.28.16.22.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:22:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85899-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TXbLB6zI; 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-85899-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85899-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 AC574B25258 for ; Thu, 29 Feb 2024 00:21:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A19E856B8E; Thu, 29 Feb 2024 00:18:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TXbLB6zI" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.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 1B7DE3612D for ; Thu, 29 Feb 2024 00:18:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165922; cv=none; b=YxjNBhgfoilh8njZa2akJ8HH8Sg/IvXhnG3T2Po2zP2m6yRYFsfp/ERj3+h0egdpbfTCG3sThN6UlABsc8dBN2SRyz4saOj/CtyjdafENaskvCo7M1VsRbyH55wJgyGgUStfeN1j8C3KpFhyU51zb2FjFNSZCci4uGaEv5ABFt4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165922; c=relaxed/simple; bh=yjVC8LCNIc1SkJJNK1huvdVoLuihBnJ8/xrqhZCq4ak=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=eBNxNGGeld5pOFhE5fREmNnLrOcTNkgenYXEo6soIer3xbFTP8ed1YCEjkLbuxEoLyY570l+LOj7PtLtxceExIbqdB8W3fzNV7B5yvbtRpgm+5RvlKfWU4cwAYwlIuGfnEnd/2TMrf/ZB2mO79Z1Ey8AhAPRKZq+8dOUBkXcJ5Q= 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=TXbLB6zI; arc=none smtp.client-ip=209.85.219.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 Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6b26783b4so555114276.0 for ; Wed, 28 Feb 2024 16:18:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165920; x=1709770720; 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=KevBgsY4J/pffn7xcpMTC+4LgPUcMPV9xIrPsMU+9Ks=; b=TXbLB6zI+0/6+6vGkPpMthp8Vsxif4X0xxUustURUo4Ess3YNY0eTvkuNQgS3r8zrY 6tlSV5TwfJrVlkb2PNv6N2pmo6e/TfPgtzYAVWl5m5j2odk4t4guhryu4+IbHnSLrj92 hrFDri20zNOA+nBXBbIMxat0QybrWMIEJBprb6UIarzcJlbERzpMlijNb4tEY68XAR8I 8Y0vo1TH8e1VI/6Cr7bO2quv70VLeeHdfdzzIugHyLdoblgX6BWnqWhG0mMaOGoicXk+ 16FuSWbkmuopilPWZY2FZiiajN9CaXBAAjN82uasqnF7GQLiYixrnjRl1HCfMF+5xwhq nUYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165920; x=1709770720; 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=KevBgsY4J/pffn7xcpMTC+4LgPUcMPV9xIrPsMU+9Ks=; b=ChhEais+obh0hyWhmwR/wBPEXj+wGPabVpiyTXS9ZhRzvgaPjGGm+Qm97ESnBK8AnT ukFwJzcTb4mYqROvkeezxYwEyS5j6JWMp30pb2BMEM7+ffZueX0sT5O1MVighKuDh9sX affxzmYHrDFCde5GvF+3sz3vsMJ0VcvPI1GBTQVNPnCCAPko8yYZ7eVYE5skNCoAknlm 2dFF/mj2tbuFs/7avBDcfXX9vrWW8eIaeZpwSz4unS/WLJ7gmaI6SONFOw34sVDcD+jI IO1IHHZWQIG83sRvD6kgVuEzUOOBB8cpCzoy/h0YybFyL34DbBUSbTCBn2r4t5zyi3il 0cBQ== X-Forwarded-Encrypted: i=1; AJvYcCWyeWuLuaPbp0kQiGCPIYQriuZd6C0X1A8+nDZAAzp1EE4VvP5wVOt/NguT4NjUU2zI0P7i1UtQHSSDwiF+AYr547qASHTp6ljfWadr X-Gm-Message-State: AOJu0YwMATyLp8bMP5yFoTaExqreGM92geYBDNvHJZ/9Cvkr6xy4E1OS h3ys9EcWoGiH8sV8+z/BvDjTxtMLu8d5DkwFqHXL3i29Gx/ILO8Vrr9YD6PXz5WeDzRKTjMsET8 l8ycHjw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:e90:b0:dc6:b813:5813 with SMTP id dg16-20020a0569020e9000b00dc6b8135813mr41854ybb.9.1709165920173; Wed, 28 Feb 2024 16:18:40 -0800 (PST) Date: Wed, 28 Feb 2024 16:17:52 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-8-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 07/20] perf jevents: Add ports metric group giving utilization on Intel 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: 1792190625234362546 X-GMAIL-MSGID: 1792190625234362546 The ports metric group contains a metric for each port giving its utilization as a ratio of cycles. The metrics are created by looking for UOPS_DISPATCHED.PORT events. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 33 ++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index f11273e9935c..63d46ee1dca9 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -1,12 +1,13 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) from metric import (d_ratio, has_event, max, Event, JsonEncodeMetric, - JsonEncodeMetricGroupDescriptions, LoadEvents, Metric, - MetricGroup, MetricRef, Select) + JsonEncodeMetricGroupDescriptions, Literal, LoadEvents, + Metric, MetricGroup, MetricRef, Select) import argparse import json import math import os +import re from typing import Optional parser = argparse.ArgumentParser(description="Intel perf json generator") @@ -18,6 +19,11 @@ directory = f"{os.path.dirname(os.path.realpath(__file__))}/arch/x86/{args.model LoadEvents(directory) interval_sec = Event("duration_time") +core_cycles = Event("CPU_CLK_UNHALTED.THREAD_P_ANY", + "CPU_CLK_UNHALTED.DISTRIBUTED", + "cycles") +# Number of CPU cycles scaled for SMT. +smt_cycles = Select(core_cycles / 2, Literal("#smt_on"), core_cycles) def Idle() -> Metric: @@ -265,6 +271,28 @@ def IntelBr(): description="breakdown of retired branch instructions") +def IntelPorts() -> Optional[MetricGroup]: + pipeline_events = json.load(open(f"{os.path.dirname(os.path.realpath(__file__))}" + f"/arch/x86/{args.model}/pipeline.json")) + + metrics = [] + for x in pipeline_events: + if "EventName" in x and re.search("^UOPS_DISPATCHED.PORT", x["EventName"]): + name = x["EventName"] + port = re.search(r"(PORT_[0-9].*)", name).group(0).lower() + if name.endswith("_CORE"): + cyc = core_cycles + else: + cyc = smt_cycles + metrics.append(Metric(port, f"{port} utilization (higher is better)", + d_ratio(Event(name), cyc), "100%")) + if len(metrics) == 0: + return None + + return MetricGroup("ports", metrics, "functional unit (port) utilization -- " + "fraction of cycles each port is utilized (higher is better)") + + def IntelSwpf() -> Optional[MetricGroup]: ins = Event("instructions") try: @@ -335,6 +363,7 @@ all_metrics = MetricGroup("", [ Smi(), Tsx(), IntelBr(), + IntelPorts(), IntelSwpf(), ]) From patchwork Thu Feb 29 00:17:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208097 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp89833dyb; Wed, 28 Feb 2024 16:21:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVQRvyMc0ZVew5QN2FRP1Iyf4/wo5BUGnoWGnvfwJcNKv7VLpRHbxWbFlBTNVk9xvXCop5gcdsBloMjwXLmpvltCoibXQ== X-Google-Smtp-Source: AGHT+IFpBFL8hgDpr9U3gbEvH6DxaYldsze71mFOXkehLJhXJu7cHJOI4LGlwovkOav0G+PTHjXH X-Received: by 2002:a17:906:4ec6:b0:a41:5675:4e2e with SMTP id i6-20020a1709064ec600b00a4156754e2emr241029ejv.19.1709166086942; Wed, 28 Feb 2024 16:21:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166086; cv=pass; d=google.com; s=arc-20160816; b=lavODGw+wG1HwwT3Fo9PwfuUNqnmQHmHHiPJ1iDtFYLVGstRcf8bxUgZnxXvgL+HtC lItjE3evGaLCBTAfV8R/qtDVcu75dPLsgLaRby8C4Ss+43WpJn5+YypychxJrF2ga5Gh uNBGIdMoa9PlqrVdrhmPp+MmmHTZwgmFH/cqqwRVRSGQyZUHB1d5VU62yqEUksAshZ5J viTGUqqePZn8N1tZDmdHiCsLe+ZDno8AMO/aC51gQ89bWSKizi6iZ1qpApJ04Cu1NKGi WkXJXE1bXpXwPAH7lo+E6GKfN6DAPz4RhqGGCEp8/aPXalH74k2PM5qn7w4+JfCwfgj9 LCVg== 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=hg+O4OOMu1UeLWG+Ohq6wGldowYOme6w15H8KRpykG4=; fh=k05x80pFBRFRTHMG4qDDKPaxBD+Pg42MWe1yQ4pIeSA=; b=PqpbFVlYXD5x5mvnEXVmTnrEANsx7qIGSDmkpzTCHOM9+XwaBuWHYbwIJspMyU/HVe 3AztsK0z1LULGzERnwcBzeWAEtvdZ0W9/ik307Vfs1ePfpZHMGXIkgZvgCN7fbAwyzeE RSCc9AgG8OEuN0B1iht2er4/kOd8uzs9vx6sAh29EWs9MbXuWfG8p/NigwLGEBDKi/gl 76+9Yzu03nx8VFs+09nSRIveYPOtt+bLlNdpAQfhIaj95IMSsh7Ug/4lYLHutl7EOiWc Yl/Mxkb3RfR+danV866q/Q1YiYlWC1UDeUrXC/4n9KY+6ZXZgcrmaxXnOZfuJ1SWV0pP 6C0A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=aPoGWhhT; 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-85900-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85900-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t23-20020a1709063e5700b00a3f84c797desi52456eji.679.2024.02.28.16.21.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:21:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85900-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=aPoGWhhT; 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-85900-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85900-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 634761F22E79 for ; Thu, 29 Feb 2024 00:21:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 902671D6AE; Thu, 29 Feb 2024 00:18:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="aPoGWhhT" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.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 90A685336D for ; Thu, 29 Feb 2024 00:18:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165925; cv=none; b=A/g4RGbv5jMp7J+dtrz6bZaC5aoTsyimZxgTmiLqaF4dUYSUHUc0vcSO3EUoswoP2JE98lLjIqRJSSRGo3fyEaoHgBq8asMqisU9MraeFcolcvT52m5tFzFTbxPLB6DXl/oUJvMYgNDOS0GOoc78tJokZY+yLF4qmo8EogL+ff8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165925; c=relaxed/simple; bh=9tPk+vGpstow6zqoysIPvqeqHhBpWkNTO2bW3Gn7ZAs=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=FcXEz4ragBodQcIVuTonql4ZhQ/5ySN8XSNHbi49dWsbJnxQfilfFy+2/5kYcCXTPkJV+aDO3Bo1I9JPYWIDev5/a3DDWh7XOgtyTsh4GqZCgUlY0ZBKeNh4cRmtI0c2Xmu8bhHNKghCbLgqyoqS6YP6IKfpFl6tc30b9el9lIo= 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=aPoGWhhT; arc=none smtp.client-ip=209.85.219.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 Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc64f63d768so650566276.2 for ; Wed, 28 Feb 2024 16:18:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165922; x=1709770722; 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=hg+O4OOMu1UeLWG+Ohq6wGldowYOme6w15H8KRpykG4=; b=aPoGWhhT0UjaRvKgpwnlvnfKB3THcXfB7DYWfkRgTgKei1Ypm5Wmaa1gdPo+wNCKw7 VdWsz+7erQA4JyGn70bWoPYwxbCHBC3IN9MSapqPq4naGvaOfjVh9iO69qfLnmzrCKHf 5n9N5og14kskqwtcloU+mMm809uvYg+qNQc4Xvw+g4RUaBYYGAK2JxgwmlZepj6uYMDE ZwHivQG2YtEX2orzU6FUVMlMMSa173oZO9fT6fxZ+rLvq38s/UOHdhYSTuWHxkGTMXjT O6o97Kcsuq7pXcVp/o9bavI06IAJnMWCiCnbdlC0g612PquAvVqgxd1kO3+67X/FfVGC uhHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165922; x=1709770722; 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=hg+O4OOMu1UeLWG+Ohq6wGldowYOme6w15H8KRpykG4=; b=dOlEgSKKsmT3JIelsT4+sXtrZJsLTBVyw6LZpKyVJzuegBevFsHMsbM54z0PIqm4Fj 5oCuWpCCD+tqxgAWaYPymaocvx3vZcq+UwwBq+v+A/uAglMuM5dATX7dwM/uQKmwzUE6 83mbYEOjyjjg+9wM0dZqKeEt6ea0fxRN+E4fhgQLkA2N9eiZF8FPmgGIgqpnz/dCN/l6 Z7bSDundPHb8o0FdlGHYjSeVLCx2/H9DI/rkL+U5iMwxZKS9hjzhcSW1Eqx2/yJmz9vR /ldznNGowq3GYokU7ZUVxdFL+bzSZYclkxu1uzhOU+wHjCU1Qfh/XsvrZoTHV7Rm1fiL 9soA== X-Forwarded-Encrypted: i=1; AJvYcCWCOATqTWuuZuPtx9qtv9/dO0HAdXDYlPHzVH6oufj9DCLhR+6R/zDC9qFVLCC7qljyyfvqrUhkyd6er3WqW+Yyb2tztX6ZAfOsYXAw X-Gm-Message-State: AOJu0YwrtAn/AwgBaOpphzC7Ww7Wmo5Zl1O8+E8KdlGKPYPmvI61lWCj BMriGnLBB8/9hCSfpqinstq8uaJ6Fj0gynkrPnalU3CtGwR5umSWxVux3MEnAI0J6cEbEIRBkIf v8yBZgA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:120f:b0:dc6:cd85:bcd7 with SMTP id s15-20020a056902120f00b00dc6cd85bcd7mr213546ybu.3.1709165922485; Wed, 28 Feb 2024 16:18:42 -0800 (PST) Date: Wed, 28 Feb 2024 16:17:53 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-9-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 08/20] perf jevents: Add L2 metrics for Intel 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: 1792190538648130415 X-GMAIL-MSGID: 1792190538648130415 Give a breakdown of various L2 counters as metrics, including totals, reads, hardware prefetcher, RFO, code and evictions. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 158 +++++++++++++++++++++++++ 1 file changed, 158 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 63d46ee1dca9..d22a1abca8d9 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -271,6 +271,163 @@ def IntelBr(): description="breakdown of retired branch instructions") +def IntelL2() -> Optional[MetricGroup]: + try: + DC_HIT = Event("L2_RQSTS.DEMAND_DATA_RD_HIT") + except: + return None + try: + DC_MISS = Event("L2_RQSTS.DEMAND_DATA_RD_MISS") + l2_dmnd_miss = DC_MISS + l2_dmnd_rd_all = DC_MISS + DC_HIT + except: + DC_ALL = Event("L2_RQSTS.ALL_DEMAND_DATA_RD") + l2_dmnd_miss = DC_ALL - DC_HIT + l2_dmnd_rd_all = DC_ALL + l2_dmnd_mrate = d_ratio(l2_dmnd_miss, interval_sec) + l2_dmnd_rrate = d_ratio(l2_dmnd_rd_all, interval_sec) + + DC_PFH = None + DC_PFM = None + l2_pf_all = None + l2_pf_mrate = None + l2_pf_rrate = None + try: + DC_PFH = Event("L2_RQSTS.PF_HIT") + DC_PFM = Event("L2_RQSTS.PF_MISS") + l2_pf_all = DC_PFH + DC_PFM + l2_pf_mrate = d_ratio(DC_PFM, interval_sec) + l2_pf_rrate = d_ratio(l2_pf_all, interval_sec) + except: + pass + + DC_RFOH = Event("L2_RQSTS.RFO_HIT") + DC_RFOM = Event("L2_RQSTS.RFO_MISS") + l2_rfo_all = DC_RFOH + DC_RFOM + l2_rfo_mrate = d_ratio(DC_RFOM, interval_sec) + l2_rfo_rrate = d_ratio(l2_rfo_all, interval_sec) + + DC_CH = Event("L2_RQSTS.CODE_RD_HIT") + DC_CM = Event("L2_RQSTS.CODE_RD_MISS") + DC_IN = Event("L2_LINES_IN.ALL") + DC_OUT_NS = None + DC_OUT_S = None + l2_lines_out = None + l2_out_rate = None + wbn = None + isd = None + try: + DC_OUT_NS = Event("L2_LINES_OUT.NON_SILENT", + "L2_LINES_OUT.DEMAND_DIRTY", + "L2_LINES_IN.S") + DC_OUT_S = Event("L2_LINES_OUT.SILENT", + "L2_LINES_OUT.DEMAND_CLEAN", + "L2_LINES_IN.I") + if DC_OUT_S.name == "L2_LINES_OUT.SILENT" and ( + args.model.startswith("skylake") or + args.model == "cascadelakex"): + DC_OUT_S.name = "L2_LINES_OUT.SILENT/any/" + # bring is back to per-CPU + l2_s = Select(DC_OUT_S / 2, Literal("#smt_on"), DC_OUT_S) + l2_ns = DC_OUT_NS + l2_lines_out = l2_s + l2_ns; + l2_out_rate = d_ratio(l2_lines_out, interval_sec); + nlr = max(l2_ns - DC_WB_U - DC_WB_D, 0) + wbn = d_ratio(nlr, interval_sec) + isd = d_ratio(l2_s, interval_sec) + except: + pass + DC_OUT_U = None + l2_pf_useless = None + l2_useless_rate = None + try: + DC_OUT_U = Event("L2_LINES_OUT.USELESS_HWPF") + l2_pf_useless = DC_OUT_U + l2_useless_rate = d_ratio(l2_pf_useless, interval_sec) + except: + pass + DC_WB_U = None + DC_WB_D = None + wbu = None + wbd = None + try: + DC_WB_U = Event("IDI_MISC.WB_UPGRADE") + DC_WB_D = Event("IDI_MISC.WB_DOWNGRADE") + wbu = d_ratio(DC_WB_U, interval_sec) + wbd = d_ratio(DC_WB_D, interval_sec) + except: + pass + + l2_lines_in = DC_IN + l2_code_all = DC_CH + DC_CM + l2_code_rate = d_ratio(l2_code_all, interval_sec) + l2_code_miss_rate = d_ratio(DC_CM, interval_sec) + l2_in_rate = d_ratio(l2_lines_in, interval_sec) + + return MetricGroup("l2", [ + MetricGroup("l2_totals", [ + Metric("l2_totals_in", "L2 cache total in per second", + l2_in_rate, "In/s"), + Metric("l2_totals_out", "L2 cache total out per second", + l2_out_rate, "Out/s") if l2_out_rate else None, + ]), + MetricGroup("l2_rd", [ + Metric("l2_rd_hits", "L2 cache data read hits", + d_ratio(DC_HIT, l2_dmnd_rd_all), "100%"), + Metric("l2_rd_hits", "L2 cache data read hits", + d_ratio(l2_dmnd_miss, l2_dmnd_rd_all), "100%"), + Metric("l2_rd_requests", "L2 cache data read requests per second", + l2_dmnd_rrate, "requests/s"), + Metric("l2_rd_misses", "L2 cache data read misses per second", + l2_dmnd_mrate, "misses/s"), + ]), + MetricGroup("l2_hwpf", [ + Metric("l2_hwpf_hits", "L2 cache hardware prefetcher hits", + d_ratio(DC_PFH, l2_pf_all), "100%"), + Metric("l2_hwpf_misses", "L2 cache hardware prefetcher misses", + d_ratio(DC_PFM, l2_pf_all), "100%"), + Metric("l2_hwpf_useless", "L2 cache hardware prefetcher useless prefetches per second", + l2_useless_rate, "100%") if l2_useless_rate else None, + Metric("l2_hwpf_requests", "L2 cache hardware prefetcher requests per second", + l2_pf_rrate, "100%"), + Metric("l2_hwpf_misses", "L2 cache hardware prefetcher misses per second", + l2_pf_mrate, "100%"), + ]) if DC_PFH else None, + MetricGroup("l2_rfo", [ + Metric("l2_rfo_hits", "L2 cache request for ownership (RFO) hits", + d_ratio(DC_RFOH, l2_rfo_all), "100%"), + Metric("l2_rfo_misses", "L2 cache request for ownership (RFO) misses", + d_ratio(DC_RFOM, l2_rfo_all), "100%"), + Metric("l2_rfo_requests", "L2 cache request for ownership (RFO) requests per second", + l2_rfo_rrate, "requests/s"), + Metric("l2_rfo_misses", "L2 cache request for ownership (RFO) misses per second", + l2_rfo_mrate, "misses/s"), + ]), + MetricGroup("l2_code", [ + Metric("l2_code_hits", "L2 cache code hits", + d_ratio(DC_CH, l2_code_all), "100%"), + Metric("l2_code_misses", "L2 cache code misses", + d_ratio(DC_CM, l2_code_all), "100%"), + Metric("l2_code_requests", "L2 cache code requests per second", + l2_code_rate, "requests/s"), + Metric("l2_code_misses", "L2 cache code misses per second", + l2_code_miss_rate, "misses/s"), + ]), + MetricGroup("l2_evict", [ + MetricGroup("l2_evict_mef_lines", [ + Metric("l2_evict_mef_lines_l3_hot_lru", "L2 evictions M/E/F lines L3 hot LRU per second", + wbu, "HotLRU/s") if wbu else None, + Metric("l2_evict_mef_lines_l3_norm_lru", "L2 evictions M/E/F lines L3 normal LRU per second", + wbn, "NormLRU/s") if wbn else None, + Metric("l2_evict_mef_lines_dropped", "L2 evictions M/E/F lines dropped per second", + wbd, "dropped/s") if wbd else None, + Metric("l2_evict_is_lines_dropped", "L2 evictions I/S lines dropped per second", + isd, "dropped/s") if isd else None, + ]), + ]), + ], description = "L2 data cache analysis") + + def IntelPorts() -> Optional[MetricGroup]: pipeline_events = json.load(open(f"{os.path.dirname(os.path.realpath(__file__))}" f"/arch/x86/{args.model}/pipeline.json")) @@ -363,6 +520,7 @@ all_metrics = MetricGroup("", [ Smi(), Tsx(), IntelBr(), + IntelL2(), IntelPorts(), IntelSwpf(), ]) From patchwork Thu Feb 29 00:17:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208098 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp89931dyb; Wed, 28 Feb 2024 16:21:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCURdG3LyAyXkkziahSUhacPIxR619j58lgm+/8+b3E5YdDhLuaqwV1rRH2z61ApY/hzQjmbgcmnFUIV8OVSltbCOs7pEw== X-Google-Smtp-Source: AGHT+IHR35wBzE1bQ3qPnph+U1WhAVjuadbqP+FUkYdtwxrt+5J9uzbzyr8qoflem+7gYzzyLRt7 X-Received: by 2002:a05:622a:1347:b0:42e:8523:5706 with SMTP id w7-20020a05622a134700b0042e85235706mr675725qtk.16.1709166102519; Wed, 28 Feb 2024 16:21:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166102; cv=pass; d=google.com; s=arc-20160816; b=l+ik3ze9XuJOu/M9inTnyyEAwTgy/EyTYh8CNcHQL6qu+xmWMeA5X74rzjKhFdNNSq N1jv0c6hSDy2+7/Cjp7tNA3Ino27GymsVqbBDcnm9f1we7kG6XHcj7KqL2IGP+cv1K0x 7Imu2r8/7lhX1WhdLoFb18g559osbTNLM2bg+XF6cEyfAoBAHazSQV4aWVtUYXMvLbZz /Kg2PLfcz9IIys7StqNBjE9t7MKxIkKP6AvuXMr54YL1Kvy5gXxtVwKJri2CPKcKxhMm E/Lkmak5M2UB0yMgNQXBzU6829ebARGLacOs2dDWtyvtyXhPsR8B5wIDepBpCq1LB85C pYjw== 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=LvXKnLjoS9aTofIk7NbrGOXPtcvKKSLx7CVRKwsuqGc=; fh=SOEz11O+9ti5oznWjGihLptms8eMn3v051Qi02HickA=; b=BAhoE+A9uUB0BsJNs9ktM7GeV8eJBoO25jeSjvtaAjN+VAT+o6Z9E5DhjX0zAgoV/j KNtCcv6ru0YRD9RVAhCEr40hOB/W15xKcaU1EBwvJH6NqAG20cZgTFuDWaT0uc6PryUq LvEOnjbaisaiSnEoJ8rtEgB/QblvAdM6KYPo1TZixPDLEFJSPT/7gKCyOIJRrmyZUfzm pjowbrhNAo9kb06a3O3oNxgXbw//X2o03Su18rzU7oxZyt47BXxhmNUdoXjzLMimB72F Bm54xaq8S1BiFXd9KMMgCGwtOpowOCzb2p1NwdLfh8iA/YBRzZJMkheGHh/aNbFsnSGz ap3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RR0zNOB8; 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-85901-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85901-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id w9-20020ac87e89000000b0042e58bb098csi315111qtj.732.2024.02.28.16.21.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:21:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85901-ouuuleilei=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=RR0zNOB8; 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-85901-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85901-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 442E01C21AFE for ; Thu, 29 Feb 2024 00:21:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3AC525A781; Thu, 29 Feb 2024 00:18:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RR0zNOB8" 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 9794F56B88 for ; Thu, 29 Feb 2024 00:18:45 +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=1709165927; cv=none; b=APDdpS37ho+mMleXaKR1DiyrIQNnYMb8YXRpaOXB1gBfME7tAGMS+BlE4lSMO4EFwd62JsKF0NZGfSCpJlKXWRFN7ir+ZuxPxEX9zGibj7/j08FjFpFNf86bLBJtuEk9k0UeKEEK9LGlZj0ifNZwCqe2WS5QqPZYxXXKJAaoL+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165927; c=relaxed/simple; bh=UjJzZnr6R5qqlP0DPOq4yMkAe+ITwoRcLwikAmtf/Vw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=mflPjHg7I1dol5iy0SfrinEk29AuM1OzMjUTru4/HiSvpaOquFZIrEASZdWBsv7dPNzxC3u0GFq9338bswOM7TfUV8XvIshm8TkT85t50oKdGf4OsxbpxSo2aC2VemQdxQAoftDm/bDHgeFTmyYB62A1tG74BycrpBTUjSxu+Dc= 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=RR0zNOB8; 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 Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-60904453110so4401937b3.2 for ; Wed, 28 Feb 2024 16:18:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165924; x=1709770724; 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=LvXKnLjoS9aTofIk7NbrGOXPtcvKKSLx7CVRKwsuqGc=; b=RR0zNOB8QeKKDr9zT4ymzlehbUTq4Ui15grlGIksHGrCfIyyjAOYOiJOt4DcJh6ajy c6XTjZVtqxJrmvEs6J5P1xYa+Brie3id9EWJhH6Xan+7DjDFe6gkOz4RdPJnsXIXF+YG SpNn25aecQvBbZKxdv9/kbSGDYI/2mYDHzVz0a/CitmuVtZG6ZgOiRstDx9hY+7B4fzE 2A9ufSdW2NwyB9YQyEKK0l/iJm/lOl0uQgZOEwaJrueL0U+0LkBGeL385WQw3/+WqHS3 kc2iK5c0Kqk7Zp/d1gfLPaFRtyJFTn+Zg0XCV+J0ikkDTJK6oF7tLaMM9XrYwGo7s5i0 Cbeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165924; x=1709770724; 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=LvXKnLjoS9aTofIk7NbrGOXPtcvKKSLx7CVRKwsuqGc=; b=i23guB+MTQUrGIH/1XUJnId3jNu+3QPVoiRxCRovHr4aFuDny7Si6YUSbjjGtIit8W hjasm19Klvb0F+3kbW0o9rd5NQ8uHfDda1X3jtd4rv9vkeqTWoRoo1OTvr2bvH7XFQt2 1RNJPRapuHpyrMiiLmhEE7eLi70dRYAaocDP70zxygA4rG7iEdtZ+L6/w7VhzY5toVDa yIQzSyoU9o+QFrA//1nTthKhfpyO81OvMSGHCcb0wfpm6ca+g71Btv0YoJ96Mh5xIv05 zb7HaAMprGALQLZZlyirw0NK5YDsnQJq5ESOXbmkLH3neTLwIuFGbRLgnkhC92l7pEJB 7whg== X-Forwarded-Encrypted: i=1; AJvYcCUpXj5yDoC96P44hiog6UuSs+b+7x3yzAWDxBeA2t9mJyUN4LvF1kO9DRJkD8bTkovTlRISTqJgVg7QLqriqShLFEyQkIURK6k65Ji9 X-Gm-Message-State: AOJu0Yw8Men9zjQzDg+ZoeMVCnFsBoRaJMJnk0LX0zPq5A0zt9gk88Fk raKsq8nou2GxX1ophHCCS1GpB4jtLEixjtfxBtIpSjL3VmBc49fb1++UZlvm3X8f1aGsdzpnxQv lTBrbDw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:690c:a90:b0:609:185:67da with SMTP id ci16-20020a05690c0a9000b00609018567damr155415ywb.10.1709165924681; Wed, 28 Feb 2024 16:18:44 -0800 (PST) Date: Wed, 28 Feb 2024 16:17:54 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-10-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 09/20] perf jevents: Add load store breakdown metrics ldst for Intel 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: 1792190555025127613 X-GMAIL-MSGID: 1792190555025127613 Give breakdown of number of instructions. Use the counter mask (cmask) to show the number of cycles taken to retire the instructions. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 86 +++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index d22a1abca8d9..0035e2441d6b 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) from metric import (d_ratio, has_event, max, Event, JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, Literal, LoadEvents, - Metric, MetricGroup, MetricRef, Select) + Metric, MetricConstraint, MetricGroup, MetricRef, Select) import argparse import json import math @@ -514,6 +514,89 @@ def IntelSwpf() -> Optional[MetricGroup]: ], description="Sofware prefetch instruction breakdown") +def IntelLdSt() -> Optional[MetricGroup]: + if args.model in [ + "bonnell", + "nehalemep", + "nehalemex", + "westmereep-dp", + "westmereep-sp", + "westmereex", + ]: + return None + LDST_LD = Event("MEM_INST_RETIRED.ALL_LOADS", "MEM_UOPS_RETIRED.ALL_LOADS") + LDST_ST = Event("MEM_INST_RETIRED.ALL_STORES", "MEM_UOPS_RETIRED.ALL_STORES") + LDST_LDC1 = Event(f"{LDST_LD.name}/cmask=1/") + LDST_STC1 = Event(f"{LDST_ST.name}/cmask=1/") + LDST_LDC2 = Event(f"{LDST_LD.name}/cmask=2/") + LDST_STC2 = Event(f"{LDST_ST.name}/cmask=2/") + LDST_LDC3 = Event(f"{LDST_LD.name}/cmask=3/") + LDST_STC3 = Event(f"{LDST_ST.name}/cmask=3/") + ins = Event("instructions") + LDST_CYC = Event("CPU_CLK_UNHALTED.THREAD", + "CPU_CLK_UNHALTED.CORE_P", + "CPU_CLK_UNHALTED.THREAD_P") + LDST_PRE = None + try: + LDST_PRE = Event("LOAD_HIT_PREFETCH.SWPF", "LOAD_HIT_PRE.SW_PF") + except: + pass + LDST_AT = None + try: + LDST_AT = Event("MEM_INST_RETIRED.LOCK_LOADS") + except: + pass + cyc = LDST_CYC + + ld_rate = d_ratio(LDST_LD, interval_sec) + st_rate = d_ratio(LDST_ST, interval_sec) + pf_rate = d_ratio(LDST_PRE, interval_sec) if LDST_PRE else None + at_rate = d_ratio(LDST_AT, interval_sec) if LDST_AT else None + + ldst_ret_constraint = MetricConstraint.GROUPED_EVENTS + if LDST_LD.name == "MEM_UOPS_RETIRED.ALL_LOADS": + ldst_ret_constraint = MetricConstraint.NO_GROUP_EVENTS_NMI + + return MetricGroup("ldst", [ + MetricGroup("ldst_total", [ + Metric("ldst_total_loads", "Load/store instructions total loads", + ld_rate, "loads"), + Metric("ldst_total_stores", "Load/store instructions total stores", + st_rate, "stores"), + ]), + MetricGroup("ldst_prcnt", [ + Metric("ldst_prcnt_loads", "Percent of all instructions that are loads", + d_ratio(LDST_LD, ins), "100%"), + Metric("ldst_prcnt_stores", "Percent of all instructions that are stores", + d_ratio(LDST_ST, ins), "100%"), + ]), + MetricGroup("ldst_ret_lds", [ + Metric("ldst_ret_lds_1", "Retired loads in 1 cycle", + d_ratio(max(LDST_LDC1 - LDST_LDC2, 0), cyc), "100%", + constraint = ldst_ret_constraint), + Metric("ldst_ret_lds_2", "Retired loads in 2 cycles", + d_ratio(max(LDST_LDC2 - LDST_LDC3, 0), cyc), "100%", + constraint = ldst_ret_constraint), + Metric("ldst_ret_lds_3", "Retired loads in 3 or more cycles", + d_ratio(LDST_LDC3, cyc), "100%"), + ]), + MetricGroup("ldst_ret_sts", [ + Metric("ldst_ret_sts_1", "Retired stores in 1 cycle", + d_ratio(max(LDST_STC1 - LDST_STC2, 0), cyc), "100%", + constraint = ldst_ret_constraint), + Metric("ldst_ret_sts_2", "Retired stores in 2 cycles", + d_ratio(max(LDST_STC2 - LDST_STC3, 0), cyc), "100%", + constraint = ldst_ret_constraint), + Metric("ldst_ret_sts_3", "Retired stores in 3 more cycles", + d_ratio(LDST_STC3, cyc), "100%"), + ]), + Metric("ldst_ld_hit_swpf", "Load hit software prefetches per second", + pf_rate, "swpf/s") if pf_rate else None, + Metric("ldst_atomic_lds", "Atomic loads per second", + at_rate, "loads/s") if at_rate else None, + ], description = "Breakdown of load/store instructions") + + all_metrics = MetricGroup("", [ Idle(), Rapl(), @@ -521,6 +604,7 @@ all_metrics = MetricGroup("", [ Tsx(), IntelBr(), IntelL2(), + IntelLdSt(), IntelPorts(), IntelSwpf(), ]) From patchwork Thu Feb 29 00:17:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208100 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp90119dyb; Wed, 28 Feb 2024 16:22:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXqUMNCBHWp5RMmi53BqFcqSjBzpbvFh829U6QG+t8iuMiRGUXVoZd3Bct91y47ulTkyWoV7qiCkQak5wROHpkgcijTLA== X-Google-Smtp-Source: AGHT+IFypl3ht3LPJHn6E+s1rvFH4SvvtoLO4n4fL+In6DWe+BMv+8IhqrF2fhrGJ/46IadzoVXZ X-Received: by 2002:a50:ed02:0:b0:565:b456:4357 with SMTP id j2-20020a50ed02000000b00565b4564357mr293739eds.20.1709166133273; Wed, 28 Feb 2024 16:22:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166133; cv=pass; d=google.com; s=arc-20160816; b=jfn7YAMTHAFO2IHd4Iesg1XQP7Ot5Es456awVCq0fPHGhfqaFnzo0+WrPSsq3iXTFm UIdzAM4ZC9a0ZFzQmHtLynim6+fewrvffSOSCtSoD+RW+rV8KM2KWzli2Z9c4kBUjdzu 3Pb1YLBT4C+KsFJFKyRwAqbmzXtamwJdzBQjHsfd80yoFv5BeKFag5ZdKX4oEByQmrYW bP+sAt7gcw/OeWDIfwnkQ97KsVq35s8B0ceXz5UseaT/TJhr0ny+necIY4P8I49H0Xof WuzRWXL6BQCGyGB0k4PcgIeVLIwAi1+lkyZO9KwmOJmvt6JyDOPyHoohYpvG7G6H7OCW YnEQ== 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=+NpctYLw69wVy2quG2Men4l4HVGKm57XDegIiPRKOj4=; fh=D3IEQoyd91lQaArjCFAh/9o6M99hNbbNQ7ueIyB+X5A=; b=gq8x07f8YOBdyhn39K+oGi6V2q2j/1eS0i4NiJz/DX/AYim3m++qxvagz+3NNZyTEh Uo5C24Zl/befSUq3uINpiHldWPbGS3ACUPPC6Sde+fZ+f7nEwkB3aUJl2ijPWO1Zwvys n7wHh/94K5jgbb7ZKTS5MiTbEDRfOfQHKIMRjSe2ZY5Fxn2Q2pzrGIRUPg8KzRfsEzia mQUfow71NBeoNgKzYum+n4WHchLv988rEHLezapQoIF5No5xVEDpJAObbbnanw183Kza fEfxhNB49/PqRbdKIzMTXFJ2TGhkWm6Lp+ietS/yNxHOd9dVa0eElRVnz5bsvq9zGZ2q Cifw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=JwOhs7Na; 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-85902-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85902-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m22-20020a50ef16000000b00564574222c1si52053eds.678.2024.02.28.16.22.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:22:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85902-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=JwOhs7Na; 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-85902-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85902-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 am.mirrors.kernel.org (Postfix) with ESMTPS id A720E1F21441 for ; Thu, 29 Feb 2024 00:22:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 492F05BAE9; Thu, 29 Feb 2024 00:18:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JwOhs7Na" 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 C2AAF1CD23 for ; Thu, 29 Feb 2024 00:18:47 +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=1709165930; cv=none; b=RhnIlJI83NGodmsCm1VSBCxfZirPsZeqHndOo4xJm0qN4uO4PdfTlvsDdXR0G5oCh+j4eZFnfnatIEsd0eegSgW2ePe1AOxd6miqrlbqAAwrlVBWrgjmqDo1DIYwf29j+gGzb5WPqIqhcpJdcLM6XV/Ep5EnJI/unfqDwCWmDx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165930; c=relaxed/simple; bh=Eq3tg/JsCmJvAD5Ui2Tzj2WmM5yVtYEVdiyfvstEmk8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=GU5U4XopQP/RXInkEIzYOZoQw2eyQ9hmwgcwo18UoejHf83y0H1BK6UbThM91xRaqsD48swtZBuTJ9N3LrUPTMKj57+JF1GNmiVC32BSeTMdoVWWQL/b3HhYdXqOXaaQHmEeEmQ9orEmWz8dFIK2kfstYAOUu+7XsdhfFx98Yag= 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=JwOhs7Na; 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-dcbee93a3e1so605804276.3 for ; Wed, 28 Feb 2024 16:18:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165927; x=1709770727; 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=+NpctYLw69wVy2quG2Men4l4HVGKm57XDegIiPRKOj4=; b=JwOhs7NaUhl30dz4ea8HQ4nJwqr1dnNIWDyLMceO5eosq2kg29iQGPYnkt4ab7P136 2aUeUpj/k+bsDxzwZwiEze4A7tde9cXx3OaZhAOvAtK5B3yRA5aa8qtW1GVKTCaXkkSg KwUnexhgrvhUudDiQQd3hRowvMuGU2zpqIookx4gFingryVGwryOA3YhRLZQuY4ejKhW bvw78y5jEhBRDZsIVOJTI/PVW8pNQJ1Ig/jpJ2lsj2XOSvPFO5KeTJ1ywwjJFRTwfxxW /+7TwkWCat7WHdZWQoBLIUXbIpP14u//8bKG8lfv413X0U1EluD+LYycppNSbC4+TJs+ HAHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165927; x=1709770727; 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=+NpctYLw69wVy2quG2Men4l4HVGKm57XDegIiPRKOj4=; b=GHf7DEoAG2QWqzvKZMSdLzGXi/d2qUT/rW7tkdfYSkK+kGURKGMCS8xp61C9RCrsq8 OMfa7SRvNrHIN+08q/68p8lJkz4d8WsMojPakCCuHeuefPMdSmTYmGqu/+Din6PgjcRl 6ja6OcyQyyIftY3XTkbz2CAPqsF9dkXCo6TJeNVp6bWxO0OKBg6aB5mCnWvg65NHBAK0 i/jsaNxTt1AVHJ9l8P/zEEIA2rAgOgNeck3lVXuT7+GtPkQ8LVyNqsXGtHPGm6PiOsZ/ 0OWVRcg7pJrtNbUeux4I+cyHxOhn9EHT0EezNoQFp+R6FlA1uaVhr3srk6eP9WwcRNgB BTmg== X-Forwarded-Encrypted: i=1; AJvYcCVSA3srnEkHCAvsCqCgfeqoNMmtEdyRejaplQEGOiiGrV0eq5jj9QGpJr9plaQRXDNS6mkJDQwTefJuwdBAz1y+6xDqWdgOeJiCbegb X-Gm-Message-State: AOJu0YxePmncrfghU6PeqL9/MuunZmVyZXLy/DEQcOHk+muQDjXYsZ6z ACYRzxRKBaWye4mTCLbz2r8a/VmZ/iDc8rkPIzExYmKwrnCpuWDFmU2m55df+wCIpdw/so7BjK/ foxGDIg== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:1244:b0:dc6:e20f:80cb with SMTP id t4-20020a056902124400b00dc6e20f80cbmr44031ybu.3.1709165926883; Wed, 28 Feb 2024 16:18:46 -0800 (PST) Date: Wed, 28 Feb 2024 16:17:55 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-11-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 10/20] perf jevents: Add ILP metrics for Intel 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: 1792190587557804325 X-GMAIL-MSGID: 1792190587557804325 Use the counter mask (cmask) to see how many cycles an instruction takes to retire. Present as a set of ILP metrics. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 0035e2441d6b..0ca72aeec1ea 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -271,6 +271,35 @@ def IntelBr(): description="breakdown of retired branch instructions") +def IntelIlp() -> MetricGroup: + tsc = Event("msr/tsc/") + c0 = Event("msr/mperf/") + low = tsc - c0 + inst_ret = Event("INST_RETIRED.ANY_P") + inst_ret_c = [Event(f"{inst_ret.name}/cmask={x}/") for x in range(1, 6)] + ilp = [d_ratio(max(inst_ret_c[x] - inst_ret_c[x + 1], 0), core_cycles) for x in range(0, 4)] + ilp.append(d_ratio(inst_ret_c[4], core_cycles)) + ilp0 = 1 + for x in ilp: + ilp0 -= x + return MetricGroup("ilp", [ + Metric("ilp_idle", "Lower power cycles as a percentage of all cycles", + d_ratio(low, tsc), "100%"), + Metric("ilp_inst_ret_0", "Instructions retired in 0 cycles as a percentage of all cycles", + ilp0, "100%"), + Metric("ilp_inst_ret_1", "Instructions retired in 1 cycles as a percentage of all cycles", + ilp[0], "100%"), + Metric("ilp_inst_ret_2", "Instructions retired in 2 cycles as a percentage of all cycles", + ilp[1], "100%"), + Metric("ilp_inst_ret_3", "Instructions retired in 3 cycles as a percentage of all cycles", + ilp[2], "100%"), + Metric("ilp_inst_ret_4", "Instructions retired in 4 cycles as a percentage of all cycles", + ilp[3], "100%"), + Metric("ilp_inst_ret_5", "Instructions retired in 5 or more cycles as a percentage of all cycles", + ilp[4], "100%"), + ]) + + def IntelL2() -> Optional[MetricGroup]: try: DC_HIT = Event("L2_RQSTS.DEMAND_DATA_RD_HIT") @@ -603,6 +632,7 @@ all_metrics = MetricGroup("", [ Smi(), Tsx(), IntelBr(), + IntelIlp(), IntelL2(), IntelLdSt(), IntelPorts(), From patchwork Thu Feb 29 00:17:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208101 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp90225dyb; Wed, 28 Feb 2024 16:22:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWEMckxa9uCUmTQPPlDp0mnef1yMmsWetcc9nQvum+6Fbmgs0R0l7hIkJW2tkaawkcZkRQbtTYxQegBV54pVFGOlbVNgg== X-Google-Smtp-Source: AGHT+IG1qXs2DI4CS09hsiInu9GeKW0nA8j8KPIC8bEDJ9eC5XE7+75C946aeiSjyP2H+oF7oBs6 X-Received: by 2002:a50:85cc:0:b0:566:117c:cfca with SMTP id q12-20020a5085cc000000b00566117ccfcamr312583edh.4.1709166148847; Wed, 28 Feb 2024 16:22:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166148; cv=pass; d=google.com; s=arc-20160816; b=Xqma5mUfdQn44AgdzaVOB69dQ8RobRCVvUrX0sg3KpbOet/8pcqZmi5/9zlq3O319E PLS13DGrgVx7iG2mmxSil+TyJ6vFWJSVpYfaRz16j/3Jwk0ZLLKorneidBVp7Z6VFJNT O36afFWf7zb9ofWckWB2lQlmBsvjH8gtuZIOtDmdbetwXorjMIBwbsbhdJwRvETxkC3U oMW76JSZb2LOMGZ6tEIwIhJ/u3/u1cmIt7Hzvn9/FU61UnQH+W2R82fjLZEyBo1mBT4M StZAwuVb9RZWFJlHgXD9eCGx6LCf696pP2Ek88QtMtQHhQ+sLFZE+t1L6dwgGii7I7HM 7EdA== 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=BJrxbtjXZ5o0JjkZHH3aEb9P2cYPenOBkdypf42wLcI=; fh=6FVmID0gisKye/jwTp0Qx58Yg06NnXZhA13HhphyuVw=; b=D2uvp5UynxWfs54ZQfGz8391rTvov+53z4DheD107nI/OoRBInlS7TLQB/3gwcIfk2 cuNf/X/+CLuSLK6908LlSduD0dZxbJzt6kZLJSqNC//MXDNz084UP1JpM4iNysNSv6i0 K5Inl6sUUT6hOh1RV2B92OySVrWWIgChxOnvWaGjP+InISdVL+vLfb+Puz6cdKVOikIG mNPW8PFm022LcArG/vNxQSmplOO2t0XE2GS/ypN40MifQgqMKDEFStSqgNPOjsqDPup1 VUH7o7NPpTh1fnhYpf2HSqwDWlBFoTmerXrSmtiUU9LPnvynfPmU5lQxPT2mijaol6Rt yinQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YzaDeDaz; 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-85904-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85904-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g8-20020a056402090800b005669c0be0a1si59356edz.163.2024.02.28.16.22.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:22:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85904-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YzaDeDaz; 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-85904-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85904-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3C1AD1F21089 for ; Thu, 29 Feb 2024 00:22:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDBE75C5EC; Thu, 29 Feb 2024 00:18:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YzaDeDaz" 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 ECAAA58104 for ; Thu, 29 Feb 2024 00:18:49 +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=1709165931; cv=none; b=n6OQGiv4Uw1WGl8FXOYXSLPRcrj4HGaMbSSSu0YdJYBxQRGdm6S3XCw1ZLmNGHlf7jhAoVXtc4eGfFuUFiX/jw788OuRQfeqLpWwW2ZeaFtjuXV3yzXj4kDhAIjKKAUEyB679573JQrYX1i8REH55VuK0EPSl5TeGHu4HPZUOzg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165931; c=relaxed/simple; bh=ky/hxGqHiEPNUXC5YpHVs6vSUyZz80sm9NdbvegFkVY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=SIPgdEtyatPS99x3KxEc2pmn31cgiUZ73THYl+OXjl5ko29HtMDfbqSvy0JPmGr2/Izck/3rveQrCW8uJNSjT7gV3xyMKYCMPhOOO8f6GH3YMXdqaW/s2+S+wfuQ5Ev1ILvJ6+fMQH3Zcju0lO5CCalfCKBiYwPJ/VfTgNBFK08= 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=YzaDeDaz; 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 Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-60942936e31so6125967b3.1 for ; Wed, 28 Feb 2024 16:18:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165929; x=1709770729; 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=BJrxbtjXZ5o0JjkZHH3aEb9P2cYPenOBkdypf42wLcI=; b=YzaDeDazio6WwF+JPxPXpfaFUOQ9x/OMBIxGCUN8m0fwdSO2lw9UmaxgTSu0LUc+VG zpzQeEFu54SBwTw/5a3vZMSZ8nrh+fDV8xIy2z1jxqU9//KzoJq4vYex5Iw2V9SYp48z 2eayrNzEsz9X8/wpap2vpsHkqqCq40vyArcqxP4H2HLW7544L2wg4P6SHgMLm1JHzyVa cH8St+39R09/R09pXuSEsr1saPrng479rC89NxqItSij6mO5svAzRu/FLT85v+4fua6G T4k0W6lCz9WhDeN0IaChpFUYKGyHySVX1eHa+9e/39zIpHullEhdTld/T8uBaJyUOb46 +NSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165929; x=1709770729; 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=BJrxbtjXZ5o0JjkZHH3aEb9P2cYPenOBkdypf42wLcI=; b=oApo8qpt/CoNAdJ+42Y2vUaZHfpyuCHdPwDBhN0sde7J7C3lZdmb9U/Zqrkn2P/wPN 7vO4CJs6QJTOATM9GpRgPu9tt51PCl4rlSMb+bD/3nVmCacDk3KLLDNtHsfsrMhelGn2 L7zXaeq3hWtRCftoLdMp2o9NRTtzoyLSnFg9v+C1m9D35EjgZcVlmJsoGVttuu6OON6r 0K70vZDiPDiYniK8vBMiW6/Yr6vPG5F8HNtLp+UMfWUME0C3MvCATDfijSYBn//beJIc mnVf29HtOwj7G90Rq6tVMRDS0XmyxO+Y+UEaXWqJjyOFdgyXIcLWKoDMS4vNqwZ1ehlg A30A== X-Forwarded-Encrypted: i=1; AJvYcCXn6xsv+AUso7G/zYLRe5GMSJzaLgxM71SImFmvCAb/W3ANg0F1IMGe0953D7W/oqzlYYPh6ExsFIFr1uqY+Q73kPsGIq+DFfsxu3iS X-Gm-Message-State: AOJu0Yz+oquCZFuY7Qx988NQsJTrZRkBK4MUnjwxb1CrQzM1msxRTgGa 8GeDnXkPB14exlkDWzMWELg8AATNSg6VH0oEaEp31r25mQ+j/jZnUNOXDzoBc2zf4+UxPLKqJPI adUXRRg== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a81:4c17:0:b0:609:2455:da6 with SMTP id z23-20020a814c17000000b0060924550da6mr154107ywa.5.1709165929121; Wed, 28 Feb 2024 16:18:49 -0800 (PST) Date: Wed, 28 Feb 2024 16:17:56 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-12-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 11/20] perf jevents: Add context switch metrics for Intel 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: 1792190603858841927 X-GMAIL-MSGID: 1792190603858841927 Metrics break down context switches for different kinds of instruction. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 55 ++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 0ca72aeec1ea..6ee708e84863 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -271,6 +271,60 @@ def IntelBr(): description="breakdown of retired branch instructions") +def IntelCtxSw() -> MetricGroup: + cs = Event("context\-switches") + metrics = [ + Metric("cs_rate", "Context switches per second", d_ratio(cs, interval_sec), "ctxsw/s") + ] + + ev = Event("instructions") + metrics.append(Metric("cs_instr", "Instructions per context switch", + d_ratio(ev, cs), "instr/cs")) + + ev = Event("cycles") + metrics.append(Metric("cs_cycles", "Cycles per context switch", + d_ratio(ev, cs), "cycles/cs")) + + try: + ev = Event("MEM_INST_RETIRED.ALL_LOADS", "MEM_UOPS_RETIRED.ALL_LOADS") + metrics.append(Metric("cs_loads", "Loads per context switch", + d_ratio(ev, cs), "loads/cs")) + except: + pass + + try: + ev = Event("MEM_INST_RETIRED.ALL_STORES", "MEM_UOPS_RETIRED.ALL_STORES") + metrics.append(Metric("cs_stores", "Stores per context switch", + d_ratio(ev, cs), "stores/cs")) + except: + pass + + try: + ev = Event("BR_INST_RETIRED.NEAR_TAKEN", "BR_INST_RETIRED.TAKEN_JCC") + metrics.append(Metric("cs_br_taken", "Branches taken per context switch", + d_ratio(ev, cs), "br_taken/cs")) + except: + pass + + try: + l2_misses = (Event("L2_RQSTS.DEMAND_DATA_RD_MISS") + + Event("L2_RQSTS.RFO_MISS") + + Event("L2_RQSTS.CODE_RD_MISS")) + try: + l2_misses += Event("L2_RQSTS.HWPF_MISS", "L2_RQSTS.L2_PF_MISS", "L2_RQSTS.PF_MISS") + except: + pass + + metrics.append(Metric("cs_l2_misses", "L2 misses per context switch", + d_ratio(l2_misses, cs), "l2_misses/cs")) + except: + pass + + return MetricGroup("cs", metrics, + description = ("Number of context switches per second, instructions " + "retired & core cycles between context switches")) + + def IntelIlp() -> MetricGroup: tsc = Event("msr/tsc/") c0 = Event("msr/mperf/") @@ -632,6 +686,7 @@ all_metrics = MetricGroup("", [ Smi(), Tsx(), IntelBr(), + IntelCtxSw(), IntelIlp(), IntelL2(), IntelLdSt(), From patchwork Thu Feb 29 00:17:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208102 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp90309dyb; Wed, 28 Feb 2024 16:22:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXgfirHHQnHIusc4SpRXZUX8taFjt8qv+zPu44VmNxucobBnbdE/kGD/2i2R6oQZZviTeEWScOqoQBPP7z+eVvGPJOutA== X-Google-Smtp-Source: AGHT+IF5YKdMxTq6YD/vVKBlF6GN1qFM/CszdCBIRjLorQzTwqtROnkp2GnvHnmQgAeEArJIP15k X-Received: by 2002:a17:90b:4d8c:b0:29a:57c6:bdfd with SMTP id oj12-20020a17090b4d8c00b0029a57c6bdfdmr778923pjb.17.1709166163045; Wed, 28 Feb 2024 16:22:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166163; cv=pass; d=google.com; s=arc-20160816; b=AEVRiFSGxWq9aqJ6I5GHzsJGCjlckK7iKndjt3yLXDcRPzjJlRKG9rpVbmBe5ah4kO wEQxHiBpumDftBaHoIKhHIC6ulyIRk2ZToHFtdtQlM2nu8HE2WQo+cGIizxlpD0zZXmp 2xJLxzbW81Y+1jkNWytStjWePfDX2tD0vkB8xPzFA8z5onOueD2vySyLOI9QDClyjGLk IPOn8rtc0kCZTa36jTAp2XIFempRUZfPvNRQhYk0c3ZN9ibchXhLfXvpb4K22UZjdZ21 TwVOfiRdP5u2ESBr4vDKepXUaPCV1YQiaHiuabeewIUZjbzdC9J34NBkm7iF1ZTyP2WB +NFg== 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=D9n/LydSsWhh8X4HCatLjTPGCEDU519H/3lA2USzD/Q=; fh=ePTe8fbSF9iFlKpe9T/9hVNdgl07DYvQeH6pYCRaEz8=; b=cdnKwg7Q2i1SjAhbirggV1CF9ypbsTwoH8m7rK0xTLbvAaTifmxcGXHn0PIEeJA45H 1lFdyE92uAMtBKtTBgVyMPrasb42k0FQny2+/efsYvFqfNXmeIhA8oZLMnUp1d/19wqB VMnrTLlJAPDY7D0+upyokuYWUQQG5QneFIHoU/10yWHvkWxUifiPGXLkGdUufaFXUtsj /Mcd+9jmLiFRPpC/dWj7FZFWhFX1p6gndkB5ntxRLa5ymsjUIE2Dpapp1HuXOOJMBAJy 8UOC16/SCHhIDqfozMaFp7oCX/igb9TsrwkF7XtLboWbogiZKf3J/sYHsi/QU2nIDPPg hyKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=LwXLDHV5; 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-85905-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85905-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y2-20020a17090a6c8200b0029acaa59f3dsi308147pjj.2.2024.02.28.16.22.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:22:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85905-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=LwXLDHV5; 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-85905-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85905-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D12F7285149 for ; Thu, 29 Feb 2024 00:22:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BE065C8E1; Thu, 29 Feb 2024 00:18:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="LwXLDHV5" 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 64D575B676 for ; Thu, 29 Feb 2024 00:18:52 +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=1709165934; cv=none; b=SpBAbDVN59R5oJBV7h/3B02aIrW4WIGZUid0Q1uCvarBM3kX8N/js7Vj0nz8RTXwXUvpYZOtt2bRS83iXMPQpgDrGjS7qzhMyNK6h0cTsL8idw0voYOQWah7p8+uchP8ZpliJlRWQ5aulb9ASb9d/VQZzdt7ZXrKowCu35uqBgA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165934; c=relaxed/simple; bh=RoQ1W/NshIyvCHXY6NTFpS7T0JU0YBtNXF8QOlBoiBc=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=pZOm/EPcgDeGlQa7IcVNNeTfeXE5WageAbk8XX7oadgck6+WY+kOnJFT6fhP7nPDMg8eOFA8V4L1oBhRmeB51yusdMA3/i7bvf6lg0yeFfcY1T/RvFxsbm95ufn9HyGUXQM+Lizvz+DokZBmShM+4HO1mJseqO9ZiurjpwIkSaI= 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=LwXLDHV5; 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 Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-608d6ffc64eso5259657b3.0 for ; Wed, 28 Feb 2024 16:18:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165931; x=1709770731; 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=D9n/LydSsWhh8X4HCatLjTPGCEDU519H/3lA2USzD/Q=; b=LwXLDHV5wo+aNP90JaDftPEmq+JdDTH2jn2MGmqR83KNvvHElTfITFzrJqu+03mQ8S 5Y9grskiB3qpV3v9ACr7T4H4b8vZ33NZBliYBzAaK7Drx/DNt2et+srvhsu5fS7doyiF wHhVDBOxtMbTWfzEgHqGON8E4zrCqI02sr4zeN1YTMzEXD+fLM1cJGQzKR2r6VD9gYDg er8/lJaS3naax0noTEqeoBnYqml8gQD/Htja1IWjiW/mqy6bw/EVxk6cSmqFN18fuJhk z9vumwAj655vbcYkBMO6r8pNqqbKEF0XFl2UfDb/npQ+RiPRcutv55TEmVP7InKCmZuw rBAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165931; x=1709770731; 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=D9n/LydSsWhh8X4HCatLjTPGCEDU519H/3lA2USzD/Q=; b=rLLzDBcQ3Qgsmn8ho2S1Wk9I63MKXqsuBitFRuEMqfcFmBCMoLqYE7Lrf1UfFCHRgB H80VlAdgn64STZIY3vIOJeXH5IbCSAcOdfzqPUkAUpWqg9lJia3cCEwikdJzWMRSbhWC rNS7Hlyz09AU2MS4ejXRiIQOVXizAzejYgIcRq9p2FjQovDEn67J8rGTui3KPZehU0pg VYJNOTDChw516z0iGAv0IZD9GvEdBzfWrun86o42eN9vBYp8/AQC4b4UJnFgB6T6oIE2 fyRiZyG/sCq/UzMxyk6nVy+80uG1JtGU92g0267S8HFMdzTA1sg0ohdu0LxH2Dt4ItMw VCjA== X-Forwarded-Encrypted: i=1; AJvYcCXClC6T4kvksvcw78V3cEiU6WWrtXNlVICohq9ozO1PHxyX9vJCHKE77o9NOI/MeqEqa1e2QchD+JJuDvnu46YlmeT2WZwUu82o3JpO X-Gm-Message-State: AOJu0YxdybGn9kmWdfLTBQtedJFW2vYFiElaDsQVu09NlgWmIvRIgFyi SbO9K0tHAppmGl4zvUBOUU7jq2mJFZchmvi69dSBJksq1qwfi9nlfhWfhDRqWqpWVFq8RTldQCF v8ByLJA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a81:49c6:0:b0:609:5bd8:de84 with SMTP id w189-20020a8149c6000000b006095bd8de84mr54268ywa.0.1709165931456; Wed, 28 Feb 2024 16:18:51 -0800 (PST) Date: Wed, 28 Feb 2024 16:17:57 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-13-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 12/20] perf jevents: Add FPU metrics for Intel 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: 1792190618905053721 X-GMAIL-MSGID: 1792190618905053721 Metrics break down of floating point operations. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 90 ++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 6ee708e84863..dae44d296861 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -325,6 +325,95 @@ def IntelCtxSw() -> MetricGroup: "retired & core cycles between context switches")) +def IntelFpu() -> Optional[MetricGroup]: + cyc = Event("cycles") + try: + s_64 = Event("FP_ARITH_INST_RETIRED.SCALAR_SINGLE", + "SIMD_INST_RETIRED.SCALAR_SINGLE") + except: + return None + d_64 = Event("FP_ARITH_INST_RETIRED.SCALAR_DOUBLE", + "SIMD_INST_RETIRED.SCALAR_DOUBLE") + s_128 = Event("FP_ARITH_INST_RETIRED.128B_PACKED_SINGLE", + "SIMD_INST_RETIRED.PACKED_SINGLE") + + flop = s_64 + d_64 + 4 * s_128 + + d_128 = None + s_256 = None + d_256 = None + s_512 = None + d_512 = None + try: + d_128 = Event("FP_ARITH_INST_RETIRED.128B_PACKED_DOUBLE") + flop += 2 * d_128 + s_256 = Event("FP_ARITH_INST_RETIRED.256B_PACKED_SINGLE") + flop += 8 * s_256 + d_256 = Event("FP_ARITH_INST_RETIRED.256B_PACKED_DOUBLE") + flop += 4 * d_256 + s_512 = Event("FP_ARITH_INST_RETIRED.512B_PACKED_SINGLE") + flop += 16 * s_512 + d_512 = Event("FP_ARITH_INST_RETIRED.512B_PACKED_DOUBLE") + flop += 8 * d_512 + except: + pass + + f_assist = Event("ASSISTS.FP", "FP_ASSIST.ANY", "FP_ASSIST.S") + if f_assist in [ + "ASSISTS.FP", + "FP_ASSIST.S", + ]: + f_assist += "/cmask=1/" + + flop_r = d_ratio(flop, interval_sec) + flop_c = d_ratio(flop, cyc) + nmi_constraint = MetricConstraint.GROUPED_EVENTS + if f_assist.name == "ASSISTS.FP": # Icelake+ + nmi_constraint = MetricConstraint.NO_GROUP_EVENTS_NMI + def FpuMetrics(group: str, fl: Optional[Event], mult: int, desc: str) -> Optional[MetricGroup]: + if not fl: + return None + + f = fl * mult + fl_r = d_ratio(f, interval_sec) + r_s = d_ratio(fl, interval_sec) + return MetricGroup(group, [ + Metric(f"{group}_of_total", desc + " floating point operations per second", + d_ratio(f, flop), "100%"), + Metric(f"{group}_flops", desc + " floating point operations per second", + fl_r, "flops/s"), + Metric(f"{group}_ops", desc + " operations per second", + r_s, "ops/s"), + ]) + + return MetricGroup("fpu", [ + MetricGroup("fpu_total", [ + Metric("fpu_total_flops", "Floating point operations per second", + flop_r, "flops/s"), + Metric("fpu_total_flopc", "Floating point operations per cycle", + flop_c, "flops/cycle", constraint=nmi_constraint), + ]), + MetricGroup("fpu_64", [ + FpuMetrics("fpu_64_single", s_64, 1, "64-bit single"), + FpuMetrics("fpu_64_double", d_64, 1, "64-bit double"), + ]), + MetricGroup("fpu_128", [ + FpuMetrics("fpu_128_single", s_128, 4, "128-bit packed single"), + FpuMetrics("fpu_128_double", d_128, 2, "128-bit packed double"), + ]), + MetricGroup("fpu_256", [ + FpuMetrics("fpu_256_single", s_256, 8, "128-bit packed single"), + FpuMetrics("fpu_256_double", d_256, 4, "128-bit packed double"), + ]), + MetricGroup("fpu_512", [ + FpuMetrics("fpu_512_single", s_512, 16, "128-bit packed single"), + FpuMetrics("fpu_512_double", d_512, 8, "128-bit packed double"), + ]), + Metric("fpu_assists", "FP assists as a percentage of cycles", + d_ratio(f_assist, cyc), "100%"), + ]) + + def IntelIlp() -> MetricGroup: tsc = Event("msr/tsc/") c0 = Event("msr/mperf/") @@ -687,6 +776,7 @@ all_metrics = MetricGroup("", [ Tsx(), IntelBr(), IntelCtxSw(), + IntelFpu(), IntelIlp(), IntelL2(), IntelLdSt(), From patchwork Thu Feb 29 00:17:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208104 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp90386dyb; Wed, 28 Feb 2024 16:22:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUeUnA2YzvCM6h6PDAQ1swggatPReeKZLwJyuPqIyAgMoDEmrJquKyaoJNfYzbISBJ5ZG11trFN6QfzhVRoCoG2wRw50Q== X-Google-Smtp-Source: AGHT+IFXlR97Z5COEsukbWCA+0KhR1IG8nv7sqtfbfTjhV3sZXpwN/R6yX4YBsq23uD0DYk1dFyU X-Received: by 2002:a05:6402:528c:b0:565:e2ee:3079 with SMTP id en12-20020a056402528c00b00565e2ee3079mr374492edb.15.1709166178534; Wed, 28 Feb 2024 16:22:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166178; cv=pass; d=google.com; s=arc-20160816; b=cXWK1rrvtP8yXnC7LK+Ey3KgeScI7X+o1vhJtSSrfeIzd7NyaCT8/XKD6/AeI6UMtd eu7iB3PiaBYjmtv1jtplSK4lEBdjPAvKnEy6bKeK6X7KcWMZxWkfDVl92KxSXyBPqIVZ UxJivJ6mTpvJOm7PAxcxvy1Y8pNf1OdP8Hm9IFqAFtbddpJeSxLFfd3hdXdIkQRBRPrk YDIrSXOW+yLBEBeY7y5t1YMROvDHqlgsQNEtDMv9t2EchS7UIM12lGiLipZAhH6TBAH0 D4wOgsw36tNRkgMMyjDwUuNOLET7dzmksoK068PhDwA/nsB6s8vAA5SAnbVpZ/LqCE66 JJ6A== 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=nEWMbeD73ltjKkx6wjteD4TdhZhnTqNw+z4QfFdR0Xg=; fh=yuf2r3hBiI/TLwPbI98an2/7NeMzGgDYowb8iY6Oies=; b=xumNecwYsiK/bkKNqSitMToEwlLNe6+magx+LfdP6Zm4eMUhE3EZ2b/3QVAFG6d63g AUEl5PX0s8VV998yqNkos2TGFfoUx7a6DsNp5ZNFAgHmdOIwXdZ3G+eig7vbKlny7wbe HXx1vKhT6UJ8dCBYuXS5Aam295EzPXPoBDygFdOiEZsPD+JHcEhh/yvrTEThsm5o7MVQ ZCTo+s0YgY0Pvb1sDBRcA8RF6XoBr+EnHyCQ2QRjEZafJjEVsn8V+8Fe+oUxVvO0l85Q sjrYpJc00nEV02NEpR76EuvWJ/fFajf7ZBSHTOhR0g6tDKjrf9MutWU6TMOMjgsbHhNe w1Gw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=cv5Mz9Xn; 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-85906-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85906-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a22-20020aa7d916000000b00565d73c1abfsi54665edr.377.2024.02.28.16.22.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:22:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85906-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=cv5Mz9Xn; 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-85906-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85906-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0A2851F2326D for ; Thu, 29 Feb 2024 00:22:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 942545C8E5; Thu, 29 Feb 2024 00:18:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cv5Mz9Xn" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.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 2F93D5A0EA for ; Thu, 29 Feb 2024 00:18:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165936; cv=none; b=nr3buHyCS7PahX1ulNkCVO9mRez3Qk3cxuYwII1Af3dC5OFHHCsNDEeDGWnse72oG0/3iviDFpWsaJ+rm5Ux6LlGpLWtf28L4cj8/afQOGHDo/JiPsiVL1ZKnrUBRoIGKZjwcO01bQv9eFFf2dfLwHExLhKnBfDI4BI5oIZzPCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165936; c=relaxed/simple; bh=v5ABchTQpnOktYWaziSCuW1XX126+T9HD5NGgP4r64Q=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=qdQS8FdzDKpslGOQgDtGku5hvkaTf0mBxOU8wqioq0iCkOh1Ni6qn8q8/JVMMmEWw7PcKMDo6oKcwuH8RsrK1wpuubmTcQzOYZ3WJWvgxVRHlmyjaDmi8czFZWnI9sLYDdoAPbcsEnFLXAC9Y9DKI5bMvSd8da39Imvd/Hk0nj4= 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=cv5Mz9Xn; arc=none smtp.client-ip=209.85.219.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 Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6dbdcfd39so705879276.2 for ; Wed, 28 Feb 2024 16:18:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165934; x=1709770734; 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=nEWMbeD73ltjKkx6wjteD4TdhZhnTqNw+z4QfFdR0Xg=; b=cv5Mz9Xn851PoHzwY/s7tDctOCA1uwhB84iMDCNAWRukfJB5/61FSTKs0BUFAZ+oYn ABhK2ZAqwsTETsRP36y66QwLGBTGGg3gZR2oJPucKHoXrqi9UFxf9iwWlcboB71s0gvx oOknQGF4vB6+boswVezJnRQfgnhoWuRYhDEXW+WfqZwFzT2UiJz3BZAQM4RlM1PuCjrB 0VkvGCCQKajdsCwsLDJ0t8IcBgwobZw2u6VQRhUnasHddcoh87xiEUZkAmEfKYpHE30Z zJoztG8o5CaO/Prq69rhZLP1IVEq/j4jmE2+Hvy4APEv1HnTbeHXBSMU6e2XtGiwN7J9 OWVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165934; x=1709770734; 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=nEWMbeD73ltjKkx6wjteD4TdhZhnTqNw+z4QfFdR0Xg=; b=es9CkG4z85dwXvImo463u8cjDdP5zoJdR0WIdDHeg/DNIVyOPXdpj3oQy0tX3+VJHD rVTOngv7X5rGwwUc/hKDs+ocWuJ6SvnCT2fJqyNsUF+/6dh+s8/r0qIXD2KS/QlCBLsc VwYcexe+MSQTzzbDz5CbPKM3D7ptt6BPzy5FDD1Q6K9SY2aMuT49U2yiMP7n2yEQ2hvV No9zQo1q9U4158KqCE5kOwJqS52VlARHZLT54aXrWuC9oNBrU7tpVBhto0Fe2NPhVgJ5 6tD/ZaHiLjqVOUgM3gqOUJdMtc92BiXdhFJuoDSNDt71c4X2Eb9GF3I+tsaaSwy+o9qJ N9ag== X-Forwarded-Encrypted: i=1; AJvYcCUz514+ssvJscIz/gCUTQIXhAzK8zMD2HZLvnl0114H8zqleWdzq4n5wH4J6a476OpEwzVa7d3mTsqeD9vQfpYRywMEH+dtARu0cKeD X-Gm-Message-State: AOJu0YwKNw0HQIfApvyeOEUd9oUxB0oERMOfxRIkrq3hzmEty0iTrVeJ kaTskZlihob0x2i09gwOb+HFr0R01Vh1ZheEkSQoKiBNxTuR7TqSkUgAGFWYhl/T3LttNpqfwKh cSmhTEQ== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a25:b225:0:b0:dcf:6b50:9bd7 with SMTP id i37-20020a25b225000000b00dcf6b509bd7mr214560ybj.7.1709165934246; Wed, 28 Feb 2024 16:18:54 -0800 (PST) Date: Wed, 28 Feb 2024 16:17:58 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-14-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 13/20] perf jevents: Add cycles breakdown metric for Intel 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: 1792190634838904640 X-GMAIL-MSGID: 1792190634838904640 Breakdown cycles to user, kernel and guest. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index dae44d296861..fef40969a4b8 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -26,6 +26,23 @@ core_cycles = Event("CPU_CLK_UNHALTED.THREAD_P_ANY", smt_cycles = Select(core_cycles / 2, Literal("#smt_on"), core_cycles) +def Cycles() -> MetricGroup: + cyc_k = Event("cycles:kHh") + cyc_g = Event("cycles:G") + cyc_u = Event("cycles:uH") + cyc = cyc_k + cyc_g + cyc_u + + return MetricGroup("cycles", [ + Metric("cycles_total", "Total number of cycles", cyc, "cycles"), + Metric("cycles_user", "User cycles as a percentage of all cycles", + d_ratio(cyc_u, cyc), "100%"), + Metric("cycles_kernel", "Kernel cycles as a percentage of all cycles", + d_ratio(cyc_k, cyc), "100%"), + Metric("cycles_guest", "Hypervisor guest cycles as a percentage of all cycles", + d_ratio(cyc_g, cyc), "100%"), + ], description = "cycles breakdown per privilege level (users, kernel, guest)") + + def Idle() -> Metric: cyc = Event("msr/mperf/") tsc = Event("msr/tsc/") @@ -770,6 +787,7 @@ def IntelLdSt() -> Optional[MetricGroup]: all_metrics = MetricGroup("", [ + Cycles(), Idle(), Rapl(), Smi(), From patchwork Thu Feb 29 00:17:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208105 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp90471dyb; Wed, 28 Feb 2024 16:23:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWafhg7iamq/g0aHMbGlO/BZARTNlokLF1dQWss2RJokg155yKC3GDNESdA037HCHjlfH51u2+kvzjaWDO/wyHrtYMeKg== X-Google-Smtp-Source: AGHT+IFHoUh4IP2XUtQWJSzZ6nPpNQRxB8i/P6tBimFw7Im1ol1hZKV9ZI3VV0aX6jzXO3AbePye X-Received: by 2002:a17:906:513:b0:a43:6136:60ff with SMTP id j19-20020a170906051300b00a43613660ffmr246605eja.72.1709166192429; Wed, 28 Feb 2024 16:23:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166192; cv=pass; d=google.com; s=arc-20160816; b=cT8HGvgezDXUCdulaLNpjKrzTdLm3Sy9aUp0YrU1tBb7FgD1hINFSsNIBKkXZgPASJ eXprRo5/+LQgktrxADrzW5Y8j6xtdsXST47DF9o2Ocafh9Iw3iN1vqAmgt3zF6hjfVaD N6g3bIbQD8+Pjxl6QOQ6oyMJG1p9B8/FG5ufiweJeCiWkm+Rw0C0Bkf8BIK1j0hrGwFd gwuidOOqdY5vW9t83N9eoMVKq0XVsDOv2eATvFo8K4WXTkFi4/uRbFTmuNw7Ps12nws/ 2w9YGplJIz3cVvQ4NnCMxsi2ZV0wObUMyL/WGRzbsx7fNg+F+7vm2pE6cY8mjqi02VFv Fryg== 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=Wt3W9ZcbAW1zDD9azPxHXaT0ia+NyzLn1A0me08+DuM=; fh=vQsjuI+OOhq0i8jeF+l+tUNcKmInjnt3dOGEJCasEJ8=; b=oPETVfXzatfMrHVJu158B/kRKxFnb368GFkJX11+I50JjAQKgawwoYYqm5tvSepLR1 SWoe6EPcy9VwBnddgen357U8w685LOdORHIj1FNPHNTdWMBVOMecOwIdKyFV8hgZpUl1 M6f6BN514wINGeJ8IY9xV6mGbAinugML1k2eTaCnTZQOzuN7Sx7JMuRRhUBHuclU6HL1 n6MPbJVAKNsofny5qWQzeDm3y2WkxHv8zq+kz95uxQdXUGzBYGxMvMg5/To6ODeI79Yf HHpaXgochQB3CNvW620Mta2FszN8Cks5jm9GPgQpxHQt+QEdz90+duRiASeqDSXFhcYo M65A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=L26MF88Z; 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-85907-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85907-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e10-20020a1709062c0a00b00a432eeb13dfsi57861ejh.368.2024.02.28.16.23.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:23:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85907-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=L26MF88Z; 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-85907-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85907-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 am.mirrors.kernel.org (Postfix) with ESMTPS id EC97D1F220DC for ; Thu, 29 Feb 2024 00:23:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F3B845D492; Thu, 29 Feb 2024 00:19:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="L26MF88Z" 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 651005C8E0 for ; Thu, 29 Feb 2024 00:18:57 +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=1709165939; cv=none; b=SelaJQkRU0etQMWGScSvKT5ojtcdY7h5xISm0mNiCrW2rnA+2e79TNI29a+Bc5lFBVCxBzy1hGocWDGo5V+5WnRLDBhoDrdcZcSKcu2djrWx+UUxTLTDyGrmBVc5xh0AhJ6diz9v8NkCDIIrJMhjX2O/bvNy8gLDjtjw9VTlU50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165939; c=relaxed/simple; bh=Qu4qP63a5Y9CrGCImGaK6yBhwp9wAZMVltq+qFK/h0Y=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=MLsAhsMPDaLcv667OhLbuRuY2F9Fe2CNElsoDR2CEkBYd6SDbyi0yAj2mkcSX21Z5HbhJQo2544Ql5WZsH/q2PsPbrojc6JdO8tcGMb8dvAMbj27YwBrirJk71tLG17yy5eB/78uIn8piMuaLxHapn6+6QJbh+ZqgFPcBNgBLXs= 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=L26MF88Z; 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-dc6b267bf11so444944276.2 for ; Wed, 28 Feb 2024 16:18:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165936; x=1709770736; 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=Wt3W9ZcbAW1zDD9azPxHXaT0ia+NyzLn1A0me08+DuM=; b=L26MF88ZMojJIDofhZMd9KkyDI4vGYuhVr6qdWGL2YZZ+e42LlE1EIQgGqy7e+z2yR 0wnghwy0hlKHKV/z9VeVqu9x4L0ydd+zWk95/nQpRFZEjtjSQYQyN0JFs6MPHxd5iB0W WnOpfngbWv5Z7Rt8w20if0qJ0w7nqZ5SRZeypQCEx8TZ1NTv3e4sPpDh67sIHX84Sy// 8bYTxUUr8kHcDOYN9K75AhgX5q0QXL8GWe4EgjmzpVIX3aB/f6321ALnvprBP0wcCZb+ a+KiZaDLtCLk6a+nnUnmmnbmDRswyi0DzJLnxSe6FgpO4nnfuWw5tY/WhjuT351fxUwO d3Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165936; x=1709770736; 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=Wt3W9ZcbAW1zDD9azPxHXaT0ia+NyzLn1A0me08+DuM=; b=fBecPoSekZV4eolA2bDEcMRBmrrkAnSY/e3jGk3eEhvhj/NK7+rnNjrd5Qx0HqtUQP hUwRs3MeG94AjTw4lgOxplBz8UIG6x2cGEM3az4K8R+pfrGoHHJjKUZaVcIBL6wAUNON p2fkDOan5cJuXSDJkKjShTFDbTvSBvQq73Emv0hCPkMboWDKgFaoSzxNfjWqhyqcXsCN CsfgpmOpa+7fMK4ibvl80p3bMNlKAefZA6Ya0vV5GX6/Un8uHuclDzM2h4aDW+/Rzmuy x0nSls2OqfBKHS0k3+JJ26dbYY/aVoOzZeneh23Mob/r9W0FwgvOSO+hoHuvbVlvbMPf Nvzw== X-Forwarded-Encrypted: i=1; AJvYcCWUvELAvV52feHCA/Zt262gsVFnVOkWku7UFh2ki65sJLHHrDoc+P75BIfOGc6djN5l5CekbXqFbOJTf8NPjND5jNORy2DTTxMS6oqu X-Gm-Message-State: AOJu0YxaZfPdFUTGgJLUskqhDLpMye2z8lv0i1WcXNkHOA3nweaCcNxu AbiVjpDT3mBqOKQ+G34PLzXgIGNiGRAISkf8fU6H3Ev89fNsrb/RelcI9o3eqg8CR8WPWkKOYGY 6rCZd8w== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:10c2:b0:dc6:b982:cfa2 with SMTP id w2-20020a05690210c200b00dc6b982cfa2mr42080ybu.8.1709165936522; Wed, 28 Feb 2024 16:18:56 -0800 (PST) Date: Wed, 28 Feb 2024 16:17:59 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-15-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 14/20] perf jevents: Add Miss Level Parallelism (MLP) metric for Intel 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: 1792190649254954803 X-GMAIL-MSGID: 1792190649254954803 Number of oustanding load misses per cycle. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index fef40969a4b8..e373f87d499d 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -617,6 +617,20 @@ def IntelL2() -> Optional[MetricGroup]: ], description = "L2 data cache analysis") +def IntelMlp() -> Optional[Metric]: + try: + l1d = Event("L1D_PEND_MISS.PENDING") + l1dc = Event("L1D_PEND_MISS.PENDING_CYCLES") + except: + return None + + l1dc = Select(l1dc / 2, Literal("#smt_on"), l1dc) + ml = d_ratio(l1d, l1dc) + return Metric("mlp", + "Miss level parallelism - number of oustanding load misses per cycle (higher is better)", + ml, "load_miss_pending/cycle") + + def IntelPorts() -> Optional[MetricGroup]: pipeline_events = json.load(open(f"{os.path.dirname(os.path.realpath(__file__))}" f"/arch/x86/{args.model}/pipeline.json")) @@ -798,6 +812,7 @@ all_metrics = MetricGroup("", [ IntelIlp(), IntelL2(), IntelLdSt(), + IntelMlp(), IntelPorts(), IntelSwpf(), ]) From patchwork Thu Feb 29 00:18:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208106 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp90567dyb; Wed, 28 Feb 2024 16:23:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXiTLpSfmPCUOX1W1W0AkufylK/SHC4s+l5WLe9br0wspsEMJHlSiucmPS3Og+y893hSKfIAD3nufSrmLEytmQMmrRkdA== X-Google-Smtp-Source: AGHT+IHuc3hxvVDA9ACQKHQ59zmkp0mm5+Eigk0NGpFBkJriOr7maLEcSa6IJDh8RNnR0iz5couy X-Received: by 2002:a0c:ebc3:0:b0:68f:3ba2:232e with SMTP id k3-20020a0cebc3000000b0068f3ba2232emr770232qvq.0.1709166208335; Wed, 28 Feb 2024 16:23:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166208; cv=pass; d=google.com; s=arc-20160816; b=rNHgMlDooyBA4hj/jPL4Jeha8WS9ZOy9+tBkShtC1TXRn1ofCzY9SHBjnAYHh+VEdq gmx7tDkppM9vZJbZ4EjP3vZ1SgCNNofSNLhA9A2VBn0165YWrKQW8zfMDFt6WZcITwBh fU7M1LuurFRevQ1OwcnEpBwJp61VgegopJI1T5nGZPQfihO8wnoQn1wsss/02r3BdTPW L1xDRPhlcr8CXzIXiD1M4Lw/V6ogAoxz5itdxO05AscVWInknjzPGriV0f3zOrnbiPUl 6p9O1qheZbTbKS8EzsHT90ujN5XAGiLLeubQW0MS27GN9eQWRJymuSRJBzHKAYUdiEeM 5H1Q== 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=ssvmfSzbf4Bf2vyw+vKAKxfn6gLVPgVaJ3+6XRQ1Cxo=; fh=h3JJ+yuo4jbvp1F+/QIzK7hM5I8D2NXT/Q+V5EhQVGk=; b=X9yZjORVyYE2vHE6yp6LLdJ3f1fenJN4V1rn6sMrgd8GmJJooiAU1sfTVQqK0HdbWr i0fmKuTxkyE1N2E3YxGnkXdgxkOi8BUTh8C7FcWJcXk2fkc16oIcCmImOmu5Deq8UNnA N+2M66Z0J77TRb1BRv6rMnFN6+RwdZRX8K+UKabBIchD7d/PWsNlqT+RDxJ/u+Gw54Pe 5Lgdn3vYoJCGmPbgHE+5rzdN+87EkGfI2R+Z7O/fR+bdmPbnhCIVaMA2D1izA0YFQO6C pyAWGqJCgU00rtWRO6dyG7s8AZrMWPWEuldxWPhicFWsXhAwSXppANkXOUJJnBj69EKm 6PfA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qrth8MBR; 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-85908-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85908-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t1-20020a05621421a100b0068c6cb82b51si258891qvc.192.2024.02.28.16.23.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:23:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85908-ouuuleilei=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=qrth8MBR; 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-85908-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85908-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1657C1C220A0 for ; Thu, 29 Feb 2024 00:23:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9EB465A0FC; Thu, 29 Feb 2024 00:19:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qrth8MBR" 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 EC8B35CDF1 for ; Thu, 29 Feb 2024 00:18:59 +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=1709165941; cv=none; b=QyPc9+8DhmdQfKi6WGGUheCBzz+BvVeSs9p+7wY9P+LGYvVwzaLjUSkuiqxxPOOCeteAqzLV/afcLvGi+c1fvZyBgOo8wclmdL+6wWmJ3C2Tq3P8S5XnG6tmeu0dhzqkt6QWlDoDRhsNTNrkyiT0GrO8Bvmq9LAfC05QwbnV2hA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165941; c=relaxed/simple; bh=n24bfMvbsLQrhJDf7paSd47VFWDE5Eb6tLHa7+2e2r0=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=cn0QmnwPbj9T4Eg2lHT6Reb6p2/JUN/Tbn2vBm2yF0tkloKoQTEUfkNjX+GomOeY/+kJHQlfH0vh0d6QXy1coNg81W/4kRCRrNQ6yz8NyThMfnphqx17FnZ/on/BJ6ECEqNvO/9P6/yrcCb0C9RcOtN4y+WJKgqqaVpc1tr9J2c= 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=qrth8MBR; 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 Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6092c637278so5462317b3.0 for ; Wed, 28 Feb 2024 16:18:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165939; x=1709770739; 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=ssvmfSzbf4Bf2vyw+vKAKxfn6gLVPgVaJ3+6XRQ1Cxo=; b=qrth8MBREDCJTrleDBrvcaqUHpkrb00Y19EVfjNfUN9B8oZw1XTRDF0lXpEPIlrxgP 5ENyMP3H/WNzf1eAsoLe3aoIb1RBSZbg/PiVPaewoI8buU2LtG1k4HLbjgr4mGfGDvlD 0/2KND3NLY3iV38VfUIUcnAx3m9dBPsi2XarNSlLycUmRDWI6nbN4ivRD/8gIYSPsCly bb9fGbNMPCREHF2oIVpF3RITj/rX5+cN0m5DciPNRcPbSimBMdwNLSCarEpzbReqn/dF SpphuyVhD+5sUOodIZUqM2Lh0qNbnEt5hRJ+UXSCcaqbzbGiFXIk7FfEf3y2KIaZw67I RIqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165939; x=1709770739; 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=ssvmfSzbf4Bf2vyw+vKAKxfn6gLVPgVaJ3+6XRQ1Cxo=; b=HZRlIIsu83BiNW+xkyEGyhvkYFVZnGa1CUZjJAI2IPo0uL+rIle0w6vWKQJhvfEAa9 Klhj/RkAbRkNQ7lMBJqc02aT/0Xbz+m6eJX/dqR+M1NZwmNe04XS3YrUNnFY+2BrNEiz sqfzG5OFpeB2ZTR2o4R6WB86AsrCB5GJOOBeV8eKZIJmVAoKS1zllESdOnRowEUJiFzF Yq8iRH9B2+y1VrTOtnmtdXBd16IJjArz/vingFKPdm/3ZrpG+m4e6kEa/2eNCM+39jBv IEv5033JreLTuYQcbp3ztB5pzrDY84qWmBKX+Ar+VeIzxNFVcqvr9oQaQeVbgEdbSDR2 vuRA== X-Forwarded-Encrypted: i=1; AJvYcCUbSIX+Xe8hOvnL4l121cUSCe1l3yIi9dp6Z3PwnKKVY7RgTEgqqx+2febMkycVwOS1r36A21VG8H+38OURASEcMRw/rxaAY8cwbiou X-Gm-Message-State: AOJu0Yz+TnlECOQpjfRie2J2Qno/Oxbbdx5MPIyWmzmuU8+FWQipVz4M oIQDBYRBtQ0UuuLbP2Lq6NKe619USeY1b1kZrW9e8yONiGtAoRLpODMMkCgAKolERuF55JN38xR ijrsU1w== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:230a:b0:dcc:6bf0:2eb6 with SMTP id do10-20020a056902230a00b00dcc6bf02eb6mr41891ybb.6.1709165939066; Wed, 28 Feb 2024 16:18:59 -0800 (PST) Date: Wed, 28 Feb 2024 16:18:00 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-16-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 15/20] perf jevents: Add mem_bw metric for Intel 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: 1792190665790348023 X-GMAIL-MSGID: 1792190665790348023 Break down memory bandwidth using uncore counters. For many models this matches the memory_bandwidth_* metrics, but these metrics aren't made available on all models. Add support for free running counters. Query the event json when determining which what events/counters are available. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 62 ++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index e373f87d499d..8d02be83b491 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -800,6 +800,67 @@ def IntelLdSt() -> Optional[MetricGroup]: ], description = "Breakdown of load/store instructions") +def UncoreMemBw() -> Optional[MetricGroup]: + mem_events = [] + try: + mem_events = json.load(open(f"{os.path.dirname(os.path.realpath(__file__))}" + f"/arch/x86/{args.model}/uncore-memory.json")) + except: + pass + + ddr_rds = 0 + ddr_wrs = 0 + ddr_total = 0 + for x in mem_events: + if "EventName" in x: + name = x["EventName"] + if re.search("^UNC_MC[0-9]+_RDCAS_COUNT_FREERUN", name): + ddr_rds += Event(name) + elif re.search("^UNC_MC[0-9]+_WRCAS_COUNT_FREERUN", name): + ddr_wrs += Event(name) + #elif re.search("^UNC_MC[0-9]+_TOTAL_REQCOUNT_FREERUN", name): + # ddr_total += Event(name) + + if ddr_rds == 0: + try: + ddr_rds = Event("UNC_M_CAS_COUNT.RD") + ddr_wrs = Event("UNC_M_CAS_COUNT.WR") + except: + return None + + ddr_total = ddr_rds + ddr_wrs + + pmm_rds = 0 + pmm_wrs = 0 + try: + pmm_rds = Event("UNC_M_PMM_RPQ_INSERTS") + pmm_wrs = Event("UNC_M_PMM_WPQ_INSERTS") + except: + pass + + pmm_total = pmm_rds + pmm_wrs + + scale = 64 / 1_000_000 + return MetricGroup("mem_bw", [ + MetricGroup("mem_bw_ddr", [ + Metric("mem_bw_ddr_read", "DDR memory read bandwidth", + d_ratio(ddr_rds, interval_sec), f"{scale}MB/s"), + Metric("mem_bw_ddr_write", "DDR memory write bandwidth", + d_ratio(ddr_wrs, interval_sec), f"{scale}MB/s"), + Metric("mem_bw_ddr_total", "DDR memory write bandwidth", + d_ratio(ddr_total, interval_sec), f"{scale}MB/s"), + ], description = "DDR Memory Bandwidth"), + MetricGroup("mem_bw_pmm", [ + Metric("mem_bw_pmm_read", "PMM memory read bandwidth", + d_ratio(pmm_rds, interval_sec), f"{scale}MB/s"), + Metric("mem_bw_pmm_write", "PMM memory write bandwidth", + d_ratio(pmm_wrs, interval_sec), f"{scale}MB/s"), + Metric("mem_bw_pmm_total", "PMM memory write bandwidth", + d_ratio(pmm_total, interval_sec), f"{scale}MB/s"), + ], description = "PMM Memory Bandwidth") if pmm_rds != 0 else None, + ], description = "Memory Bandwidth") + + all_metrics = MetricGroup("", [ Cycles(), Idle(), @@ -815,6 +876,7 @@ all_metrics = MetricGroup("", [ IntelMlp(), IntelPorts(), IntelSwpf(), + UncoreMemBw(), ]) if args.metricgroups: From patchwork Thu Feb 29 00:18:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208110 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp91386dyb; Wed, 28 Feb 2024 16:25:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXjRkEkUkZ/1kd7dAIhKr3n1qlkFrS9Frf98wZHoxm2h7f357mNNRQf1dvedTMqd+6bTS4bJ5i3vtsk9xHL3WAz4J4RsA== X-Google-Smtp-Source: AGHT+IGhiHcRBebpGKZZ69d9DOOpsaTbI70sjWN2aqflMgaOd3JhxUtStK/LSfMubND6C1a4Emg+ X-Received: by 2002:a05:6830:3a1a:b0:6e4:82c2:72d1 with SMTP id di26-20020a0568303a1a00b006e482c272d1mr558465otb.1.1709166355725; Wed, 28 Feb 2024 16:25:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166355; cv=pass; d=google.com; s=arc-20160816; b=PNch2zxBSs1brhaU1hNbDsk8v4r4tF3junUMfUFNasyvMbItFABBXzid5IAn79QfIS cVaM0ceconXb5nysgFKBIiTZ7XJtprw1WJUgoxMIzbtNR0W5fPJCzkHVmIlYDbelRPDs kH07zSlP5RmdMI/pGsLoCvAvELiXTWTWZZ5ECAQh61xSs4Vhj6ZbuCLLIWgzfARAHHrb R+Fq1t72OXCbWdFUBMVe8OE2jwgbNhuu0s9UIc6X9qFScqtg8z9wYJoycImgn1ApChzF dPQEPQnAjWOhkqYG0LBvcpfTjH6zmAej26cwN3jseC7TQm8p/FjOtTvBvvj9W1sAubeX JaHw== 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=rzyPImOsBkhbJpUz/fKV9tFh3RhaMmxr7x9cFs/2Ci0=; fh=LfpJoSSHwYKNZA4tt/jmARvvu2y8HcAfrBqFfxtcgNE=; b=jBpEF1WyWXQXLlH4IdLlKf/nCsp+J0pUm4XT9L+Lsvurk56jroN9TMm0OQbJQ2bMng T8vn7Wz+XRKCkEtQr2dr0gPP5zk+7mvVh8fyz+zvKAf8tqsvk6ifXEbDP0kI27XB8grM 6mI+6xyEB/u+aRt+d4t9FAEqNg0TU7Tr55jrD/WRhHLWzl/7Uek+u+loA8+RL20ThpVy iqhrIkvdOm7mdR+izBBOwdmZdHMAX7j5Otjwn46vgjZd3vxuUH2xB+9ZpPenrLNMtN9T KpCbI3ww3IDAzJqPdK5esbCJHc7ghi4h9jsrpKl0tb0/WirBe5CEAmNiJoxj6cNwRp5R mwQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=eOrbWy3X; 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-85909-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85909-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. [147.75.48.161]) by mx.google.com with ESMTPS id 5-20020a630905000000b005dc4fbfb9acsi171243pgj.583.2024.02.28.16.25.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:25:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85909-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=eOrbWy3X; 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-85909-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85909-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 65751B2327C for ; Thu, 29 Feb 2024 00:23:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BAC525A103; Thu, 29 Feb 2024 00:19:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="eOrbWy3X" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.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 5DF3A1DFC6 for ; Thu, 29 Feb 2024 00:19:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165943; cv=none; b=Vj2ViQ+4YbW9DoeF8UUu1JN4KX8E3pKkMY6fmQOA1/KdCf0LOBdRnSqylI7S8O1xQ9sYeWcGKdYuKJYWEOQQZKJEzA231JkQZMRu7P7Ctuset6FG9OTq4TNv38uJFzi0V3gLBH5XMQWY4SRUvHqdoB3+dT5RMCR8WS7RshJbwk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165943; c=relaxed/simple; bh=fOe0QR0t4OQ65kB5h4f3RSwkpTEtB27EsEiIpAN0gXA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=QQ5IgUMSpIE4bkCzB0SIATkwsTyPiHXjUjZnzzPuAbVaAVVJC58YFoSmYDmSzEiOjKPTy20U8kTZ7SnxIs7N1Dqg/mcMlhLOwfi3TwSIBQYasmv/+dw8ShhR97AkdQ5lA6jE/0Mirz25Yt2/nwoV77qfvWaLZrFefBvvqu5nXkQ= 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=eOrbWy3X; arc=none smtp.client-ip=209.85.219.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 Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dcd94cc48a1so584811276.3 for ; Wed, 28 Feb 2024 16:19:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165941; x=1709770741; 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=rzyPImOsBkhbJpUz/fKV9tFh3RhaMmxr7x9cFs/2Ci0=; b=eOrbWy3XkobnNHUpheVs5/38HAuJR8zepnCXhE/r4dM258Hh/x4RN+U8NGZ1KIUGqa +xM0gwnlsHBPBcGpQR8lP9RoQpkEXSXTXOySo1U+0yBZ+WZfbLGREJtZ2GM5isW8KPqa 6Yoz3BCNwnMWjOChFYnQaC4mjqAum9Wz4UBVXIn58OpigW9jEV04Cij68ggi3TsUYt0A s+3Cg3TxSQwRDilCbMwft/uK50FIuf2iDnqFx+k1nAZv3WOi4rSy9BVu5fP66tFnZsAu lnRQxMTaGJ391NtjU0LNbp+NntkxH0TPG9huEv9oMASKbeDN6O3KHzH5gPq7ZKRR7smE K8LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165941; x=1709770741; 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=rzyPImOsBkhbJpUz/fKV9tFh3RhaMmxr7x9cFs/2Ci0=; b=HVbp+lFhHQ1nhCDDa9CVm8kl+PlS1N9LmO+ocFT+y9Mrg0B0Tcs+dYAiVYjjMegnAX vFe1etF8yRLUtffhtfhluICDb4U7BaN3dQGy7Geok11k7XPneRzKv8HmfnuJ/ANcYDq1 NVZ+6wyttm0Zn4dGKjwa6duWGgN2M1f/cTIi8vg6r20JuoWdvPmjob8hk20LwwLXItKw 0E479t1HAofL9fFYhXxGQVuuEW5eppUpITeG/MQAtWCt7BZmAz/6AtITPL+BdWxi+5LA ZFNJoXKzqIlnamoibJ91dFlYrqXNtVpcSpFxbanwCb7VfJjZY4z0fIaGf2PMX7uKfMu7 kc+w== X-Forwarded-Encrypted: i=1; AJvYcCUFvXquzxzkSryw2jiWsV9vMRCO5YBc5GAm+v/QyzDgvNMuCF75ELR/QKHJtZ67X1UI8OWLOg8lbhbsdqYlllhGANu2+F8MaEVruk0M X-Gm-Message-State: AOJu0YzTZIDmqD3RCv4HX/kfR25tmzaNcX/UYto6XmDos8AKaf976w4b 24/oler8+hDPEl8t8xsAjdfKv5OHhgHKIbWukZplsBiM+ShH/3sKgQFVzZMyRyk4gzn0kD3TNyP 4X0aW1g== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:d45:b0:dc7:5c0d:f177 with SMTP id cs5-20020a0569020d4500b00dc75c0df177mr193731ybb.6.1709165941515; Wed, 28 Feb 2024 16:19:01 -0800 (PST) Date: Wed, 28 Feb 2024 16:18:01 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-17-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 16/20] perf jevents: Add local/remote "mem" breakdown metrics for Intel 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: 1792190820759479009 X-GMAIL-MSGID: 1792190820759479009 Breakdown local and remote memory bandwidth, read and writes. The implementation uses the HA and CHA PMUs present in server models broadwellde, broadwellx cascadelakex, emeraldrapids, haswellx, icelakex, ivytown, sapphirerapids and skylakex. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 8d02be83b491..82fd23cf5500 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -800,6 +800,32 @@ def IntelLdSt() -> Optional[MetricGroup]: ], description = "Breakdown of load/store instructions") +def UncoreMem() -> Optional[MetricGroup]: + try: + loc_rds = Event("UNC_CHA_REQUESTS.READS_LOCAL", "UNC_H_REQUESTS.READS_LOCAL") + rem_rds = Event("UNC_CHA_REQUESTS.READS_REMOTE", "UNC_H_REQUESTS.READS_REMOTE") + loc_wrs = Event("UNC_CHA_REQUESTS.WRITES_LOCAL", "UNC_H_REQUESTS.WRITES_LOCAL") + rem_wrs = Event("UNC_CHA_REQUESTS.WRITES_REMOTE", "UNC_H_REQUESTS.WRITES_REMOTE") + except: + return None + + scale = 64 / 1_000_000 + return MetricGroup("mem", [ + MetricGroup("mem_local", [ + Metric("mem_local_read", "Local memory read bandwidth not including directory updates", + d_ratio(loc_rds, interval_sec), f"{scale}MB/s"), + Metric("mem_local_write", "Local memory write bandwidth not including directory updates", + d_ratio(loc_wrs, interval_sec), f"{scale}MB/s"), + ]), + MetricGroup("mem_remote", [ + Metric("mem_remote_read", "Remote memory read bandwidth not including directory updates", + d_ratio(rem_rds, interval_sec), f"{scale}MB/s"), + Metric("mem_remote_write", "Remote memory write bandwidth not including directory updates", + d_ratio(rem_wrs, interval_sec), f"{scale}MB/s"), + ]), + ], description = "Memory Bandwidth breakdown local vs. remote (remote requests in). directory updates not included") + + def UncoreMemBw() -> Optional[MetricGroup]: mem_events = [] try: @@ -876,6 +902,7 @@ all_metrics = MetricGroup("", [ IntelMlp(), IntelPorts(), IntelSwpf(), + UncoreMem(), UncoreMemBw(), ]) From patchwork Thu Feb 29 00:18:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208111 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp91498dyb; Wed, 28 Feb 2024 16:26:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWxGpytX+KIY+zo9lGzu3AJRZ6OB53u3c1VtGr8OSsPdoTjrKHpec0VfxnVr4xUmuhVj6qJZUl/g7eHRaJpHNZJ/k7wew== X-Google-Smtp-Source: AGHT+IGfx6vUJikZH8dmNtWTWTbPn3jtWDSse5E7wGfappMddoYBJ5YU6wTkBpX5CpkqjboUraaN X-Received: by 2002:a05:6a21:1584:b0:1a0:e838:8e76 with SMTP id nr4-20020a056a21158400b001a0e8388e76mr1010181pzb.5.1709166378209; Wed, 28 Feb 2024 16:26:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166378; cv=pass; d=google.com; s=arc-20160816; b=rwj6oPwk37VqcvtJGN7waG3wpfLxltVsXkZLbvp2YhJsFAHrMjUwJJ8UXeZO4QTpIS +uUqUwohdP3dnl8bxOfpKLwwf1k4KuG56HJMRlCaHgyd2GlvW0pPX6/M1fNJHfAQJnqD jMx/m1PAntVf1Luh7WyYJX7XD2mZk+Mpn3JJTOPvf/YnuYMcz/R0P1SZVAV9sKKQcW6C lzvJ9Es9jP62Jj34j5KLjgwjrXwvzZ1vOeR3X+y0PCaHBvXVGnRU6jMkd+alJzShnuJl 0vuBVbF5hRlRWppl32SpXoUganntLbF2KgdS6e+WEhCeTg7DsxTmVvpnJy584aSrPaqS WSDg== 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=uBmMTFqHwHtPnnqhBPb22111ik/LzYAYuMu6eaqCRZo=; fh=PPsbwkFq7A/cdumX9/uWpBqPZXNkzb3NDNT+suYZ1Es=; b=DgXnKHS6cmnlCYLD0e1U3cukH1apVnWFqgtuq99E8HI4iCO3iDjoKh9ylmjW7XcZvL mnKeQ81yFEsDIBJyY0G4WR7ND38uFxG2xZxJ1fpPvJnzkbPRmmar0OIegknLBlt7795t 7VXZ9kslyT1VqnLfZv0YERJeI8WiJ6K8Fmit/p3/BvWn+PFYFgQK/Uk/nCiCa9oF3TA2 Sn2lkFZRzwOBUf0mgFMqCYX2GTS7hQxU1LxZofOA4wb3PSHN+GUYGutaj1mI/4lMZMIc qkQ9SklLbIXyWrizX4BvfqdpVnEBv3AhToKJ8NJd5ZkAwDL8vz4+jgKckQHoVAmTp/FG tmbA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=OB3v5o4y; 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-85910-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85910-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. [147.75.48.161]) by mx.google.com with ESMTPS id h125-20020a636c83000000b005dc81a16015si186554pgc.118.2024.02.28.16.26.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:26:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85910-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=OB3v5o4y; 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-85910-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85910-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 63590B238C3 for ; Thu, 29 Feb 2024 00:24:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F20A5FDCC; Thu, 29 Feb 2024 00:19:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="OB3v5o4y" 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 D1EE75F482 for ; Thu, 29 Feb 2024 00:19:04 +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=1709165946; cv=none; b=etHtAGi4LMttnOrRHKuHS81tpvI3toY6jHuXIZUS5FeuFJ5hC3dYKsqzkwWuW+vetH3ScU/LmzGjjF3XsBl0Wo/S2EeqLXSGHvCaUrvzoIwNRSfJ7JkzQoahOLOTyXGZIAW3ljOQsdWZeVjg619NQwuyKirrW5F2Hcp9rYB3lyM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165946; c=relaxed/simple; bh=xlzja/1NTHsdXbKI9l/ne67VG4rMNc4Dj/LOyY65h08=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=DPcgMhLTiBYg1iNEm0QtwaByzAskCI/ahhMUGN8CRgq7J0/olvw2MFoReLtww+yBP39nLU2QCSXjg+JdXGT7Gj8gVOQVnW5gSeAAgGnwOaNO+j7H5RG7xHmnnCrsaHtLJ0uauvQsmN3UyWjZj8V+HdiWaddVFj4qReFPq4JuUSE= 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=OB3v5o4y; 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 Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6047fed0132so5952127b3.1 for ; Wed, 28 Feb 2024 16:19:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165944; x=1709770744; 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=uBmMTFqHwHtPnnqhBPb22111ik/LzYAYuMu6eaqCRZo=; b=OB3v5o4ycIEF9dUEtS6bl03w8Fd6HEcJX4aemqEEA5Gfu4miFOPsn9g8E76Pjbrk7J viGr0gf6mrtt/3kpKjxtm2GSFrZcxPlp1ODukd1s8IzLahNajZfYKzTMCpAyWpnk4O01 /B2sF1e0kDQEMhEGjArzAzNE6EoMZddtFRMxgaOBFAdntDdPqnA1XYcW7u8jw1cWb+ee wrYqvFczuMppXnEScALhCF/dfyXzBR0LVuDmd4X3SeXPQaVNhd9LtCrF7wT/u4HfF2Jo 9Ssjluq52IsZGrO1UM9fuIIg7nhPoF21jN8VWlBedL+21PIEKb0lfQd7cp5FlYwkvG0m PsdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165944; x=1709770744; 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=uBmMTFqHwHtPnnqhBPb22111ik/LzYAYuMu6eaqCRZo=; b=K3FSKeS/PhDsgaz9ht7V+NiqvidZnwEyqdKieeRgVsNJrYLBzVvYJXDA5/XUttmo0A zkZ+EGsSOHOJ1KwIn9lmcEWWq9Rq03CK20K0A97nN3HEltD4euCRQ6esDJM7CIDadnyT rhMMPlakKHWclX/XHGf+hh2NtQ1Gdmn9bY9K7P872Q9a2PbKPeTxs+jpjaqNVpmbjraB 6uqym6sSxaVs7UCYxxR/APK1buJZTyr79y1Vogo41UYxgRbJLFkPwqXexRNH6/bTivdE RN6KOFlH5Q2sNzzp8GVhPGRQN7WZUl8CsM3yBusopGSv30hp4sxwiptVuTxMmMl4MUIU QWsA== X-Forwarded-Encrypted: i=1; AJvYcCX6ZkA2Cu1XbqnDl5KFg+tdSKhg32sHAt9t6aTUj+u0lMPO9Hg0VzuiMpwCRc8ylIMWUnTCcXeI9pRYqPtZiCF5avI4pfp5KonpJbOC X-Gm-Message-State: AOJu0YwdMTujcqL0VekFk8fZyIMXjHwl6Z8s8y/dVhSh4EKw0KT+6NGZ +c+iVIAFz2ua1vtDHR9P7hACunPdkz940YiTQtZ9Po5JJX2yhqxth4uCkaw/CUa2bavDa9jeHmN 4IpQjlA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a81:9b4c:0:b0:609:51a3:b409 with SMTP id s73-20020a819b4c000000b0060951a3b409mr147135ywg.0.1709165943906; Wed, 28 Feb 2024 16:19:03 -0800 (PST) Date: Wed, 28 Feb 2024 16:18:02 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-18-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 17/20] perf jevents: Add dir breakdown metrics for Intel 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: 1792190844140078546 X-GMAIL-MSGID: 1792190844140078546 Breakdown directory hit, misses and requests. The implementation uses the M2M and CHA PMUs present in server models broadwellde, broadwellx cascadelakex, emeraldrapids, icelakex, sapphirerapids and skylakex. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 82fd23cf5500..07aafdf77f79 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -800,6 +800,41 @@ def IntelLdSt() -> Optional[MetricGroup]: ], description = "Breakdown of load/store instructions") +def UncoreDir() -> Optional[MetricGroup]: + try: + m2m_upd = Event("UNC_M2M_DIRECTORY_UPDATE.ANY") + m2m_hits = Event("UNC_M2M_DIRECTORY_HIT.DIRTY_I") + # Turn the umask into a ANY rather than DIRTY_I filter. + m2m_hits.name += "/umask=0xFF,name=UNC_M2M_DIRECTORY_HIT.ANY/" + m2m_miss = Event("UNC_M2M_DIRECTORY_MISS.DIRTY_I") + # Turn the umask into a ANY rather than DIRTY_I filter. + m2m_miss.name += "/umask=0xFF,name=UNC_M2M_DIRECTORY_MISS.ANY/" + cha_upd = Event("UNC_CHA_DIR_UPDATE.HA") + # Turn the umask into a ANY rather than HA filter. + cha_upd.name += "/umask=3,name=UNC_CHA_DIR_UPDATE.ANY/" + except: + return None + + m2m_total = m2m_hits + m2m_miss + upd = m2m_upd + cha_upd # in cache lines + upd_r = upd / interval_sec + look_r = m2m_total / interval_sec + + scale = 64 / 1_000_000 # Cache lines to MB + return MetricGroup("dir", [ + Metric("dir_lookup_rate", "", + d_ratio(m2m_total, interval_sec), "requests/s"), + Metric("dir_lookup_hits", "", + d_ratio(m2m_hits, m2m_total), "100%"), + Metric("dir_lookup_misses", "", + d_ratio(m2m_miss, m2m_total), "100%"), + Metric("dir_update_requests", "", + d_ratio(m2m_upd + cha_upd, interval_sec), "requests/s"), + Metric("dir_update_bw", "", + d_ratio(m2m_upd + cha_upd, interval_sec), f"{scale}MB/s"), + ]) + + def UncoreMem() -> Optional[MetricGroup]: try: loc_rds = Event("UNC_CHA_REQUESTS.READS_LOCAL", "UNC_H_REQUESTS.READS_LOCAL") @@ -902,6 +937,7 @@ all_metrics = MetricGroup("", [ IntelMlp(), IntelPorts(), IntelSwpf(), + UncoreDir(), UncoreMem(), UncoreMemBw(), ]) From patchwork Thu Feb 29 00:18:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208107 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp90791dyb; Wed, 28 Feb 2024 16:24:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUq7pExZA+G/Y+lRMSJgua7eGUCW7LPFQRFJSHr+ityT/KRomK7c+roegm8eDX6WBmLH+dkZXHRCTyi4nECsinVSQV8Tg== X-Google-Smtp-Source: AGHT+IHHw1hFHk4ZiAkXkR+MT9RTyEzgUpLRLzQZEWEmQyPz2pkvDpmShV0a+gTTRfEBQgUNKFzh X-Received: by 2002:a1f:ea44:0:b0:4d3:4aad:4a01 with SMTP id i65-20020a1fea44000000b004d34aad4a01mr482362vkh.0.1709166251738; Wed, 28 Feb 2024 16:24:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166251; cv=pass; d=google.com; s=arc-20160816; b=ZVmVbvWSlguxkH39r9Z2iP5ljssnxXduRcYzLYnxP43ufhInP67nPijEcFsbb+3zaN HwyAX9oaMthoh7Hvb/fAnyknQRx2VkVPbrYryEuKcfhmWvwZ2ryfMSgW4qa8KD8F/CHF ppdOz27WRhNY47FCSd7K4Sq5EFLAFkJd0x7k6eEzOK5GRvptWwNZ6oyn2zjI+q9gwHeu RhzSN2mZCcfTTB5bgjNaZGcXbb/fRCKC7KJUG32NTPABgrnv033mSc3MWbhJ//RB4+/F dC15vKOKzk2tlxz/nzlMFT6+B4CQRYq0RnEEjrTyDrpi/TM43Y+RejFj2qbeFdWeDxPB yCGQ== 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=Ka25JSwa42fEfAhTOfaB0MMLbh9WO0q1HvqA//NrEvI=; fh=EmW9KUsTIgKJX1w4w+E0p48ppTB5o44a7wWQkBB5al8=; b=oqsnJb9JPlFJNJYpQkBNn/gMLPNFZYnY9tRKaBXdPoz9jt4cG/pGFeCs48RjnBG11T afFbo8+q5gm8ATjByh/8iK/temQUwBqvT/ugnALFpF8wZ/5smqkDZxVPp/IyRuzm9/+a ABQDsn8975gR5i8IgqE/SfPpQBZcBO/kEAAmulqHzfID3B367NccltRyGu2NTdjWdggA azEcbWxurQDkvHTiPDlCWshwpQI2NdOot+PrQ5CrXN/YF4chcLSfci+usULfFwLoUzFy Bxamy2lgc97BjofvwwBegLM8hf4fE7aN7fkBPGQ2h4fBW5MwiX01bmgw5D1FufDZ13iz ZkdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Q4xlc3XS; 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-85911-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85911-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o10-20020ac872ca000000b0042e68e360fbsi300109qtp.152.2024.02.28.16.24.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:24:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85911-ouuuleilei=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=Q4xlc3XS; 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-85911-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85911-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7F6881C22210 for ; Thu, 29 Feb 2024 00:24:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8285460248; Thu, 29 Feb 2024 00:19:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Q4xlc3XS" 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 05E515FB89 for ; Thu, 29 Feb 2024 00:19:07 +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=1709165948; cv=none; b=TIhwvC6/eSNcfVfbChduA7ZxWQ2n5jD0XkTtci1OrURAe9xbDWOV1BfQR4wWeE5P2ujGoGHGBB0+xE70bY4fLKGmOPTkUT2jW/lDEIuHjmuztt0RkEh1dM2OS6cj9rSRqGAoJzpj6HSghsyupK5ITz8E60ahGgj8je94WNeKaEU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165948; c=relaxed/simple; bh=YXNqPVvmlEQl2UENKfp2LS78R8f/Oi7KHqOEb/B8xzI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=sZiCOPiTuI9bLv0vA9yDBja8/Pmjy/akXbqvICNez/M0pJPhcwas+3LBndt7ysVPTAWi88Tob2rprXQwSMPCT/rnvISIPdnRKr57sNX0gsY6APcmQ1f+S8rXDqKXdoqnlYVRdSpM3xFqq3nlP5TnTYLDmaSLCx6D0VTwnnE1zhc= 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=Q4xlc3XS; 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-dcc0bcf9256so506946276.3 for ; Wed, 28 Feb 2024 16:19:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165946; x=1709770746; 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=Ka25JSwa42fEfAhTOfaB0MMLbh9WO0q1HvqA//NrEvI=; b=Q4xlc3XSTia1GwWIu8nN9P276UE7RThUVPwR9hbZbxPFfZGqcpn2xhz3KBGXQrBfDn JSzDGWp/u6qciDtUHHjd0yarXZLayGSaHXDEJJeNXcaN0neblw9An2ysAZzW5XDGDGRc ce/EdhLT0ZakPYUivyZ9jpEVxvejbB/Vj090AfHJooR1GGPX7Sd3cN6oflsQ/54QIlKS H5+u/T73nDCdqUnwTmh9HygBC+dypn/UObbWPNxn2a7LphvGzYSId8fV62EZJldLuhzJ akJ83nhQWed9nY4mEH44BdyG2VEvz2/jotocxIjjUpGLzEL8FnfeVAoPIrB54+SPO7h4 PNWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165946; x=1709770746; 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=Ka25JSwa42fEfAhTOfaB0MMLbh9WO0q1HvqA//NrEvI=; b=ohmnhsvGWKsFUISULruB3M8RBLBizkRbIhlLsrjfRmndUXU2PtW04SmtiKzmad/6Oz Bs00cPA9+b0/n/TcrwFHJ/DsKOsl6WFrgIIe9FhxK2S7cM1AnlMQ0Sq7/c4qd8EKJq43 SOPB6H5LeH4ttI6xpAs2vvYVPbu/jAQkE18AQ7aebNKT8tq+OMwoajGaFp5zG6gc/4uZ Hz8AQpQLwQBb1Q8MFb0Va68nZjN89Bduc/rCoopDY6lQH9fXIbZrPQIoyPmaLRgdx8Hb yHWkOnAeDEBDVsTMvdBup4Gtim+4UCEGiXea+G+5LJvql4sUN2/pa3BOrL8w5zsfRBGz a/Cg== X-Forwarded-Encrypted: i=1; AJvYcCXNSOQ07IwxRwVJXQAD4RStJw9fxl/3qwZTVm2/ysqbSMRX9FCBEMVfmAlJZh6WuNLnsrDU42/IBnzY6DwnYV9gFhBN4DEjy96HH2E3 X-Gm-Message-State: AOJu0YwtxIcwJbSklvtD/E2CM3cGFvaMmWIBUGtFV+zCvXqi5Ls1K5EC xaHHImrKe55BmLAFhbADjWzjfPkdxf53ZJyD769ctMTtD1PhL+sY5Xq6GulHz9naOYTHhc9DlbO ++kaU1g== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:100a:b0:dbe:387d:a8ef with SMTP id w10-20020a056902100a00b00dbe387da8efmr42143ybt.1.1709165946209; Wed, 28 Feb 2024 16:19:06 -0800 (PST) Date: Wed, 28 Feb 2024 16:18:03 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-19-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 18/20] perf jevents: Add C-State metrics from the PCU PMU for Intel 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: 1792190711381953654 X-GMAIL-MSGID: 1792190711381953654 Use occupancy events fixed in: https://lore.kernel.org/lkml/20240226201517.3540187-1-irogers@google.com/ Metrics are at the socket level referring to cores, not hyperthreads. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 07aafdf77f79..1b9f7cd3b789 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -800,6 +800,32 @@ def IntelLdSt() -> Optional[MetricGroup]: ], description = "Breakdown of load/store instructions") +def UncoreCState() -> Optional[MetricGroup]: + try: + pcu_ticks = Event("UNC_P_CLOCKTICKS") + c0 = Event("UNC_P_POWER_STATE_OCCUPANCY.CORES_C0") + c3 = Event("UNC_P_POWER_STATE_OCCUPANCY.CORES_C3") + c6 = Event("UNC_P_POWER_STATE_OCCUPANCY.CORES_C6") + except: + return None + + num_cores = Literal("#num_cores") / Literal("#num_packages") + + max_cycles = pcu_ticks * num_cores; + total_cycles = c0 + c3 + c6 + + # remove fused-off cores which show up in C6/C7. + c6 = Select(max(c6 - (total_cycles - max_cycles), 0), + total_cycles > max_cycles, + c6) + + return MetricGroup("cstate", [ + Metric("cstate_c0", "C-State cores in C0/C1", d_ratio(c0, pcu_ticks), "cores"), + Metric("cstate_c3", "C-State cores in C3", d_ratio(c3, pcu_ticks), "cores"), + Metric("cstate_c6", "C-State cores in C6/C7", d_ratio(c6, pcu_ticks), "cores"), + ]) + + def UncoreDir() -> Optional[MetricGroup]: try: m2m_upd = Event("UNC_M2M_DIRECTORY_UPDATE.ANY") @@ -937,6 +963,7 @@ all_metrics = MetricGroup("", [ IntelMlp(), IntelPorts(), IntelSwpf(), + UncoreCState(), UncoreDir(), UncoreMem(), UncoreMemBw(), From patchwork Thu Feb 29 00:18:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208108 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp90896dyb; Wed, 28 Feb 2024 16:24:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW48FW4ydK+HseO22T+3DcQI9tm0T9S2xSKEtQl7HsV+A8Mbl4DPVm1bCiuBkIDz/EVRCA2U/GQMWD2n6onP/E8GKiFYw== X-Google-Smtp-Source: AGHT+IEMp1pMV6P/gMrRZgYbBLtlTuwA8DJuMQtkYtNlvCHFpVuwps8k166htR+hRc33ZKKg6L0j X-Received: by 2002:a05:6a21:3408:b0:1a1:864:65bc with SMTP id yn8-20020a056a21340800b001a1086465bcmr433066pzb.23.1709166270132; Wed, 28 Feb 2024 16:24:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166270; cv=pass; d=google.com; s=arc-20160816; b=eJSb8J+ZnE4Q3f2Jrt84iD1Fym13wwLLLEHvdqg6cOzWjTteTFdjyXQPLdBN1J+Cos B3ln11L0kKAznzt6R30FvD+MiqFoPupboidAZvD8UijbNMhJG6/ilL4gA6DJRpx8uFlX WnaM73U9sXJ/uLsKfXSLG4KxE12MlqI/QETsM9m2N+8m9tknoyhT99F3/j1Vop3Kl0A/ N11hpLHchbT1DyZig6fEDyf3pcPeikhTFfbXR+387iIXkgBRE3UzkP7GFXH1nsVwGPnW Plc3c5yK9Q5RFrCNfGl7E9mkjTUfwr5TXszHpPq5ViIvc/4Ea+W169vo9Is6YCBj+roH dgsA== 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=jHwxTyOi6lmXZYsarPu6rddsGOcfVBFqWW+pqTf9FsI=; fh=LSsAv0wv8cO4SfdsCnq+nOsunh1ptBOsj4qLLS+upks=; b=wFrQwKUZFsO1mcJQta79qYTfnHzxMYizjNWj7hrM4Q5fG1Ixs/FlKQvjOhzfhrMQG/ rZxU/QT9D+aEslHCGW2iDp5WjIxfgzCrh93HYhBLQqPqWUCryAmXPBjURxNVPeOnGkaX c9s9NUu7CXcMPCUWRu02JeCjW4SXEfJYBsTKBvOl1dZbyjV5fiucCuLAaJU9SHDnHVkP S1nb9QkBH2iG0ENWuWY53PDf9jj+xYR44iqzBrmpBIt4ozK6gy4I44pZtUyf+LaldBGI 4SVAdF8dndqoOclBRYN4v82lKtfUYh8zBGPVRYwhG7122GPLmE64zocN1OTWSdvNUmiT X1lg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=K3GFQFwW; 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-85912-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85912-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a8-20020a63d408000000b005d8e2f56d7bsi172657pgh.864.2024.02.28.16.24.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:24:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85912-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=K3GFQFwW; 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-85912-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85912-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E7010286B9C for ; Thu, 29 Feb 2024 00:24:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6AAF65C81; Thu, 29 Feb 2024 00:19:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="K3GFQFwW" 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 744BE5FDD2 for ; Thu, 29 Feb 2024 00:19:09 +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=1709165951; cv=none; b=WrZR0CbFbPqhT4bOe30HgDpxvAfSoEy3XXewyAl2VMxfCCKBjhRz/utBRojSTxOv0D3fQuAj/Y5AmhCmxye5e6J4HP4gFsi8q/3UEbLZnvnZxGoLLKQymwznlPhUi491P/YHVXFuRk9H4Y8keXFu7Pqn2qWyxpGRrLeiyxbxZ6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165951; c=relaxed/simple; bh=HvG8OnmJueim0ZQLofUBNhtsvwoXfQ3M1FY1SvPuynk=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=ZbWxyQqY7GasjzLyKzOGXJfaOTkwUbLFY1KL6iTg6BJyP0UCKgBWprfIZuw1jil7Kim1hzLL5fZP5b8fb8F0W6zyao2ugtlcu0nkQrWysnBkuibIJ9bquYCnSMM5CnOoSclBVqYJtGcUqpBZ7XwVQQGdsDF/qQvS/uRJiMuPevY= 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=K3GFQFwW; 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-dc6b269686aso610999276.1 for ; Wed, 28 Feb 2024 16:19:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165948; x=1709770748; 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=jHwxTyOi6lmXZYsarPu6rddsGOcfVBFqWW+pqTf9FsI=; b=K3GFQFwWUFhHg/zkvGJJzIun8kqC3Nc0wqzXQcHcj2+t+4ZUiNutdvhw7JGy4cfvD3 fbPU/21uS8E7WUPOR9npb+qU2HXzQm2BtfjM+6oSTlHzhPpRZDlcaCxQh0Xz/RAWLb6t LFmorF+AV9G9Gem6cmdRZx61ELb0oVAMrVbdKrR38ZPX+Bgrj2SysjrIbouZBnh/4Nir L6vQRaYhsbMkaFdkUqRxDwgJVMa1is6rm2HaTqtZ52wwUaI9r7CW7pDRb+0+6PZlHrUF 4tdtdq4WgTLRn5NBfFEbanci4Ye8kngqbwwnoS4NH1qZi62VQVbI0rKeYEAb5cK6bFQ8 aEjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165948; x=1709770748; 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=jHwxTyOi6lmXZYsarPu6rddsGOcfVBFqWW+pqTf9FsI=; b=cGoutDEZDrsQuS2xr7Ae1McGH6tkgjsFIpz0/TIaBSYKe1hoS5HHnD0LAT/jucjHL2 ikG9p7Eg3zq17jnxdmrN7EBDLGREsmwCxKldv+bhhNzAuaCYTSkD76X8DyQtFFXNsGqV 0gXdDDJCvMoTFrBFHvzZZmOeJsrgFvFOJKb4FLDb+pzo1cz0eXU1Tq7hIKXuguOhY7Uo 9bumfDrgadlrcllGX6ZN5X6xYK6beXBUiTx6N+ghjE8l0m0ZzCGVAMH/eHihSb8NIK4p fQe7QhvHzDwROtMvwOGDnssULuJh4SjA+tPt58ufU7rl2t86ftSFw8rQUQAKrilvhI/7 jvUQ== X-Forwarded-Encrypted: i=1; AJvYcCWsB2kisiQuYVKWt15OArV7aItd3H/6uecthkzvDotHzKI542p9pjUZp8mcNBwzqF14niDkjdSO87xdFa9YV3IDVcle0L+VMM4m24Lq X-Gm-Message-State: AOJu0Yx/KK3+eJigRRsRY+245hQq90IRnj+cVj97qnj53GiO4WmdfVus YEdpzvp0GksxdVpxI8o/caRYrccOjBmAZAn1pOtwGYKmsjPtro2FilW6D+ohu78n80oXHkuEVwi mJPyBhQ== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a5b:441:0:b0:dcc:79ab:e522 with SMTP id s1-20020a5b0441000000b00dcc79abe522mr42703ybp.11.1709165948642; Wed, 28 Feb 2024 16:19:08 -0800 (PST) Date: Wed, 28 Feb 2024 16:18:04 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-20-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 19/20] perf jevents: Add local/remote miss latency metrics for Intel 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: 1792190731122070065 X-GMAIL-MSGID: 1792190731122070065 Derive from CBOX/CHA occupancy and inserts the average latency as is provided in Intel's uncore performance monitoring reference. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 59 ++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 1b9f7cd3b789..cdeb58e17c5e 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -617,6 +617,64 @@ def IntelL2() -> Optional[MetricGroup]: ], description = "L2 data cache analysis") +def IntelMissLat() -> Optional[MetricGroup]: + try: + ticks = Event("UNC_CHA_CLOCKTICKS", "UNC_C_CLOCKTICKS") + data_rd_loc_occ = Event("UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_LOCAL", + "UNC_CHA_TOR_OCCUPANCY.IA_MISS", + "UNC_C_TOR_OCCUPANCY.MISS_LOCAL_OPCODE", + "UNC_C_TOR_OCCUPANCY.MISS_OPCODE") + data_rd_loc_ins = Event("UNC_CHA_TOR_INSERTS.IA_MISS_DRD_LOCAL", + "UNC_CHA_TOR_INSERTS.IA_MISS", + "UNC_C_TOR_INSERTS.MISS_LOCAL_OPCODE", + "UNC_C_TOR_INSERTS.MISS_OPCODE") + data_rd_rem_occ = Event("UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE", + "UNC_CHA_TOR_OCCUPANCY.IA_MISS", + "UNC_C_TOR_OCCUPANCY.MISS_REMOTE_OPCODE", + "UNC_C_TOR_OCCUPANCY.NID_MISS_OPCODE") + data_rd_rem_ins = Event("UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE", + "UNC_CHA_TOR_INSERTS.IA_MISS", + "UNC_C_TOR_INSERTS.MISS_REMOTE_OPCODE", + "UNC_C_TOR_INSERTS.NID_MISS_OPCODE") + except: + return None + + if (data_rd_loc_occ.name == "UNC_C_TOR_OCCUPANCY.MISS_LOCAL_OPCODE" or + data_rd_loc_occ.name == "UNC_C_TOR_OCCUPANCY.MISS_OPCODE"): + data_rd = 0x182 + for e in [data_rd_loc_occ, data_rd_loc_ins, data_rd_rem_occ, data_rd_rem_ins]: + e.name += f"/filter_opc={hex(data_rd)}/" + elif data_rd_loc_occ.name == "UNC_CHA_TOR_OCCUPANCY.IA_MISS": + # Demand Data Read - Full cache-line read requests from core for + # lines to be cached in S or E, typically for data + demand_data_rd = 0x202 + # LLC Prefetch Data - Uncore will first look up the line in the + # LLC; for a cache hit, the LRU will be updated, on a miss, the + # DRd will be initiated + llc_prefetch_data = 0x25a + local_filter = (f"/filter_opc0={hex(demand_data_rd)}," + f"filter_opc1={hex(llc_prefetch_data)}," + "filter_loc,filter_nm,filter_not_nm/") + remote_filter = (f"/filter_opc0={hex(demand_data_rd)}," + f"filter_opc1={hex(llc_prefetch_data)}," + "filter_rem,filter_nm,filter_not_nm/") + for e in [data_rd_loc_occ, data_rd_loc_ins]: + e.name += local_filter + for e in [data_rd_rem_occ, data_rd_rem_ins]: + e.name += remote_filter + else: + assert data_rd_loc_occ.name == "UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_LOCAL", data_rd_loc_occ + + loc_lat = interval_sec * 1e9 * data_rd_loc_occ / (ticks * data_rd_loc_ins) + rem_lat = interval_sec * 1e9 * data_rd_rem_occ / (ticks * data_rd_rem_ins) + return MetricGroup("miss_lat", [ + Metric("miss_lat_loc", "Local to a socket miss latency in nanoseconds", + loc_lat, "ns"), + Metric("miss_lat_rem", "Remote to a socket miss latency in nanoseconds", + rem_lat, "ns"), + ]) + + def IntelMlp() -> Optional[Metric]: try: l1d = Event("L1D_PEND_MISS.PENDING") @@ -960,6 +1018,7 @@ all_metrics = MetricGroup("", [ IntelIlp(), IntelL2(), IntelLdSt(), + IntelMissLat(), IntelMlp(), IntelPorts(), IntelSwpf(), From patchwork Thu Feb 29 00:18:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208109 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp90944dyb; Wed, 28 Feb 2024 16:24:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXJmDx5Hn0FEQYFWW0hOPP7jGJjZKyiCYr39uWmuYuNIDzE7SKQ0g0i1B7uBj5QFE2er3kr/7y8X9rnlXqPU0QGKSOT8g== X-Google-Smtp-Source: AGHT+IF3a3VSEp0unvGwOi5an11zLAhRSxLB3Y6no0Ur+wzkV8FomfoWsF8ImT+zBp3Fcxd5vMND X-Received: by 2002:a05:6a20:d04e:b0:1a1:e4b:dffc with SMTP id hv14-20020a056a20d04e00b001a10e4bdffcmr1077454pzb.41.1709166280372; Wed, 28 Feb 2024 16:24:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166280; cv=pass; d=google.com; s=arc-20160816; b=mopIKW+zoXcsoQKRHvL96eHwIcTY+S0WQcl0pjcfbYFHMBt6fxCSdy41FU6owU1q9f 99mo8fGZK8UOtuYzykKrCwtKaScujK9Mw2Smm4oMexMlX5sXwVrPM1xIaK5bg4aBd9TW sglFLG2jVhRWR3g/K5Wuyy3MC4ALe16I7XDwkX5r2SVbQ5tG5XuUmxxCxVJhaF5rNjRY 8lqCdToMx9AP8x6AjJiFZ4Sub8Qg3A960zq78NtCW9s0tk/7abA4i+Ny805AQV+LMSlJ 4uEF/gEV34LaafGvSILPYMN5b5LbeDs/1RzZtjmtBzTH5Y3B3YyWwdl6SgnhQTba7E2J wEBg== 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=GARAKFSHROUeCUO/36ulyyjpscEMXnihleFvvHQNW7U=; fh=1yQc3Q0HQvflcmrIxX6C7f5BmlJqzXoAs/CZ1hj3xaE=; b=meUDno5ADD0faV/wABEX675CSgjqUEVpkpqgHR8FjYW37FmfwA8GaW1vP5Jm/dTmna TxXR2jY4Eeh3omIYCB71RnDx9gKCn96aNw1ki5p6Zhb2J6XGRQI3pihUUtBLacQzmec2 nqc/aHrv0fktgmyzEaiwpiFrHmXuiEmdngfl2ZiNHzDAepYDlFtnk8+BZbQle5M4sCZG rrwZIT43c4PNJUOAJFiTUT0fKawgWpzmR+Z6Dmv+pRHZTgyLIzsmN3x4HOMQsAg98PCG 9iwFfgIQq1nqcRgowqHclmOrQeanJWYcdSWbjvyvplIHKKvkG/xzvlLKzW5LOIb9wCt8 +Llg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Tnh4PLt2; 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-85913-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85913-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l26-20020a63ba5a000000b005d8fdbbd5d7si180295pgu.606.2024.02.28.16.24.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:24:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85913-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Tnh4PLt2; 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-85913-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85913-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2AAE128661A for ; Thu, 29 Feb 2024 00:24:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6875B60DEC; Thu, 29 Feb 2024 00:19:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Tnh4PLt2" 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 141D7605A5 for ; Thu, 29 Feb 2024 00:19:11 +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=1709165953; cv=none; b=ZoHp3aBWWX5Ubbcj/ZPLrF/dRaMszZDVirmNLnP+mchAao7mmIL77w6tRzLNdMpISAjsJu+v4b2ylnYupU35bSS8mTHvLRhAMSIXtizzJriepWKXRjia+Gq+Lezdu0E6tSLglynjmLldb3/xxQozmJ26RRcgxSIoOIE68FXz+/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165953; c=relaxed/simple; bh=McUJMeln2Z6sLdD8gh2mpJJERcOGFKDfTLUUixwws6c=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=rUs9IrJ1NjOAVrDQo0Y01jNrJYp6mgDYp11teIJrmmvstHKQsLluckRF9ndY2JbOx1V0GYBtHgBF8ioJ6w4Z3fwfbynYJ8PX0w6Byz0Mxgznd4zQkMp1kh1hycc4daEtF04wTSaPMCuC1KpJJb7zKdPhZ8nwXRtwrhe5vT38KoU= 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=Tnh4PLt2; 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-dcf22e5b70bso630894276.1 for ; Wed, 28 Feb 2024 16:19:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165951; x=1709770751; 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=GARAKFSHROUeCUO/36ulyyjpscEMXnihleFvvHQNW7U=; b=Tnh4PLt2imeNpvK40JbRWZqzMn+X6PKolkVTyPqjJDdebpx+4e8mhHSAA2dMA+1+7i xkyzhHKK0lBRonO0/ULJsFnjdY08e/ZIqQTxqDUneUsljhtV/MrkoUe14qbN7LctzoGR Gzk0P4+TaI2gyCwKjCFAv4RQbvn/0r0Ri2kHvB8Aa87pwp4S2neHxtLDm8z0nBH0EoXp 10Iww2+sufYcnq38Q9c6btRNbFRI3mlFzZF/9GdPcGfH1sjnIP4LT7wJr4QqkMjPR+Sx 3+lz5tyPlUOk5UtgCjLLSwhRIxnJcXSbDWFd9TQLRaV7u40P53rUY9l97Dk2pO+R86HA tKNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165951; x=1709770751; 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=GARAKFSHROUeCUO/36ulyyjpscEMXnihleFvvHQNW7U=; b=U55y3QK8F2zx9ldAVgrQ6+3Jki0VLi32knOhGVBNbmu8Ka6NVOdRxSEKwVcEh2yzY8 m8cq3/ggwXTm2HFQ2+ofdWxPWWxSyqqFV6fwKnyDm0U5knqMYIubsIF6kedOqH2cgpM9 NKcVUjgcHDOWGorUsPKHQkpXqD8M1Hns1OB4iqKCjoocACMbvTnxtahQS+6r9wBmMcRL UJMqe3LkqDjpr0wbTAUDoFynBApdp9lS5BOIT1z4GyAFaTj/QMS8CcwH2LUSHECS2mqP l81ug6Fnlie6LrVVEBw62J8XhQbqKFqAMbTKRgqDQWgcL0N+TzmA1n+cfWKzeZ8D7ZjP ceMQ== X-Forwarded-Encrypted: i=1; AJvYcCXdm4GjppxGUyy+3l9/VYpJtFVvUh1ppF8d7F8SKhtmsFg8IwWMkydsNxnwH1KeChorPtIclQQFo6wdca2IRywL8yPZCTFoPNEzljBK X-Gm-Message-State: AOJu0YzM8xCeDfFvpYF/kjO8zMruXc25ar4Kpkpz86vDuiknz+5XrrT3 mve/7IIQfpIoHGAD7JzOhv0mDhrm6c/5Enyc0POc12aF+yvKhEY4LyX7+ciQgx60phkgwTTSYVr TfLT4PQ== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:1244:b0:dc6:e20f:80cb with SMTP id t4-20020a056902124400b00dc6e20f80cbmr44036ybu.3.1709165950813; Wed, 28 Feb 2024 16:19:10 -0800 (PST) Date: Wed, 28 Feb 2024 16:18:05 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-21-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 20/20] perf jevents: Add upi_bw metric for Intel 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: 1792190741443525779 X-GMAIL-MSGID: 1792190741443525779 Break down UPI read and write bandwidth using uncore_upi counters. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index cdeb58e17c5e..219541a30450 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -1006,6 +1006,27 @@ def UncoreMemBw() -> Optional[MetricGroup]: ], description = "Memory Bandwidth") +def UncoreUpiBw() -> Optional[MetricGroup]: + try: + upi_rds = Event("UNC_UPI_RxL_FLITS.ALL_DATA") + upi_wrs = Event("UNC_UPI_TxL_FLITS.ALL_DATA") + except: + return None + + upi_total = upi_rds + upi_wrs + + # From "Uncore Performance Monitoring": When measuring the amount of + # bandwidth consumed by transmission of the data (i.e. NOT including + # the header), it should be .ALL_DATA / 9 * 64B. + scale = (64 / 9) / 1_000_000 + return MetricGroup("upi_bw", [ + Metric("upi_bw_read", "UPI read bandwidth", + d_ratio(upi_rds, interval_sec), f"{scale}MB/s"), + Metric("upi_bw_write", "DDR memory write bandwidth", + d_ratio(upi_wrs, interval_sec), f"{scale}MB/s"), + ], description = "UPI Bandwidth") + + all_metrics = MetricGroup("", [ Cycles(), Idle(), @@ -1026,6 +1047,7 @@ all_metrics = MetricGroup("", [ UncoreDir(), UncoreMem(), UncoreMemBw(), + UncoreUpiBw(), ]) if args.metricgroups: