From patchwork Thu Feb 29 00:15:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208082 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp88230dyb; Wed, 28 Feb 2024 16:17:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXngH+Q0h6qpDgNxVgoNJ+dEA30VPusmdvvn56sQnfkRvWwJTYtmVCqTKm93x1THPWpW8wixGT0zNf9UkAz6Agtypdxlw== X-Google-Smtp-Source: AGHT+IH+QqQ7X5yhXh1twAwReFaIwpfLhuHEutnVS+dgFz2Tm23lub1V/FAtl8IjArunYU5+kVPq X-Received: by 2002:a17:903:493:b0:1dc:d6ba:ed4c with SMTP id jj19-20020a170903049300b001dcd6baed4cmr488142plb.2.1709165832734; Wed, 28 Feb 2024 16:17:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165832; cv=pass; d=google.com; s=arc-20160816; b=vWEUDy9bckXQq+jiEszCf7ZUtpJXTyxvKLy47apJ6FGax8xgwTJ/VwRB9CQyrDQOET 6Mq8gtBh9a3BVyU7QlWAewYUd/cYNQE2xdXqUDecQ9U/uIXY8UP97iYEu3oQEYFu12tD uPxgWHbp1JI0HFRwj6wk0s2/66ETx0GyWXL4/44Jy/zDqO7dMNmkx8QbC/45NWCd4k9x zFSeXch5CigcNKfzlWMQIbUjNhHWlthWzXLelQT4/3kcy1buOjCjuHprDZHKfTLFwYeR 42utRQqNjPowOn7XGIodoF/WwwGH8BMruV2WbztRP8F5OlqS/uvVg3oxYBxBwNR2Ht05 QmNA== 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=Pr4WIv++H0HDAnrGFLxDjHsCZ1ntGDE7FfUCE5Wa1h4=; fh=+nH6yibFlzWseGeZeA+2ycoC7RLJzczWVKHbBuzdhak=; b=qPI2pj8VXGyl5h64BUmwJWZ7GppTUh/2pLIr9Htre4HYnCMmCHD6S4hiAxu21Nb43j ohtKKZn0hHnoJ6ex+xjKpKKpTb9i+5w/WCIVBIlRXonahd5FiusVdLxc3zOddpDNhII2 GVm6nKc60mHrT0WYvkXXqIxRjBUnejtcIhnU4BniiwToCl21BwvQQNmR4/vvhawRAcmH mPBdaGuSx1G52CZxGrG7tB7STr8FFFlVl4o41/l8SK8UP0PqWXkve28oiMXXSGX82fhw knf8hSps7WTg3abZtlMSpkFI3bMqgPowaJySM3jWC6b+iRidn2JYMY/Yx3J92AfcX67X WmdQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DMwi+yyz; 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-85878-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85878-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.17.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:17:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85878-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=DMwi+yyz; 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-85878-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85878-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 34C8E288EF7 for ; Thu, 29 Feb 2024 00:16:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4FF2228E7; Thu, 29 Feb 2024 00:15:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DMwi+yyz" 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 E670F12E5B for ; Thu, 29 Feb 2024 00:15: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=1709165747; cv=none; b=nslTBYOeo+6hn4vIW2UbybRi6BJB/6gFZ6a0zsRC4GsqvrQktrx2WjdSyvLywnCVhNv0tTZBp5T1Q44qgdfkrIfQ8MVehPzudxIY0dK8P+mnCNE46jmtTqdsLzM7ivC4pmLNejIPmaRzvM1XMTrNSdOscc7HbVj3V+t1ayf6G/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165747; c=relaxed/simple; bh=RzPNAkcYFaWtPD0d/orbD+ZkcQxuwvwqzQzOuKyN1IE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=bb6xmdTAEDbfctDuJJOPcP/hsiKLPM6rYbBnE/d+bweVKzbL22p4ElUQAu7jEdGOXEPdpLrVS5eKwCmuQtjP9ZXNOQLGFNgTACMV62lx8O0i7C80pNa71cZ9XBw+lxqkCRnM9nMu+Zie6iM22TfRTKZbhfZqUzjz5oDPiMeAxZY= 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=DMwi+yyz; 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-607a628209eso6340677b3.3 for ; Wed, 28 Feb 2024 16:15:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165745; x=1709770545; 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=Pr4WIv++H0HDAnrGFLxDjHsCZ1ntGDE7FfUCE5Wa1h4=; b=DMwi+yyzPIDxeLUohhLyyw3Uevex68cK35ybDsd9KNGqd5SNUEO+hP4KOObu+/rKfw ENWiNj3If0uSM/Uwa8D4vEqKIG8socREWoXrjYocmcqu5lcC1Oj37X1/OaDtAY2QDU1G 4VwYHXwkdWkzcMK9CgFCiqSYSu3GGGmXC2Q7NLcd7XZ6XUG+TgZ9o8wEHWYKk0wuX5rz d+fEvZHCeVQ/rPbkm3TScoMWPqsvOP4ttNrLwj/40Tsn2eDO91cYQf+oGjqkZZ1FyyIq FxcVLi4FQqGU1f86EZ/LPi2tBMz/HXBYP71Ae2g3HP4dmJPHCdBygcllzM7cv75nFVT/ +fUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165745; x=1709770545; 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=Pr4WIv++H0HDAnrGFLxDjHsCZ1ntGDE7FfUCE5Wa1h4=; b=Tkj8KZN01oxHc3OsT69GHqU/TXVDtC3XE2Cd1ECQyZ9F+GA2fWKTUaGJIRLBzWI/lj Uv7NfU4ZNJl0/uRo4eBZ6jUCEQ8bX/Hvb5YZ+9gFjm6K7ve7t+kiz6grmUaXpFOYZqoY 1gpyLlMYGvKcA7H3m/zaXII/cc6wg3JdcvA4l+5oZYbmnSq1iIumdp9ACSrCT0KbheoA HU4cIbsnLVRIZ1MIzD8jVdt6c9/boLPmIwxeJ87gY8+bDT7Qd2YdQ0MaWNBskgqGRNWZ DeToYNSVBYvq/UB+zm2BBJe5dr7jF5SLeXWoLZFmdQszPcocXl4VuOFFsqjdDRBbih/7 zsEA== X-Forwarded-Encrypted: i=1; AJvYcCXvKjxj45hC8eP5njhgKjsBH18AlMsKH4FkZt7xxE8olrAAEwipaCJWmBdhZOQRo41YhQunLGEp3tBvo52vgX3vexOqe9j64iDGq7AM X-Gm-Message-State: AOJu0YxU5NdGYkoPTBzFrNy2Lj88ElMLoeLmGati+5br+tPcc7WBR9vR qHwAD20fNNXkHQlc24MSeKZ/ousHawRML85HBl4ElMlCqZWU1Q7voFb4NaiS5Q79HUIxNwINzOz 3H8aHCw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a81:9a86:0:b0:608:bee6:150c with SMTP id r128-20020a819a86000000b00608bee6150cmr153903ywg.8.1709165745002; Wed, 28 Feb 2024 16:15:45 -0800 (PST) Date: Wed, 28 Feb 2024 16:15:25 -0800 In-Reply-To: <20240229001537.4158049-1-irogers@google.com> Message-Id: <20240229001537.4158049-2-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240229001537.4158049-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 01/13] perf jevents: Add RAPL event metric for AMD zen models From: Ian Rogers To: Sandipan Das , Ravi Bangoria , 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: 1792190272652219886 X-GMAIL-MSGID: 1792190272652219886 Add power per second metrics based on RAPL. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 30 ++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index 227f9b98c016..4016ecee6464 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -1,9 +1,10 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, LoadEvents, - MetricGroup) +from metric import (d_ratio, has_event, Event, JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, + LoadEvents, Metric, MetricGroup, Select) import argparse import json +import math import os parser = argparse.ArgumentParser(description="AMD perf json generator") @@ -16,6 +17,31 @@ LoadEvents(directory) all_metrics = MetricGroup("",[]) +interval_sec = Event("duration_time") + +def Rapl() -> MetricGroup: + """Processor socket power consumption estimate. + + Use events from the running average power limit (RAPL) driver. + """ + # Watts = joules/second + # Currently only energy-pkg is supported by AMD: + # https://lore.kernel.org/lkml/20220105185659.643355-1-eranian@google.com/ + pkg = Event("power/energy\-pkg/") + cond_pkg = Select(pkg, has_event(pkg), math.nan) + scale = 2.3283064365386962890625e-10 + metrics = [ + Metric("cpu_power_pkg", "", + d_ratio(cond_pkg * scale, interval_sec), "Watts"), + ] + + return MetricGroup("cpu_power", metrics, + description="Processor socket power consumption estimates") + +all_metrics = MetricGroup("", [ + Rapl(), +]) + if args.metricgroups: print(JsonEncodeMetricGroupDescriptions(all_metrics)) else: From patchwork Thu Feb 29 00:15:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208080 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp88040dyb; Wed, 28 Feb 2024 16:16:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXF3T3WE6LKbS9vVMKhCXLx8D8q2poeBbi31HUBJw47tc3G06iMXc0L6UX/JSzRwOhHbFz9AbG4r8nVU4vOQgJ1zHl8KA== X-Google-Smtp-Source: AGHT+IGImBJMsYg36kVUK+G/rMLx5cCtpR0FQGJh79mfcUWBDw4CGNRKVEszO+Q8RglhhyU8nAqv X-Received: by 2002:a25:9011:0:b0:dc7:4639:55d1 with SMTP id s17-20020a259011000000b00dc7463955d1mr800939ybl.18.1709165800531; Wed, 28 Feb 2024 16:16:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165800; cv=pass; d=google.com; s=arc-20160816; b=JHjj+hoWqM0zBrozZwalDVclW/T0TIIJI2qox4rSRymSXmKr0Hb3ck1RLolHCuJLwv HlYNLnWFJ5W+MUTQmrC1gZ9HAJ1yodjhOzRKXeXrADUJSIT6Z0F7cQROmO3gG7nuL+A5 RPk5f8IXGUgJ3GaW64l8U/HZ8B84BR0/gGiBb9CjNeuuAJWzxzW3IGYxa2fmRZNN7fPF fWNdKLA9eKM0LjPPbfpwfC+DzZao6ceKgCTCNv8270LB+2s6/YWBkz+n7oPZj5DHtDvv gL+ys96MzTpjj2Go6euy9Ej3869d/+0riAwaVKwjYL7iujWTccqeF6y+vl0cOAb3aOK1 U/JA== 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=R1z+XJES0GLGr0Q8oaGDYo7B4O7AcfZJJPh1SyEgcrw=; fh=faM0qnSt+IpHrJrAOFDYctQ0AAoYoAKlfANzwIhq1gQ=; b=MeI/3nV4nZCyPwVzRSkeOKM67i8pRi+VbXx8zwkF8wz+2EmDNNrRlNWOqxPPXfeMhH /JF7iLInMPplxjrbq9IuUgDaazf4QyYG/kmNyD48VSqQVnO4bi3D/FCLOlNJzlXf1T8+ OOP1QUQtrjy52Hhs8ydQrmoJ5mU9m2YtQT0phPdCpMipKg+nvKgSRO8rOtUODhs8q2xn i91Mg4kPSR32ICyWu71sjtnHiU+wOf8NbAPor7OEjA1NBbk2WMdLH0VBHASqjSi+1Nth hf6eU8D1C4d09pr8OpFmPIQbxxDKTHFowC3/WIghxawWLAfameMlmWsneEftGQawd6w+ t+zw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=1BLPzBn8; 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-85879-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85879-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 e5-20020ac84e45000000b0042daa920d4esi307448qtw.305.2024.02.28.16.16.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:16:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85879-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=1BLPzBn8; 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-85879-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85879-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 45E231C215D9 for ; Thu, 29 Feb 2024 00:16:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA57F2E3E1; Thu, 29 Feb 2024 00:15:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="1BLPzBn8" 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 6E3BE1E507 for ; Thu, 29 Feb 2024 00:15:48 +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=1709165749; cv=none; b=uZSU4qhgx3v05ZGxxDRt9tWptjJa1EHp9YfHGgBdygKdeD4ZrBGcAenjEp5za8jMa/JCs7mkhjwqq3OdldvIbCWJd9FRfK/La9bTv1U9AQF1zrhj9ovRdtPDXkOh1uc5s43w948yd8Iq2ZlDVpg4pM8FL2b9Fj3Vf1xETY3FYHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165749; c=relaxed/simple; bh=Dfpdo2YwplSQDWWpMc73Uzmy+I+y4UMFYX3EUMZzsvM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=q63TNhUnztdNBvMkyB9cEwqdoA2PS6SLVUKS/qjXIPSWIxT2hIg9//o/fOhGw1AfAIAr1iziS+3jmYE94jpdKutBDnvGcWdd3iZelzgI3GyjUPdhfg3kyE49rvQlJd2XYxnWKE2U/J0CCQ7tpfe6sj+fzHf8WnalaAi4ur1A2GM= 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=1BLPzBn8; 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-5ee22efe5eeso6397887b3.3 for ; Wed, 28 Feb 2024 16:15:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165747; x=1709770547; 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=R1z+XJES0GLGr0Q8oaGDYo7B4O7AcfZJJPh1SyEgcrw=; b=1BLPzBn89W0Tdh3j9cdOTO/vJxleAcibZR2pwDCEc3w7FJEci1cEqUW4A4vaqVm0h6 dBNXFhyhMgcGeV20wGtNfnuNdEBLENpXkQ97/sorr8IYcvKRyXj7H2Cxr+1KjpdBUABS NVYkXl9LlD9cAqBVkdUqbyo5pnxtwTn7cXKmuqPobO4J7DaCGUBYWxafTIWXn5GW3kAs J1UYAIpKs4fB73cs3y+5wy5Jyw2Q84D8RfDxX0Z575hcvliI7t20GxQVoXUHwpTbej4D ucyNOr/rtSYZTgZhdkjPj8FoDqcHkANMrxug3uUcz2s6QXF53S2MaKnP4viceufBmv0s xDuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165747; x=1709770547; 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=R1z+XJES0GLGr0Q8oaGDYo7B4O7AcfZJJPh1SyEgcrw=; b=EXt1H9Uv10Fszt2tTM9PTnkG7q+wouUrqSMfG9b98dnp9k7TNvIk2bC0JRrbotn5V0 nA9roLCN5+uu6NEjVQTBt+phfIJVyZ3W+1IeHqRnKPabq0sY5RXk1X1u4S4IVACi8F9x K0vFQ/Fh3L3TRdiHujAQhBcvSlqWuuG977T53E4aVfdDyysjXN1sFHv7xTL9yuqIA6XE 4cEhgtaXNNiBDep4YPSIs9Nhn7XpGfyWfGyRVHQjfzK4wPao1pjgHxg5fHZuC4ywyJdX Fictux6mvWQPxqCeF+NA7lxavs684LpUq5CXHkiNLbNNUyfakZmRPPjZGNiatT3akRtI QTRQ== X-Forwarded-Encrypted: i=1; AJvYcCVJiqbR5EckqLQQzivhzJKZctf8VQs+Mu+eXeleElYLhX4OruoZXUBbRPnaqnixOjDlQfabKFNHL9NYzjgc1KSoVFZbREckXUV0bkyx X-Gm-Message-State: AOJu0Yx8sktYSzXRrqh3vt3U2lkyLjdIRlukkvdlCOSz+D9kODmCbsug ZUuFZUmJGb/X5QpQy48aCUXj0+dPujqIIeHASbBmjqOxDaZgdArJ1GnUhk867ml6s1vd18xPV+1 P84XUVg== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:690c:3505:b0:609:343e:db43 with SMTP id fq5-20020a05690c350500b00609343edb43mr117344ywb.5.1709165747562; Wed, 28 Feb 2024 16:15:47 -0800 (PST) Date: Wed, 28 Feb 2024 16:15:26 -0800 In-Reply-To: <20240229001537.4158049-1-irogers@google.com> Message-Id: <20240229001537.4158049-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: <20240229001537.4158049-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 02/13] perf jevents: Add idle metric for AMD zen models From: Ian Rogers To: Sandipan Das , Ravi Bangoria , 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: 1792190238414725715 X-GMAIL-MSGID: 1792190238414725715 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/amd_metrics.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index 4016ecee6464..fd3095cb5c1d 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_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 @@ -19,6 +20,16 @@ all_metrics = MetricGroup("",[]) 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. @@ -39,6 +50,7 @@ def Rapl() -> MetricGroup: description="Processor socket power consumption estimates") all_metrics = MetricGroup("", [ + Idle(), Rapl(), ]) From patchwork Thu Feb 29 00:15:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208081 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp88140dyb; Wed, 28 Feb 2024 16:16:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUNaIX2H2U2MZLgJOGfqnOpczo31gRgkZ8VdLQG/r5UrmtU6fVJ/w4pulmRjYtUoikvnJo0ukRNzosB0WA82WZsWFBOkw== X-Google-Smtp-Source: AGHT+IHtV0zMFJcQGyEdONgxc0+oE6PsVrhWGITZKI7/Ru/ibitm6NqdrqNtExi7n7Y60x6JClAJ X-Received: by 2002:a50:858a:0:b0:565:a6a4:2ecc with SMTP id a10-20020a50858a000000b00565a6a42eccmr302149edh.2.1709165819078; Wed, 28 Feb 2024 16:16:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165819; cv=pass; d=google.com; s=arc-20160816; b=uC0KYh+4V9I6jOSyM+yrIdysrG3KPo9KWkCUlSlLo0volWIcZx/VjmAP/bi05ZEyKq uwszFpRkEU8wFH4PmQTrBhP/gjpKDqoWUaWQNjGgG6ZYukAMnJhCY642E4dwEnS2LzZG KE/9EAf+yyfMWxIhIsuj4x19NMm6m1MOghnqV/k7QMGc941q3WT2CU05T+pNj+eZXhwz 2X6juxeVvXzN6WaAqRh7MMhZihbL6GkXLdfjFaKS2BbvmCJB2KSqWX0zFgy3nFZwBjfG TW1gi+Hi8SkAiLLxTCA7mt5uttnm/WJaiiZZNT23Ixe420v353Jc1wMWRcfNGw3rz+/B hcUw== 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=f7UsDzYt66DPsayZORzPPicQ8YRzeND3f/RE4XjTOWg=; fh=LO31QwenY26UWtwbR3uFkInFG8IW9+smokWseiRIH3w=; b=yebKgcJXGaVb5+uZtQ5oG0umAUUi+3syPOR2xV8+81RDi4/JxjeZQbTWGprltbSVq0 xpREaSw0dX/O9c52kyqD2z3AxcfudQ/z9RVc9zArA2d7bIxNxVZ4Ci5lwD2q0U43tjNe 8BK1RiIyczF+VfBUf9WGd87Yhi6/d/HNVGc3mo7I/cNQeOjv9j/7Za+HoLVARdzmP0Z9 kAJTrpC/FMjzC9rrS/2DrTktvaHq5h4mQ20SDh5ajPKB1U+ru/GRFopd5jklJHPJW09i ijCGo2vcdadGSp848P7ZbtCnrNHIE0Y3qj05DT6cpQ7zvyxcgsf36okXg6aU7FkHkQ2w gZZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Sh7eK20/"; 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-85880-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85880-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 f19-20020a0564021e9300b0056694dcef39si57207edf.137.2024.02.28.16.16.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:16:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85880-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="Sh7eK20/"; 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-85880-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85880-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 4796A1F21AA5 for ; Thu, 29 Feb 2024 00:16:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE3E6374DD; Thu, 29 Feb 2024 00:15:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Sh7eK20/" 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 8FC1A29D03 for ; Thu, 29 Feb 2024 00:15:50 +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=1709165752; cv=none; b=IR5GO0XU8OcG0hPSp5Sg7Q4MR++Qi6L8xsm15OW+9HY/heB1HDstZAk8z9yQLHhXlSuesUIeOFbMpSb5apkyRKymTIAq/oM7HjWqiSwK3whpdIhDFyLEQf/GRXJ2nCyo5Z3pRfJPH50MdjsHfMv9k9ttlhSDimNeLANrAvKr/1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165752; c=relaxed/simple; bh=yEm8gDDiOp2kaCb7bjt8yDfO5lzyLygQrwL/+bKOLd4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Tdj0xdsUtq0tqlrj6Yx8YPOmsy7aAjVYvJHfpfMMA/ds4SuiE4JAHT1caADXVxXbtS5GJKDLPkeoOoKqLJ9UA3cyrS8bm4vku3xnlOY4RsBzJXJC2dTe+xUaSahyX5jI6zd+4+5vJ5QXxtv4DKW+5wpuRCEXUJRewUIE+UuhZuo= 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=Sh7eK20/; 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-dc6dbdcfd39so701672276.2 for ; Wed, 28 Feb 2024 16:15:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165750; x=1709770550; 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=f7UsDzYt66DPsayZORzPPicQ8YRzeND3f/RE4XjTOWg=; b=Sh7eK20/wFBkujUG6QvGgVXr/rgoGkp1JkNvxePRmf5ZpfTVyLQ7O4g7KCYiuPpSfM x72SEs0osdODMzGjvoDa/USFldosOkBKy+tdXRQgDRcfOsxk+024K+73IepFNyU8tSkR a5DCxwhT+DJFhSkfg1FDZVHnvUI1xZGpLqT+mYgtvUaEFUEAIDSADXHj239fnlRM7nL/ n6ULHi+M+LCO+RddZTk3I6Clgy3IxlmizIOmw2/OGhQbBArW/lWOyalv+zqBu7hXMsmE FSaiagDkDbAoRBI3DYQpbjQN1RS+rCNl/XvRxTGOuf59L0qUL63n+s22rh73vqw55HaB EnVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165750; x=1709770550; 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=f7UsDzYt66DPsayZORzPPicQ8YRzeND3f/RE4XjTOWg=; b=Sz2GsB+B27rZ3GkygBReV7pWq4VzrLoqFvEMARcef/rvNqSbXF1uaDMxn7c9Trbres /GFsFPbrSmtZU7/f6IvO4Nitv0wIp37kg68ruNXdJkcOaGtHcq3I01ZPwZfVgoIiDkx6 ORppUB1iz+4ZnlyRcvl71t9kuYy+FhoWgjVXjTxMPvafPpaB6sIyzPSaoCeQ1JCzHwCB wNXoAqvCJ+pVXVwWQ7FgKddx6wc1K2yxUSoRPs7OUeWO+kCvhygNzOvFWOkuA3IG1sJu /AJPlIVH1a9015cijR6KrHlmp8a+AcWKJ41hk9QcUujbo7/6uxUGUdW3Gk6ivVikabkx VFAw== X-Forwarded-Encrypted: i=1; AJvYcCVe8NrGvj7k3Herckg49fGqXpP6cqPw0SSI7S+vx5bdhhl2dIrW407hzBsiWCEYouOWZQyDT7HwYlwuQfbSlQopSrfPo6Sri0gJy33O X-Gm-Message-State: AOJu0Yxk1wdhHrlcaheC35GIvr+unaKLTmh20CC7LJ+/QO+sEvysJSS0 48mWY4E+V7z4k3/jF+uLDvzfEQDwxMyeMi9NTNcKzx/k6h0uEdNLf0FVfCnu1K/+aNNn6Uh2LtR ABKeq2w== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:723:b0:dc2:1f34:fac4 with SMTP id l3-20020a056902072300b00dc21f34fac4mr215253ybt.2.1709165749852; Wed, 28 Feb 2024 16:15:49 -0800 (PST) Date: Wed, 28 Feb 2024 16:15:27 -0800 In-Reply-To: <20240229001537.4158049-1-irogers@google.com> Message-Id: <20240229001537.4158049-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: <20240229001537.4158049-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 03/13] perf jevents: Add upc metric for uops per cycle for AMD From: Ian Rogers To: Sandipan Das , Ravi Bangoria , 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: 1792190258122507446 X-GMAIL-MSGID: 1792190258122507446 The metric adjusts for whether or not SMT is on. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index fd3095cb5c1d..ce3d1535483a 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -1,8 +1,8 @@ #!/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, Select) + JsonEncodeMetricGroupDescriptions, Literal, LoadEvents, + Metric, MetricGroup, Select) import argparse import json import math @@ -16,9 +16,17 @@ args = parser.parse_args() directory = f"{os.path.dirname(os.path.realpath(__file__))}/arch/x86/{args.model}/" LoadEvents(directory) -all_metrics = MetricGroup("",[]) - +zen_model = int(args.model[6:]) interval_sec = Event("duration_time") +cycles = Event("cycles") +# Number of CPU cycles scaled for SMT. +smt_cycles = Select(cycles / 2, Literal("#smt_on"), cycles) + +def AmdUpc() -> Metric: + ops = Event("ex_ret_ops", "ex_ret_cops") + upc = d_ratio(ops, smt_cycles) + return Metric("upc", "Micro-ops retired per core cycle (higher is better)", + upc, "uops/cycle") def Idle() -> Metric: cyc = Event("msr/mperf/") @@ -50,6 +58,7 @@ def Rapl() -> MetricGroup: description="Processor socket power consumption estimates") all_metrics = MetricGroup("", [ + AmdUpc(), Idle(), Rapl(), ]) From patchwork Thu Feb 29 00:15:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208083 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp88299dyb; Wed, 28 Feb 2024 16:17:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXTFx7aeqoec40jPH5X92uxNx2DY1roBnrlLRwNh8dPkdnYzroOi+sxHpGdxLFSRN9N1ocJxdLAdosSg+RiYnQ8LmQQDA== X-Google-Smtp-Source: AGHT+IGdZaQp0iCBadj5yfvRrr68GSdpapqPFJJ0HDnEJimJLAYVLVmu/bJTFTG3FHy6m16OexVn X-Received: by 2002:a17:902:e885:b0:1dc:8b82:7f72 with SMTP id w5-20020a170902e88500b001dc8b827f72mr466627plg.16.1709165841646; Wed, 28 Feb 2024 16:17:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165841; cv=pass; d=google.com; s=arc-20160816; b=eX4dy/X3uVeRC3609Ujutf0gK1G+mdjCyL6cCyXfoBn2TiUlNt7OAMq1Fi3F+UomFP tc/vf7YPL/xIQlpKn8PMg6wQrSy8IPq79QBTZbhD/7lSmMGN6IO6ydLQrNckWwJsK7Wv 2Y6qk8+0aODQfs8J5/9gLG+dVYSvp/b4vjdg8Q0lVtK/tb3phzyCmqDTkax7oGtgf95x 23WY8tj6F801ueJU2XnOJa8MY+uTAee7XfYgpUNQIrMONYRNu+qddFqiBxoQPG43fggU C8u/PVBk0nHQ7+pcG6vPc/HHih/V0Txvacaq8cCZbzvUCJxaHJEXT0l8QxBCy+otMrSa Eefw== 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=KWgiWiE03exBg0PhwlQIGByRAV21o9JQjLn06/BhBfg=; fh=hQtTdiI/nTqSSUrb6KdWlrm22MYHiZGt9frOm0Mdj0Y=; b=nh8rJ4TFXYwE95HufTKP2lzaLH26XQia0+wux7CTbdRua4E3x++Nl5R5IOU567sh2n 5wTN+7fugMMQleeTLSWFo69CnEpbiswQ+ZuW8HtMulk58rkBrczeEr9M1tmMkDt2qand tpyMK9PCcGfkFheI+pR/bLfFXKpYbdizWly0K2kaWkuVZfKx9nNnnZSc1CqAzBNPHTpT p13ZsqB7x15y1MYTap1E4Xa1zMfrnBfjjnnDwSrFEHj/tnuuQavx+1t+Lr1+FfzmdMWw ZBvuVMz/nqKkc864sz7z3FZ3waZpcEzSAGKVzrBXHU2X7pH5s1/pRJTvBE6HQ4W65wFc +VhQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=itbrC+ka; 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-85881-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85881-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 p5-20020a170902780500b001db3613aacbsi88182pll.617.2024.02.28.16.17.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:17:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85881-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=itbrC+ka; 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-85881-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85881-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 400D5B22DB5 for ; Thu, 29 Feb 2024 00:17:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4172443AA4; Thu, 29 Feb 2024 00:15:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="itbrC+ka" 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 0D1092E413 for ; Thu, 29 Feb 2024 00:15:52 +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=1709165754; cv=none; b=NVhZZcLCv2fWeIjThuggb22ZvmVDMJjSZunMf/INOhUQFH81vveDb95FQVRTu1HdOvBNe67rQ1+DJtSk6qmZPvslUuomDOwP63wKcYekPCZwoVNnEzarhrMQ7D2adPXLCLuiiq3R4d7c+8yn/wKN87dmA1xrILz3Ipo2tBMO7pA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165754; c=relaxed/simple; bh=YIxmuBzBhglh4md55W8onI4xgQ9tn1Wuzd6FPGsaM/I=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=NftwCEHWfNz47cQv5q7DOadD7osuXRhLxzdatnKZMHL7pbmVdyg/Gw5q5Dn19EekohGbKQLa7Jdh1msLkWmntbxFHOWBmg5GKh+n4X0bdwI0KSNOx4EdKEo/HRzm9KRgbxOJLNsNBgqvmUWDZQqWRwsTsLbTJf2OZRfBjJETd3Y= 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=itbrC+ka; 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-dc746178515so523492276.2 for ; Wed, 28 Feb 2024 16:15:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165752; x=1709770552; 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=KWgiWiE03exBg0PhwlQIGByRAV21o9JQjLn06/BhBfg=; b=itbrC+kadF0E0a++Y7xmZz1cYtR15CWYJY/LNUWqrWSGp28vZHT001p0uYPR7TtDKJ yvWTjYegglb1tE5fxsquytXvCWvSscnBrbsrxOP5kIM5gH/VE9rLQ1EupJl8fjvxmEmV BkkQPw0qEWX8bqzXJjR+M4lMi5JjDE2FD2kFawXr+PofoItzFUaQc1asUs18PMFS2JFd t/abkxWwc2J09D2FPVzmu0qTGQ7lj87RRQQKMzJPChHQ73fA4iYv5JMC3O9PW56V+PEv 39Td476tW0+sJQCMCKzJ1plkEfHDPfuf+ILbrr+SHw2F34Q7GlZ5zKVRjSXk4TgqpVL8 JqUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165752; x=1709770552; 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=KWgiWiE03exBg0PhwlQIGByRAV21o9JQjLn06/BhBfg=; b=l9W4kWVzSmMtlny3cVkN9bnUkEqD9aLiUgZFGxI42zm3YH0+TsABI/R9kY4av4/S9K US1O8mMICAb6Y04c5BzZmPe381xQpSKtu+GAkGmiOX3/QQA6pLS0yPjk8rulm0PgA/d6 OnJnjTz3n2OT2uzxKjMFb5/8jV6qBoqcqInAeUeMC4ox/HI+7MlwdC8oibJJpOS4Lq9d x1+aSCnA60LwZd3JPg6IfShzJxgSjGlvX5X6TQ40ExvJNHb2D8i5R3ZajYJQtirba+Rr WhGtNa7IVjDlmSBm/pW5bkATowyjEK4KzQrglNf9y7fitPVloS0NLZ77lw57eCTBioHl mveQ== X-Forwarded-Encrypted: i=1; AJvYcCUniVobn2C7TEvuzO4qfazCmfVr9tFTfrSu47r992uJ3OzqlKMC+qCmoM7+uQrCJweYdJ/Sbt1k0pZn9S5w2BRJk2XOQVvpJOpPSuly X-Gm-Message-State: AOJu0Yw4bIFMHbw0ZzvA9oVbHPpYmvbNCyWSciC8MOjgIMgfhXoHhyCc K+HotsklaCdum0KjH+rbYb2KZ4rTx0BmwId6EEwWAD1src5kjTvpWl+R20aGMteAUp1nQqHDxjq b5hFaLA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:722:b0:dcd:b431:7f5b with SMTP id l2-20020a056902072200b00dcdb4317f5bmr210121ybt.0.1709165752053; Wed, 28 Feb 2024 16:15:52 -0800 (PST) Date: Wed, 28 Feb 2024 16:15:28 -0800 In-Reply-To: <20240229001537.4158049-1-irogers@google.com> Message-Id: <20240229001537.4158049-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: <20240229001537.4158049-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 04/13] perf jevents: Add br metric group for branch statistics on AMD From: Ian Rogers To: Sandipan Das , Ravi Bangoria , 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: 1792190281645661715 X-GMAIL-MSGID: 1792190281645661715 The br metric group for branches itself comprises metric groups for total, taken, conditional, fused and far metric groups using json events. The lack of conditional events on anything but zen2 means this category is lacking on zen1, zen3 and zen4. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 104 +++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index ce3d1535483a..f8d5ba2861ee 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -7,6 +7,7 @@ import argparse import json import math import os +from typing import Optional parser = argparse.ArgumentParser(description="AMD perf json generator") parser.add_argument("-metricgroups", help="Generate metricgroups data", action='store_true') @@ -18,10 +19,112 @@ LoadEvents(directory) zen_model = int(args.model[6:]) interval_sec = Event("duration_time") +ins = Event("instructions") cycles = Event("cycles") # Number of CPU cycles scaled for SMT. smt_cycles = Select(cycles / 2, Literal("#smt_on"), cycles) +def AmdBr(): + def Total() -> MetricGroup: + br = Event("ex_ret_brn") + br_m_all = Event("ex_ret_brn_misp") + br_clr = Event("ex_ret_msprd_brnch_instr_dir_msmtch", "ex_ret_brn_resync") + + br_r = d_ratio(br, interval_sec) + ins_r = d_ratio(ins, br) + misp_r = d_ratio(br_m_all, br) + clr_r = d_ratio(br_clr, interval_sec) + + 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") + ]) + + def Taken() -> MetricGroup: + br = Event("ex_ret_brn_tkn") + br_m_tk = Event("ex_ret_brn_tkn_misp") + br_r = d_ratio(br, interval_sec) + ins_r = d_ratio(ins, br) + misp_r = d_ratio(br_m_tk, br) + 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%"), + Metric( + "br_taken_insn_between_branches", + "The number of instructions divided by the number of taken branches.", + ins_r, "insn"), + ]) + + def Conditional() -> Optional[MetricGroup]: + br = Event("ex_ret_cond") + br_r = d_ratio(br, interval_sec) + ins_r = d_ratio(ins, br) + + 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"), + ] + if zen_model == 2: + br_m_cond = Event("ex_ret_cond_misp") + misp_r = d_ratio(br_m_cond, br) + metrics += [ + Metric("br_cond_mispred", + "Retired conditional branch instructions mispredicted as a " + "percentage of all conditional branches.", misp_r, "100%"), + ] + + return MetricGroup("br_cond", metrics) + + def Fused() -> MetricGroup: + br = Event("ex_ret_fused_instr", "ex_ret_fus_brnch_inst") + br_r = d_ratio(br, interval_sec) + ins_r = d_ratio(ins, br) + return MetricGroup("br_cond", [ + Metric("br_fused_retired", + "Retired fused branch instructions per second.", br_r, "insn/s"), + Metric( + "br_fused_insn_between_branches", + "The number of instructions divided by the number of fused " + "branches.", ins_r, "insn"), + ]) + + def Far() -> MetricGroup: + br = Event("ex_ret_brn_far") + br_r = d_ratio(br, interval_sec) + ins_r = d_ratio(ins, br) + 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(), Fused(), Far()], + description="breakdown of retired branch instructions") + + def AmdUpc() -> Metric: ops = Event("ex_ret_ops", "ex_ret_cops") upc = d_ratio(ops, smt_cycles) @@ -58,6 +161,7 @@ def Rapl() -> MetricGroup: description="Processor socket power consumption estimates") all_metrics = MetricGroup("", [ + AmdBr(), AmdUpc(), Idle(), Rapl(), From patchwork Thu Feb 29 00:15:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208084 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp88318dyb; Wed, 28 Feb 2024 16:17:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVAN1ut1sMBQ6UsETdkq4WG71evu3OUZ13aIDnXDs5jszvyXKa83jddkeFjT3dLco3vjBQTaCrxbM7TwfIE/NSFbuUGIQ== X-Google-Smtp-Source: AGHT+IEDfHVrcp2PY4IzF7k382BNBYUW7n4splJJmxXIYq5Na30jyfFy/EA6lsJGrZKDkXNO44nf X-Received: by 2002:a05:6512:3ba7:b0:512:f307:71b0 with SMTP id g39-20020a0565123ba700b00512f30771b0mr358954lfv.7.1709165844143; Wed, 28 Feb 2024 16:17:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165844; cv=pass; d=google.com; s=arc-20160816; b=Zdw0JMmzwnGyXqWiAjCmjlxZ0haNpbBpuoXrfN+ykdFRvyvEfaxbAgwZVkOtMeT8fH m6hTVtVZCjUIAfXDatWc+ukLIUnxt7PM9JuVzyyzZIx2kNlPQa+v9v78djjxG+fBUm3D 7hDwB5lIwQnItFFW2yQMqHe3jz3hv46Wv/df0sJ/t65AgZ5coSFwde6+PFk/iyv/oNZB uAn2poHKl/2cWgzwEnH7lBAeJnPi5pdCqd3Y3I8Np7oXvblloDDRTng4SqGE8JqZc4No aiB0irCHZ5wgokRLBZt1n+ZOiR5Z3AcfrvxWabIvFkL88VLWXrE7kxMAppbFt3HsY8YK okcw== 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=gcc/qUxyeEjzpXo98Okf44ySOQGx/p2IAM001Az25yY=; fh=s1e1l94WWHXveLjgnGSPJ/09xrypH26f4oBCMC/IJzY=; b=ZP4iDBXX8wV6WQp22KA3sPXgByQAQDAYF5vRqTdjic2WtAyJ7V3+vXxYIJ2NKr0NxN pLgZzLVTpubCZDZNNotWZY1NVUf3N+BTCMosjUkjJBIgb3Uou2swDek/X61/mfe69dgP DXOqb4wQh94+Vasio+QGpGUwUOMX+38H/NFEU7eff3MFJQVLz+jV5yGUotW5j2XxlTYE 2RBdEc8FfHj+CkBB2DrzOtMuD975//uchhgNCm0XU9c9txXH+P9JWX56LxTgfxsUASuO 87+s7eXG036ui+ACBL2/uKGCPn8gqGiybyb3WDowHsf2PfYICCsNWiC+JjR3dtTJ3Ci7 bHEg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zXCkv7Gq; 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-85882-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85882-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 u9-20020a50d509000000b0056577684470si50964edi.246.2024.02.28.16.17.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:17:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85882-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=zXCkv7Gq; 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-85882-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85882-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 8FD841F21A45 for ; Thu, 29 Feb 2024 00:17:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D67F44366; Thu, 29 Feb 2024 00:16:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zXCkv7Gq" 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 35DE338F97 for ; Thu, 29 Feb 2024 00:15:54 +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=1709165756; cv=none; b=mzqu+DzwDY+mumyuJ9pUGJ+Wuq1fW7+93bVRQXQk/3pLadpwytxB13Gc9BkrEtQ4tfOt1vkSjkvd0p+Jw+BFH2zeeUL3uIZ8GU8raODY14iIiARGeEI+Vei9GPBlpLUXs97cldkhDVoJqQxoIA8QsgJk5iYHhGMvt+okEme04ms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165756; c=relaxed/simple; bh=+avI6OXSebapAM2pF6TaSl95UtS1MYUkS9EvCqrF/LU=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=JSrUCLn/rJRCGVsWJNgWLuxB/30Ixspj3CAgnwoKHJyGO1jba1RkpZxrbT6bPfyf/ieoOFHxL0fErMhLRB7GE2HrAcYLT8sTBXhWqYy/vUkkgOWxuMRVeanrOx+5B2hX+k4ecaxcYEnxAaPzo5bRRZaavWedTQBc9+03STDjEFM= 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=zXCkv7Gq; 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-6087ffdac8cso5032977b3.2 for ; Wed, 28 Feb 2024 16:15:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165754; x=1709770554; 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=gcc/qUxyeEjzpXo98Okf44ySOQGx/p2IAM001Az25yY=; b=zXCkv7GqQ7CeFtzE+jD4qIVcNbHuzq/Z+4gyLc1ocsHbWafSu4WXtTgXto4j1hPp3E vQ7EDv0ov2d9MWC5JNkZ6gbzlIPACBRk4715FLXGXO0ZLtmMSeQu608SpLnaQ9gU9zmd mN0s7yAvkwxoM9AHn1GOApy8mD/G15lsUurvaj7qKpCWjkwmwZgBoSg2BArArIE2+VbY 7zBFXWJ2VoobY6NcjDxEKEWbroxifxoQqedE05Q0DABzwzcm02eLsZSd8/3IaEVx1HWj f/Llslt1umtEsJAc8pyPoDPrp/PR9Mid8wMOsu0qnnUTgQUJe+9+YtC78SeOV227GVia Z/Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165754; x=1709770554; 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=gcc/qUxyeEjzpXo98Okf44ySOQGx/p2IAM001Az25yY=; b=tkVgd986hx3t4sHc3TvWkUBhiQbG0pCMYRT6r0hyIALAFC4Akaqf+4pNRy8XlJ+aLu xO8voIx+5fQ5n126U6tjYDwkcWRypPcajhgVtUDVoi/52DoaoA4nhducr1nGqKpd2Oqp 7OGrM1A8R+HMOjpa4JENce5iShDyFfdz9Ht87GMpbAC+lSAUhz6rUmWFbqvw1Lk9ia4g j469D0Rf91KtYhaFVmvvygGg/Kb+1xPYzgfqAsEv98LdhJTthh/E8AvkDSYrdJ4aCgVh NIoDbnxiXWDSpwkWDUFbaveKIMXvqWzVeFD4Lw944QL+m3m+c+2pkgVNYWnEj7pQGLYb vjew== X-Forwarded-Encrypted: i=1; AJvYcCWXlIV12qDKmAAl+65dOdvcZ3IGdQK6ZJ/dDAHasxu5XtKGP/RxjxjsiOi5RXX/dnL8/0Z98V8cvOA/IoIml3KG8G5yIvCxTlHdkpZW X-Gm-Message-State: AOJu0YyZxYS9topEdGV4eIeJiWJfIutcfkz/IrjfoCiRWBKV/Pwr3DZ6 qSugnJBsU1OY8Iq/Lc8H3MJkdaqNVha4KEw59kJjT3okEt3YQkJ06+bhL0vTbxuCgVsdHxbKMRm Jwwg9SQ== 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:dc6:e5e9:f3af with SMTP id w10-20020a056902100a00b00dc6e5e9f3afmr192114ybt.9.1709165754237; Wed, 28 Feb 2024 16:15:54 -0800 (PST) Date: Wed, 28 Feb 2024 16:15:29 -0800 In-Reply-To: <20240229001537.4158049-1-irogers@google.com> Message-Id: <20240229001537.4158049-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: <20240229001537.4158049-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 05/13] perf jevents: Add software prefetch (swpf) metric group for AMD From: Ian Rogers To: Sandipan Das , Ravi Bangoria , 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: 1792190284119331846 X-GMAIL-MSGID: 1792190284119331846 Add metrics that give the utility of software prefetches on zen2, zen3 and zen4. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 95 ++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index f8d5ba2861ee..52451bcb4bbf 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -125,6 +125,100 @@ def AmdBr(): description="breakdown of retired branch instructions") +def AmdSwpf() -> Optional[MetricGroup]: + """Returns a MetricGroup representing AMD software prefetch metrics.""" + if zen_model <= 1: + return None + + swp_ld = Event("ls_dispatch.ld_dispatch") + swp_t0 = Event("ls_pref_instr_disp.prefetch") + swp_w = Event("ls_pref_instr_disp.prefetch_w") # Missing on Zen1 + swp_nt = Event("ls_pref_instr_disp.prefetch_nta") + swp_mab = Event("ls_inef_sw_pref.mab_mch_cnt") + swp_l2 = Event("ls_sw_pf_dc_fills.local_l2", + "ls_sw_pf_dc_fills.lcl_l2", + "ls_sw_pf_dc_fill.ls_mabresp_lcl_l2") + swp_lc = Event("ls_sw_pf_dc_fills.local_ccx", + "ls_sw_pf_dc_fills.int_cache", + "ls_sw_pf_dc_fill.ls_mabresp_lcl_cache") + swp_lm = Event("ls_sw_pf_dc_fills.dram_io_near", + "ls_sw_pf_dc_fills.mem_io_local", + "ls_sw_pf_dc_fill.ls_mabresp_lcl_dram") + swp_rc = Event("ls_sw_pf_dc_fills.far_cache", + "ls_sw_pf_dc_fills.ext_cache_remote", + "ls_sw_pf_dc_fill.ls_mabresp_rmt_cache") + swp_rm = Event("ls_sw_pf_dc_fills.dram_io_far", + "ls_sw_pf_dc_fills.mem_io_remote", + "ls_sw_pf_dc_fill.ls_mabresp_rmt_dram") + + # All the swpf that were satisfied beyond L1D are good. + all_pf = swp_t0 + swp_w + swp_nt + good_pf = swp_l2 + swp_lc + swp_lm + swp_rc + swp_rm + bad_pf = max(all_pf - good_pf, 0) + + loc_pf = swp_l2 + swp_lc + swp_lm + rem_pf = swp_rc + swp_rm + + req_pend = max(0, bad_pf - swp_mab) + + r1 = d_ratio(ins, all_pf) + r2 = d_ratio(swp_ld, all_pf) + r3 = d_ratio(swp_t0, interval_sec) + r4 = d_ratio(swp_w, interval_sec) + r5 = d_ratio(swp_nt, interval_sec) + overview = MetricGroup("swpf_overview", [ + Metric("swpf_ov_insn_bt_swpf", "Insn between SWPF", r1, "insns"), + Metric("swpf_ov_loads_bt_swpf", "Loads between SWPF", r2, "loads"), + Metric("swpf_ov_rate_prefetch_t0_t1_t2", "Rate prefetch TO_T1_T2", r3, + "insns/sec"), + Metric("swpf_ov_rate_prefetch_w", "Rate prefetch W", r4, "insns/sec"), + Metric("swpf_ov_rate_preftech_nta", "Rate prefetch NTA", r5, "insns/sec"), + ]) + + r1 = d_ratio(swp_mab, all_pf) + r2 = d_ratio(req_pend, all_pf) + usefulness_bad = MetricGroup("swpf_usefulness_bad", [ + Metric("swpf_use_bad_hit_l1", "Usefulness bad hit L1", r1, "100%"), + Metric("swpf_use_bad_req_pend", "Usefulness bad req pending", r2, "100%"), + ]) + + r1 = d_ratio(good_pf, all_pf) + usefulness_good = MetricGroup("swpf_usefulness_good", [ + Metric("swpf_use_good_other_src", "Usefulness good other src", r1, + "100%"), + ]) + + usefulness = MetricGroup("swpf_usefulness", [ + usefulness_bad, + usefulness_good, + ]) + + r1 = d_ratio(swp_l2, good_pf) + r2 = d_ratio(swp_lc, good_pf) + r3 = d_ratio(swp_lm, good_pf) + data_src_local = MetricGroup("swpf_data_src_local", [ + Metric("swpf_data_src_local_l2", "Data source local l2", r1, "100%"), + Metric("swpf_data_src_local_ccx_l3_loc_ccx", + "Data source local ccx l3 loc ccx", r2, "100%"), + Metric("swpf_data_src_local_memory_or_io", + "Data source local memory or IO", r3, "100%"), + ]) + + r1 = d_ratio(swp_rc, good_pf) + r2 = d_ratio(swp_rm, good_pf) + data_src_remote = MetricGroup("swpf_data_src_remote", [ + Metric("swpf_data_src_remote_cache", "Data source remote cache", r1, + "100%"), + Metric("swpf_data_src_remote_memory_or_io", + "Data source remote memory or IO", r2, "100%"), + ]) + + data_src = MetricGroup("swpf_data_src", [data_src_local, data_src_remote]) + + return MetricGroup("swpf", [overview, usefulness, data_src], + description="Sofware prefetch breakdown (CCX L3 = L3 of current thread, Loc CCX = CCX cache on some socket)") + + def AmdUpc() -> Metric: ops = Event("ex_ret_ops", "ex_ret_cops") upc = d_ratio(ops, smt_cycles) @@ -162,6 +256,7 @@ def Rapl() -> MetricGroup: all_metrics = MetricGroup("", [ AmdBr(), + AmdSwpf(), AmdUpc(), Idle(), Rapl(), From patchwork Thu Feb 29 00:15:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208085 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp88398dyb; Wed, 28 Feb 2024 16:17:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWbbDK+yuf+p9BqNfEXTDexqAFHGsZedkzJYXuBg4Krm02uqRi/NF8ZSyK4BhEKjkxmlNoblG1eFx+GfzcO+1aFs+ik0g== X-Google-Smtp-Source: AGHT+IHtLzqFoPnbb7gWludHn+jtZnivbwXD0V7Vi9uLmDSxJC//Nx1fFCOP9vH3lYV9+16+jCjK X-Received: by 2002:a05:6402:1e87:b0:566:4ccd:b81d with SMTP id f7-20020a0564021e8700b005664ccdb81dmr355348edf.7.1709165857808; Wed, 28 Feb 2024 16:17:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165857; cv=pass; d=google.com; s=arc-20160816; b=qzUFzuNlhgY09CE2WX+tPIeZdsBDamxnnhCQRGNAlZWH+lkWkJXieSg+DJFHtXHgmj ObVfkASAQo29VY0D6EUHFX6JQK6rm6MeO/Z9HRIiWp0k6CWKY9CYC0UCGvM4XFU8048T hy6TpNG/icm3e7gk9LK7yLXxTkCzyQIIYRp1xp6cGX+43/gnHHYXgYDQAqcZ0LEaDxmW TEhEwCBt5/Xh34nr/NInXnpy21CoLsBM/zEVIj39prTh3Yup9OnIIDhun604CX4y3/M3 fCKnpWmY6GnFX8rqk2QyLyS1oV+KWfS3tkARJTpLTNgocxgnzeeNucV5qjSlL8dbBi6S BcDw== 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=VbbMwVexzgBT1fsV6th5WqgIzFECec7b7GQZlOqA780=; fh=BzPoibvDyKLzbASCzVQmx8UoedIili3vi5gyu0qE/rk=; b=xND2TH91BO1vx4AmjKHe2ZXkfPdC1af+WpsCSTE9TEyDsp2EGP7Ak8lFWfHWpa6ph7 ra7hlh7Qu8dLWh+bCPpMNSZ6z+bQMbRy+5bNindAJDKod2rMRQ5YfWurVFjc64zpjQqs +Td3Ziiel//mhWLFz/0P7hNXaArkokYnvqFBiBCoL7HaRnoGz7rxFX4AAcqbEuI/srjV 8nZLzmfGUMdHHn/7rycPW/tZHiVCz03y1AUKcy+k9x4G5uPvaKL+UUYUPCqE6Arne21w nt6zHH5el8MEkxw201VrlKRFNwhuIwfvsdZnKmBBfWdVT49aGTj8R23deR4GgHT1sJXH gwSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="YDzozVH/"; 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-85883-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85883-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 u9-20020a50d509000000b0056577684470si50964edi.246.2024.02.28.16.17.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:17:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85883-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="YDzozVH/"; 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-85883-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85883-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 445231F218E8 for ; Thu, 29 Feb 2024 00:17:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0FF324643B; Thu, 29 Feb 2024 00:16:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YDzozVH/" 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 53A5D42054 for ; Thu, 29 Feb 2024 00:15:57 +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=1709165758; cv=none; b=BMs9ZSBtdPx8PLw7ORgVb3yRKOOtygf3z0FcN7igA8XRACwEXZ0dyXdic59U3UONgEePlWfbs1Y/d8vu8e3edrkR9g+0q7BItosJB5PWwcCKagGjpeaRBPR6pWywWyR6I0jkM4dicAe1a16sE6XRWXNQzykioIOrxChiS8/QBSY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165758; c=relaxed/simple; bh=5rPQbQbgB4a9rwpPs3GZO8lIicUTIgfjGCJZshFzKwg=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=XzflOeSDGdk2E2qhejoYkWiEixL5h+ux1e5s4B9+flVdEfc6ex2XYnaS2/BkvgieUBfbwzrxOGffAmFXBAVPh3olNGeylae5EascRIjanHT9bdgc0sMqpXTurCTZLcI167q0EHYdo+vQg2q6ADvN7SBp9+v3UTgFVUX+wac+chs= 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=YDzozVH/; 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-60957e0b914so6065867b3.0 for ; Wed, 28 Feb 2024 16:15:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165756; x=1709770556; 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=VbbMwVexzgBT1fsV6th5WqgIzFECec7b7GQZlOqA780=; b=YDzozVH/Jah8I1SlVaJCYSs6zJpYfc5oEEdA/gzpxXANV2ChywCMF7cOjKqBlzMns7 1hdk1Odpgpx0OMsz3sl6Lt2jsIbyCwAX4wKetSO0SoYa7fGwyDL9+GkPnyEylf9K5LfJ UH+yxsc6aNSV7hVLIGoXGXEYpYusVIVsMbo8Gf7y8cD4+XkgVHhn8uSoyB8VktNa7xYZ d+NmJ/yzt29JdjM2es6xqU8Bgnshijtc0Uo4SjtHYfz2NwLQKL1uB80ObYe/s745A7zd zZlcdevzDp2UzRJXZJlF/r2exmY2jJUNp7lpl2MHztoUvSWdPkTUSgxOVbDpIMkZMkxx E0kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165756; x=1709770556; 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=VbbMwVexzgBT1fsV6th5WqgIzFECec7b7GQZlOqA780=; b=Nxjl+gobvAuA2gYt0/OxPVtA7DlSP8fpjzaDsjK2PaVFCln1Zsno5BheT000i9WOPd 31B1dsVTgjM+Bf2eARC2pfRJI4wobq1KOuBJ03c+dMlevVG6Z02dd5deW7l84lIXhp70 wE9Xe2R/oW5PyprxF2t975/r6gJQK0buj7x1VyL2J2UJXbk19CrHYscv16t1Aui1umv+ H/dBYgVH2hdPh9FzxWsHcCbv6qe1u8XjrwIgnqRAcceV8pa5haFWm1KhD7Zj/qCgkE0g ZYhrV9kKEl1Y7G+y1YXSigvWlXsSHBna6wtTmowzsdCzJmZS8sCsRP4A6cEWvImu9zXL OLIA== X-Forwarded-Encrypted: i=1; AJvYcCU8JjhOH/BrdXFBBEo+CTkDIc7JrLv2QII2vi4jRNwuSdoRH4zrDNQU2VxaSev1oMnyiwRcZPkMGjx7MZ6yjNxilu7hD1bFc/7lSURx X-Gm-Message-State: AOJu0YzOSIbqH48j43AEC7wYnPX6q54wouzAw6/0ztYSOU3NVJFQfaPH jteq4OwEdN7u6ZFM/ggDNjerLLtUflfurwVb8dHSPv4KM75S/qJx8d2cWzBqacF67aD7NQbdO0X 5/U9OMw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:690c:3507:b0:608:e67f:4387 with SMTP id fq7-20020a05690c350700b00608e67f4387mr136175ywb.7.1709165756654; Wed, 28 Feb 2024 16:15:56 -0800 (PST) Date: Wed, 28 Feb 2024 16:15:30 -0800 In-Reply-To: <20240229001537.4158049-1-irogers@google.com> Message-Id: <20240229001537.4158049-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: <20240229001537.4158049-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 06/13] perf jevents: Add hardware prefetch (hwpf) metric group for AMD From: Ian Rogers To: Sandipan Das , Ravi Bangoria , 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: 1792190298735085931 X-GMAIL-MSGID: 1792190298735085931 Add metrics that give the utility of hardware prefetches on zen2, zen3 and zen4. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 61 ++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index 52451bcb4bbf..dda904998269 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -125,6 +125,66 @@ def AmdBr(): description="breakdown of retired branch instructions") +def AmdHwpf(): + """Returns a MetricGroup representing AMD hardware prefetch metrics.""" + if zen_model <= 1: + return None + + hwp_ld = Event("ls_dispatch.ld_dispatch") + hwp_l2 = Event("ls_hw_pf_dc_fills.local_l2", + "ls_hw_pf_dc_fills.lcl_l2", + "ls_hw_pf_dc_fill.ls_mabresp_lcl_l2") + hwp_lc = Event("ls_hw_pf_dc_fills.local_ccx", + "ls_hw_pf_dc_fills.int_cache", + "ls_hw_pf_dc_fill.ls_mabresp_lcl_cache") + hwp_lm = Event("ls_hw_pf_dc_fills.dram_io_near", + "ls_hw_pf_dc_fills.mem_io_local", + "ls_hw_pf_dc_fill.ls_mabresp_lcl_dram") + hwp_rc = Event("ls_hw_pf_dc_fills.far_cache", + "ls_hw_pf_dc_fills.ext_cache_remote", + "ls_hw_pf_dc_fill.ls_mabresp_rmt_cache") + hwp_rm = Event("ls_hw_pf_dc_fills.dram_io_far", + "ls_hw_pf_dc_fills.mem_io_remote", + "ls_hw_pf_dc_fill.ls_mabresp_rmt_dram") + + loc_pf = hwp_l2 + hwp_lc + hwp_lm + rem_pf = hwp_rc + hwp_rm + all_pf = loc_pf + rem_pf + + r1 = d_ratio(ins, all_pf) + r2 = d_ratio(hwp_ld, all_pf) + r3 = d_ratio(all_pf, interval_sec) + + overview = MetricGroup("hwpf_overview", [ + Metric("hwpf_ov_insn_bt_hwpf", "Insn between HWPF", r1, "insns"), + Metric("hwpf_ov_loads_bt_hwpf", "Loads between HWPF", r2, "loads"), + Metric("hwpf_ov_rate", "HWPF per second", r3, "hwpf/s"), + ]) + r1 = d_ratio(hwp_l2, all_pf) + r2 = d_ratio(hwp_lc, all_pf) + r3 = d_ratio(hwp_lm, all_pf) + data_src_local = MetricGroup("hwpf_data_src_local", [ + Metric("hwpf_data_src_local_l2", "Data source local l2", r1, "100%"), + Metric("hwpf_data_src_local_ccx_l3_loc_ccx", + "Data source local ccx l3 loc ccx", r2, "100%"), + Metric("hwpf_data_src_local_memory_or_io", + "Data source local memory or IO", r3, "100%"), + ]) + + r1 = d_ratio(hwp_rc, all_pf) + r2 = d_ratio(hwp_rm, all_pf) + data_src_remote = MetricGroup("hwpf_data_src_remote", [ + Metric("hwpf_data_src_remote_cache", "Data source remote cache", r1, + "100%"), + Metric("hwpf_data_src_remote_memory_or_io", + "Data source remote memory or IO", r2, "100%"), + ]) + + data_src = MetricGroup("hwpf_data_src", [data_src_local, data_src_remote]) + return MetricGroup("hwpf", [overview, data_src], + description="Hardware prefetch breakdown (CCX L3 = L3 of current thread, Loc CCX = CCX cache on some socket)") + + def AmdSwpf() -> Optional[MetricGroup]: """Returns a MetricGroup representing AMD software prefetch metrics.""" if zen_model <= 1: @@ -256,6 +316,7 @@ def Rapl() -> MetricGroup: all_metrics = MetricGroup("", [ AmdBr(), + AmdHwpf(), AmdSwpf(), AmdUpc(), Idle(), From patchwork Thu Feb 29 00:15:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208086 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp88462dyb; Wed, 28 Feb 2024 16:17:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVhWL4FPQAabchhFpvus3Spcc0czFWDJEQ22R7PZcxLRhxe/v02EwV3Mnyw3EbPWbCmkBR8BEacyzAjh200dKC89F+y4A== X-Google-Smtp-Source: AGHT+IHdwcNsIVgmOZWdViQOgVvfu8wfFgF1yo++6p0bnQ7E4Ebjj5okW3GPMOAU+EzmwXvxkvu0 X-Received: by 2002:a05:622a:1788:b0:42c:66fd:3fc with SMTP id s8-20020a05622a178800b0042c66fd03fcmr550299qtk.56.1709165867266; Wed, 28 Feb 2024 16:17:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165867; cv=pass; d=google.com; s=arc-20160816; b=jnCmqqSrrQHDSb39gbudiZ02HMgJkSs6xETrGoeUbbzeFrltKNakWbRp4NjmZzsUsb A1PUP58ofNB1/15yjGUCIyJU1JwqhYMxg2m4pnuCcGpVQ2mgHTM0JHok58GiZ9Vk6nLK IVU57OQREw1vcXQXWRDo84a3+JZor32hLqKb9C5DxV8Rt19CanG+9LcU0BQ5yaboRBP3 6K8lqPHAUUFcg2epPd96JLaa7Uv2f+W8deW+E8jJlIEX1Um7XJ74MnTvq1EeM84aAC8O l+IfsEtxzmKyTlwea9ce2i6JFDeVvFLbHmE38VbxMW8lBbVGbWHZ1sn2sxaRqRb1A6Dx kd1Q== 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=3qpQTOjMlbYqRHWOkfWf3rXeImb6hJen/IuHxVmpGuM=; fh=AkWk3/hqAplbLW4LASUu+aT68khoAVRDa8Ef18tBKvo=; b=KvBqQjKEc5C/uOU4cVctbvgjEi3fsWIkzDJ3ruXYw0dwrFUMBcWzTyq8kF6GypyJPv eVXeXG8WtA5N4unGBCiEElAY2a5upBXoyh5fYuf6A2ib22ICq1h/yZSX26rWpOvZ/SCL vHjkv535R7R0EVgj/RdlaiJ5Hk+HInxbdjdu2c2W7sZltR+Jk4niF3kM7QKl/GHqREXy Wk1k7dEU+W+tJUEMiv4Y8b0PVpalMAdwm8lx/P05MUaSscfv9faI8SBpDO0DFQamX1uh LBxJbna5qK12cpZLF8Q1CsZa9NFWKRuHZxvTHvfOuZf3QB5XTPrr87+Ka2CT4gnySocE l3BQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lioECYG4; 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-85884-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85884-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 e5-20020ac84e45000000b0042daa920d4esi307448qtw.305.2024.02.28.16.17.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:17:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85884-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=lioECYG4; 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-85884-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85884-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 04F451C212B3 for ; Thu, 29 Feb 2024 00:17:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F1B952F61; Thu, 29 Feb 2024 00:16:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lioECYG4" 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 94B8042A8C for ; Thu, 29 Feb 2024 00:15: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=1709165761; cv=none; b=dCcrgzhMQ68dB+zoOPM+udegtlEc02GFTWz0lQ7IySbr+M/wxCRi16vsGycOU8cir18JbVDbHdoyTmh7VjAVqZjUoSqEcfPta0jz5OTEiqVL/kDnvhut/Q9RIOJHMM582RTo2Efe6L67Luf8SG1UykycRTy10hey89WvWVZWB4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165761; c=relaxed/simple; bh=Ttu1a53AKHn6jERMdPOWyCk47DSzrYVS6BszAMd1Sa0=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=akr8b/TI8nLOoOs3YNn4e0S8zBaK4DP4YvWRPkEthA2qwzV6S2Mi5PIqhveN81sERhpbeHO2/Vt7kjVQtrJd2ogmX4SJxvu9FMvQaAGe68IvJiJ769e8E+kvC1RuuZBou5dGwLxmYbQRA9CKKFRLN3zdg+SU52soOqT1V7D/TX0= 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=lioECYG4; 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-608d6ffc64eso5239417b3.0 for ; Wed, 28 Feb 2024 16:15:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165759; x=1709770559; 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=3qpQTOjMlbYqRHWOkfWf3rXeImb6hJen/IuHxVmpGuM=; b=lioECYG45CGgEL39o9YCUX3yfw0g786m17svPDv+ee9ph8Uc6BIALvCO8gPAnXvxvb Y1cxl2T+y8aEG6uHjYnTwSxGIvg1BJ6XS50rTLdBgwcf9loE6HdC7CupVXxxsts/Yfli XNfnsQkR3gwtHKl4c1IzZrdSPZxugVD73Mhf3F5BVzme4Lr/BBx9A5YzRIMV9VsWT0Vv bgv/zJEq4T3SphnZOhndqhX2LJ92cHNOUiwMuB80pk4R1Ll72nZRJtGhy6SvPFPx66Oh ywd4Q1VC0X+ZvbvIb1HZN8uNYbTrxEsOfyn5zyNPBMYIpFLlvQFUuBtdPlnksp+iv1hc rCcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165759; x=1709770559; 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=3qpQTOjMlbYqRHWOkfWf3rXeImb6hJen/IuHxVmpGuM=; b=QdRISXz45qFjMw88EnISACzjdsyMlsH4P4Twdy3cckyiBr8+Y4EfbjLcZ+mMMcUSbs pQz4yPP3rx4EzyJuIRvrehmIjT+zql+UN/hccOP42Km8wY8i97KgPUS28L2x2+bU1fvp mNMOhEQmOZQA4s/iSPXHBuKCDGsenWExibAyhJDEDsUe8Rh8rDu7zUEXlesPSXg52pKM 6enVDU6NWLUy/9D1OcoNFH7FEZYnqfz4xvp/OXTvHN1Kk9BNLd/3APx+rzMNNeFCrZCE vxU/3Vt8CyV9Wd6Vy5hH5hLfpm/tacl8dgr8T+ZKQG1U9vM3PHevLn7BzaeWPX4a8ue4 0FCQ== X-Forwarded-Encrypted: i=1; AJvYcCXu3P8s3Exg+3quWFhDQ7AheRJWSTe2aDx0qCLmpRp01QbR9qHZ2ANoORjXcWeeMOAokavO4056u84mNn2SmPbXz71wEET6flplf75y X-Gm-Message-State: AOJu0YwtpmK61dQxsTGIpQLIdYYV3chtv5aZdFoj2ISmnL1hzMEKDZ3r uPrsNfOZ9Wj/RjA1ztLt9lPsOi2MRQlkfifBuiUFVFvo4mAh6r0IxxKfwDXSFzxGXFNrLnJ4tSL zp5Nkcw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:690c:360a:b0:609:6150:da22 with SMTP id ft10-20020a05690c360a00b006096150da22mr77628ywb.1.1709165758889; Wed, 28 Feb 2024 16:15:58 -0800 (PST) Date: Wed, 28 Feb 2024 16:15:31 -0800 In-Reply-To: <20240229001537.4158049-1-irogers@google.com> Message-Id: <20240229001537.4158049-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: <20240229001537.4158049-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 07/13] perf jevents: Add itlb metric group for AMD From: Ian Rogers To: Sandipan Das , Ravi Bangoria , 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: 1792190308353556416 X-GMAIL-MSGID: 1792190308353556416 Add metrics that give an overview and details of the l1 itlb (zen1, zen2, zen3) and l2 itlb (all zens). Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index dda904998269..82aab39c2a50 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -125,6 +125,52 @@ def AmdBr(): description="breakdown of retired branch instructions") +def AmdItlb(): + l2h = Event("bp_l1_tlb_miss_l2_tlb_hit", "bp_l1_tlb_miss_l2_hit") + l2m = Event("l2_itlb_misses") + l2r = l2h + l2m + + itlb_l1_mg = None + l1m = l2r + if zen_model <= 3: + l1r = Event("ic_fw32") + l1h = max(l1r - l1m, 0) + itlb_l1_mg = MetricGroup("itlb_l1", [ + Metric("itlb_l1_hits", + "L1 ITLB hits as a perecentage of L1 ITLB accesses.", + d_ratio(l1h, l1h + l1m), "100%"), + Metric("itlb_l1_miss", + "L1 ITLB misses as a perecentage of L1 ITLB accesses.", + d_ratio(l1m, l1h + l1m), "100%"), + Metric("itlb_l1_reqs", + "The number of 32B fetch windows transferred from IC pipe to DE " + "instruction decoder per second.", d_ratio(l1r, interval_sec), + "windows/sec"), + ]) + + return MetricGroup("itlb", [ + MetricGroup("itlb_ov", [ + Metric("itlb_ov_insn_bt_l1_miss", + "Number of instructions between l1 misses", d_ratio( + ins, l1m), "insns"), + Metric("itlb_ov_insn_bt_l2_miss", + "Number of instructions between l2 misses", d_ratio( + ins, l2m), "insns"), + ]), + itlb_l1_mg, + MetricGroup("itlb_l2", [ + Metric("itlb_l2_hits", + "L2 ITLB hits as a percentage of all L2 ITLB accesses.", + d_ratio(l2h, l2r), "100%"), + Metric("itlb_l2_miss", + "L2 ITLB misses as a percentage of all L2 ITLB accesses.", + d_ratio(l2m, l2r), "100%"), + Metric("itlb_l2_reqs", "ITLB accesses per second.", + d_ratio(l2r, interval_sec), "accesses/sec"), + ]), + ], description="Instruction TLB breakdown") + + def AmdHwpf(): """Returns a MetricGroup representing AMD hardware prefetch metrics.""" if zen_model <= 1: @@ -316,6 +362,7 @@ def Rapl() -> MetricGroup: all_metrics = MetricGroup("", [ AmdBr(), + AmdItlb(), AmdHwpf(), AmdSwpf(), AmdUpc(), From patchwork Thu Feb 29 00:15:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208087 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp88570dyb; Wed, 28 Feb 2024 16:18:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXrPo6BNkrwjTQ6BxusGH5RGxDxQogJFzX0dF3FBK5uMhHNZypqCB+OC8EVQIBjryQlPuxiazoc1ErqPpAY3zmk/R+Q1w== X-Google-Smtp-Source: AGHT+IEsvSnApGpQBrmHxQGW8+rPt/iODTAdqT0Z/IGLUV/z1was9+Ni0m0K9Tw8t28WjFJr5SYh X-Received: by 2002:ac8:5788:0:b0:42e:5c3a:8b2d with SMTP id v8-20020ac85788000000b0042e5c3a8b2dmr714598qta.1.1709165885503; Wed, 28 Feb 2024 16:18:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165885; cv=pass; d=google.com; s=arc-20160816; b=e4hx+TbmdSQeXK/F2udAR+8sXDZvWS6Btf/1yL3PGH3+5/vDX2mOOpXEKzBx7TfGW3 0ZO5C8RUs4/2fP+nUa7TDf9c4Gq/ahGksu6QVaTwmx0p9+80UJYIo+ptfaLgQn3490jQ T98MlmVqVdLMO5t8IMJnxq0blUSBqczv+jNZtPv81NgFNzYzfGq/UDdQegOzM8aI/4/C xpNHWj35CDcK22BZ/0hzKjwhzUGIHVMM1bTe6/VpKmV8QNBRRc5En/z/CbNuIaUCO9kZ uJ3MT+WUw0FNa0DR39gL/5Wx5aNuOLl06y3yKEk9E40oUmipNbZ/bWgDbzxlTFYoZJnZ f9Ow== 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=QW5aXCnWYkSdBtfKb1tyFWz2NLyYuSqZgMPUtXRmNrc=; fh=XdNErsMBco6waxlkY0yt1a6QvphmKIJMBRtrdcuxld4=; b=ILBvWRAqz0swHy+Iu3WQvIH3vpRJE6AcOivsVmPZ+MAaQlkIPXVLjUm1zQ67CF1fuE XTLFYfFjqfeDeu17/3Rw4BrL+aPIUsKXbGUEEivTeTeZ8v6UmNgfI0OnIhsUxJa6kRKP cY9ihCDbNmkIUVb5//+/ysIaH6Ut0iQjeFeaeiiCAeYMCqdiF19Oa8G9WRJS2tL7TvGY QC6lw5HcbXvKlJiQLXPluRxL+8MX8Xg3bVblOxUbkuSSt6hAft908sli7gui3WqGdEb4 lGLqYzwaFqKwQ5Pf5ZJbkD3x9SOmBQRRnp8r/enBF5pbtM6LkhtE+xWC2Vq/JF5Rb/QZ 2GTg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SPBT0UwO; 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-85885-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85885-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 21-20020ac85755000000b0042dfa21270bsi315306qtx.605.2024.02.28.16.18.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:18:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85885-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=SPBT0UwO; 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-85885-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85885-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 40B421C2112B for ; Thu, 29 Feb 2024 00:18:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4669355C16; Thu, 29 Feb 2024 00:16:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SPBT0UwO" 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 083384597B for ; Thu, 29 Feb 2024 00:16:01 +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=1709165763; cv=none; b=ZRgbCwA1pB8cCDxi8D7zmvcURT70zR4RndZcw08HLVwKWFXWJ6Q0LhldGSVbeQZdFuUSO9XYATgs3oefqXwmANiKEcbKuB/EBnjqAb1B2zdJNz5JB0mVdNbOL/A9CE4nmzbvfwQRj5wfubQPf5Q3g+DwLmm4iIu2nqiRLgnPGNk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165763; c=relaxed/simple; bh=XBT9PFw4GJEI1QEQOFY5V3VQlW/6wsuXkDB+REWJty8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=RDT4kgnrJqE3UQjTLQcHPgd+jtphlMPftCvY+ui3t7r1tStFZAreN8FESU8Ai5yge8LQInuHKMEP0KBOzkTmZ13ZhqOWsCzc74oIZSKMOXmuEvUy6r3fIjU4pvFiNtgcZs+t4aqtiISbSsJvbGRhfzO1e16bBoOKXN/pspQNJJ8= 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=SPBT0UwO; 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-607e613a1baso6366057b3.1 for ; Wed, 28 Feb 2024 16:16:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165761; x=1709770561; 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=QW5aXCnWYkSdBtfKb1tyFWz2NLyYuSqZgMPUtXRmNrc=; b=SPBT0UwOP189pEkqlR+5OWkMnB4O0Ss2w7sWMWEJZ6qyKbyNSUqOXsy511kMeegK9R tc5QFK2L5/8cTHbUz/pXvP614sWZUkr1U3sUqmBfLht04/HyiBSGXSteqjnyId3uCFHf udTL0DBSqmLuYyPxO8DVxYQnuTO2HcBOmAYBeaHImVJA9RMwrsYYMob+PFBLcijP4WHD gOqL++/tyht52ctGb1yauHQZ/u0KdJMisQXuMtsjhqiyG9MyDW9rLkQKTVEBfWuuKFY0 uwwo0mpCG3X29V7wStOlHzBTL7vQ5Zr7DvywYnPqbholNCqMSBmxlTPW4m7Dd6XlpgV6 paNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165761; x=1709770561; 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=QW5aXCnWYkSdBtfKb1tyFWz2NLyYuSqZgMPUtXRmNrc=; b=SJ/HI+LUdaztVU+zEJLIAB+lZC7iCqdECD9FHLfNRt1sOv8xgMxZf1m72asrM1/GKF houWQpN4PN+gPDPU+TcEyXsfEZFPV3DTrexEJz1a5XxmnrrpK77PDVt2u7+hNP7SfVqX LWxUK1nOH5qfXE6UOrOZlgYvnZUYuQgOCvnHgsSQGDIZDvcgoN8RJOWT1qSf3UnDNyOX jKMwfPwrY6sgjQMp+FI/PuOf9e8CMrjmGUmc5tNHUVhkLQfzdFjmzJCqxVt4/2C8MoIy pdh0GeLHThPuJzHdPYfWUNVxqxrlAM4BHKc62DVHgQyk10bPxG73wYytqan7w9UsZskq WwUQ== X-Forwarded-Encrypted: i=1; AJvYcCW7A+MqGG0nueg7bjbr8wdOjRWLSBApKgXKG2YY7iIj+fOs8CRvA5g5WPNu28Zu+vGnBeF2bE/DsMZLljD13a264dWr/vReNpRMvUnp X-Gm-Message-State: AOJu0Yx5XZGbZ/+bNlcrZ2d5RnRHi3LdMe7DzMFPbA6c7jI9UR3A8YaT gJvmhI5eQVe6k/6ch0K/yvpGTGMPzt8X8uRgLqQo7XIQvGvtaNlMrzj7BLOsFj5PdWzv9uPIffv KpG4vxw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:690c:c9b:b0:609:247a:fd3c with SMTP id cm27-20020a05690c0c9b00b00609247afd3cmr159686ywb.2.1709165761129; Wed, 28 Feb 2024 16:16:01 -0800 (PST) Date: Wed, 28 Feb 2024 16:15:32 -0800 In-Reply-To: <20240229001537.4158049-1-irogers@google.com> Message-Id: <20240229001537.4158049-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: <20240229001537.4158049-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 08/13] perf jevents: Add dtlb metric group for AMD From: Ian Rogers To: Sandipan Das , Ravi Bangoria , 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: 1792190327839791943 X-GMAIL-MSGID: 1792190327839791943 Add metrics that give an overview and details of the dtlb (zen1, zen2, zen3). Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 108 +++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index 82aab39c2a50..be10acb40762 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -125,6 +125,113 @@ def AmdBr(): description="breakdown of retired branch instructions") +def AmdDtlb() -> Optional[MetricGroup]: + if zen_model >= 4: + return None + + d_dat = Event("ls_dc_accesses") if zen_model <= 3 else None + d_h4k = Event("ls_l1_d_tlb_miss.tlb_reload_4k_l2_hit") + d_hcoal = Event("ls_l1_d_tlb_miss.tlb_reload_coalesced_page_hit") if zen_model >= 2 else 0 + d_h2m = Event("ls_l1_d_tlb_miss.tlb_reload_2m_l2_hit") + d_h1g = Event("ls_l1_d_tlb_miss.tlb_reload_1g_l2_hit") + + d_m4k = Event("ls_l1_d_tlb_miss.tlb_reload_4k_l2_miss") + d_mcoal = Event("ls_l1_d_tlb_miss.tlb_reload_coalesced_page_miss") if zen_model >= 2 else 0 + d_m2m = Event("ls_l1_d_tlb_miss.tlb_reload_2m_l2_miss") + d_m1g = Event("ls_l1_d_tlb_miss.tlb_reload_1g_l2_miss") + + d_w0 = Event("ls_tablewalker.dc_type0") if zen_model <= 3 else None + d_w1 = Event("ls_tablewalker.dc_type1") if zen_model <= 3 else None + walks = d_w0 + d_w1 + walks_r = d_ratio(walks, interval_sec) + ins_w = d_ratio(ins, walks) + l1 = d_dat + l1_r = d_ratio(l1, interval_sec) + l2_hits = d_h4k + d_hcoal + d_h2m + d_h1g + l2_miss = d_m4k + d_mcoal + d_m2m + d_m1g + l2_r = d_ratio(l2_hits + l2_miss, interval_sec) + l1_miss = l2_hits + l2_miss + walks + l1_hits = max(l1 - l1_miss, 0) + ins_l = d_ratio(ins, l1_miss) + + return MetricGroup("dtlb", [ + MetricGroup("dtlb_ov", [ + Metric("dtlb_ov_insn_bt_l1_miss", + "DTLB overview: instructions between l1 misses.", ins_l, + "insns"), + Metric("dtlb_ov_insn_bt_walks", + "DTLB overview: instructions between dtlb page table walks.", + ins_w, "insns"), + ]), + MetricGroup("dtlb_l1", [ + Metric("dtlb_l1_hits", + "DTLB L1 hits as percentage of all DTLB L1 accesses.", + d_ratio(l1_hits, l1), "100%"), + Metric("dtlb_l1_miss", + "DTLB L1 misses as percentage of all DTLB L1 accesses.", + d_ratio(l1_miss, l1), "100%"), + Metric("dtlb_l1_reqs", "DTLB L1 accesses per second.", l1_r, + "insns/s"), + ]), + MetricGroup("dtlb_l2", [ + Metric("dtlb_l2_hits", + "DTLB L2 hits as percentage of all DTLB L2 accesses.", + d_ratio(l2_hits, l2_hits + l2_miss), "100%"), + Metric("dtlb_l2_miss", + "DTLB L2 misses as percentage of all DTLB L2 accesses.", + d_ratio(l2_miss, l2_hits + l2_miss), "100%"), + Metric("dtlb_l2_reqs", "DTLB L2 accesses per second.", l2_r, + "insns/s"), + MetricGroup("dtlb_l2_4kb", [ + Metric( + "dtlb_l2_4kb_hits", + "DTLB L2 4kb page size hits as percentage of all DTLB L2 4kb " + "accesses.", d_ratio(d_h4k, d_h4k + d_m4k), "100%"), + Metric( + "dtlb_l2_4kb_miss", + "DTLB L2 4kb page size misses as percentage of all DTLB L2 4kb" + "accesses.", d_ratio(d_m4k, d_h4k + d_m4k), "100%") + ]), + MetricGroup("dtlb_l2_coalesced", [ + Metric( + "dtlb_l2_coal_hits", + "DTLB L2 coalesced page (16kb) hits as percentage of all DTLB " + "L2 coalesced accesses.", d_ratio(d_hcoal, + d_hcoal + d_mcoal), "100%"), + Metric( + "dtlb_l2_coal_miss", + "DTLB L2 coalesced page (16kb) misses as percentage of all " + "DTLB L2 coalesced accesses.", + d_ratio(d_mcoal, d_hcoal + d_mcoal), "100%") + ]), + MetricGroup("dtlb_l2_2mb", [ + Metric( + "dtlb_l2_2mb_hits", + "DTLB L2 2mb page size hits as percentage of all DTLB L2 2mb " + "accesses.", d_ratio(d_h2m, d_h2m + d_m2m), "100%"), + Metric( + "dtlb_l2_2mb_miss", + "DTLB L2 2mb page size misses as percentage of all DTLB L2 " + "accesses.", d_ratio(d_m2m, d_h2m + d_m2m), "100%") + ]), + MetricGroup("dtlb_l2_1g", [ + Metric( + "dtlb_l2_1g_hits", + "DTLB L2 1gb page size hits as percentage of all DTLB L2 1gb " + "accesses.", d_ratio(d_h1g, d_h1g + d_m1g), "100%"), + Metric( + "dtlb_l2_1g_miss", + "DTLB L2 1gb page size misses as percentage of all DTLB L2 " + "1gb accesses.", d_ratio(d_m1g, d_h1g + d_m1g), "100%") + ]), + ]), + MetricGroup("dtlb_walks", [ + Metric("dtlb_walks_reqs", "DTLB page table walks per second.", + walks_r, "walks/s"), + ]), + ], description="Data TLB metrics") + + def AmdItlb(): l2h = Event("bp_l1_tlb_miss_l2_tlb_hit", "bp_l1_tlb_miss_l2_hit") l2m = Event("l2_itlb_misses") @@ -362,6 +469,7 @@ def Rapl() -> MetricGroup: all_metrics = MetricGroup("", [ AmdBr(), + AmdDtlb(), AmdItlb(), AmdHwpf(), AmdSwpf(), From patchwork Thu Feb 29 00:15:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208088 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp88655dyb; Wed, 28 Feb 2024 16:18:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWvnWtieumcQ2jyuw0MtKSzh3e+dd66V/Ky2r0Et25ahfIIW6ebyKMIIRJtdBFJi7trW2bl1z1AkpW7oOhz2aL8qakd5g== X-Google-Smtp-Source: AGHT+IE6qfJ3KWfIxXRx3aWkVysHAV4KgUTYvrAIUgREHUexMPlK9NsJtemDiL1tbOv1mvTcehux X-Received: by 2002:a05:6359:411d:b0:17b:581c:430e with SMTP id kh29-20020a056359411d00b0017b581c430emr947402rwc.3.1709165894608; Wed, 28 Feb 2024 16:18:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165894; cv=pass; d=google.com; s=arc-20160816; b=ODPxGlX16wEggv8EQC7sMMolP0HHGAubpjHYJqCR96Q2xSyCQlA1P0ntM6ZcxuQStv YiDDd/kMdR7A4AeG4c8fvL074ueMGhid7WwUDRBELRRQdsxNpDaumiEnIYfQasUMckol uS74HgpFjxz8BGtgzRAaDdApUNr3mvAMSsAFemYW55WQA2rQAwWj4jEJ3Q6igQ1vOH7s O4sYKG44prtiw2d+NsRBRXOk/QGfI9P21n63/sbuMR1G5D6Ua9/vOkuoliySs1nbZdmY JC0/zzQJ6K4TDOQOnkrOqaBX0vsB2vTzALquI5CwJ2zNoZTPJI4Y/LMXDCd3pjtURQ9t 4jxA== 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=nnw8j+u3lnjVu4UTXXzRJGFzX9SHr9I3FGbOrJjWHHs=; fh=nxVd516kcYr08l/K0rb/FzFxbrjClW+hX0JaeUyrHik=; b=W0IfuNh3w9eGKGf2jfVdKdJZ8klpObTBrICVCi2lAmtLRkZZyylbROlecfbBAuUtym Bo2NHwGFcpKo5TxUv86dg+yhyfyoBpysFCGufXgFOC+oadKNMJzL7PcmMaTEcUmTO9eW 4rCYcCMy7kI3WvFAHdMqzytzZPQsu/kZ8BlsT46mPFtzWaEFJm093CWnszvgsDvIBBro U1tVmRzC+iI22U63NcTTJSr5geLrGdgXHKIMXc0kEKm3iBlOLushWTijI7VPcJj6iTzp /qYNPqwp71bYmD45hWhFV5O9/pYmO93iN9ESJeh7NRm3OganyuVSiZ6J2tobVNqWY2vC lnhw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=CDZEwEQ+; 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-85886-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85886-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 iu2-20020ad45cc2000000b0068feee484b5si258939qvb.174.2024.02.28.16.18.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:18:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85886-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=CDZEwEQ+; 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-85886-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85886-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 632F31C216E9 for ; Thu, 29 Feb 2024 00:18:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D2FA415E9C; Thu, 29 Feb 2024 00:16:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CDZEwEQ+" 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 983977FE for ; Thu, 29 Feb 2024 00:16: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=1709165766; cv=none; b=iidDeylaOSfyxGOPUTaRThX1Xh1CqRGmCEIw0by6/K8GAY3d8sRfIu/rLoA12ay0bKHPK9sXb3XaGBPCUQxlQXkmVZTlYFIuhluAqwP/zau7MNjCDbhYJVJBkff87KQM6Oe7zcshDb0xKlth4KbGxo+WlUIVqRSo4jUr5LgLKKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165766; c=relaxed/simple; bh=xBfxlNT0aaXEMy2J3656vmd02rMeN9x8F3Ypxz5k1Kk=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=jiMuIAo1uTxBUFujuVC/pTLc1TcIZR2gZ6vC4aUlxytBbstF9iRxJouqzQdDr2q96Fvod4BFP2BxBmXPI1+BEPomAGxOJ2OpgX3O3xQ+0priExJYLPRoUNrrtg4EoBE/kOTWtoRgkLb6V/9Oz3oV4pNUe8nOLvEdZ+uSjITT75s= 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=CDZEwEQ+; 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-5efe82b835fso8215177b3.0 for ; Wed, 28 Feb 2024 16:16:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165763; x=1709770563; 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=nnw8j+u3lnjVu4UTXXzRJGFzX9SHr9I3FGbOrJjWHHs=; b=CDZEwEQ+/8KUHGuAg4i2NUa4TgorEzTxb0mPPbXV+zfjmXufeEkMvzhS4mwTg8D8M2 0qsveyes9xpOdxR/q+pbMJKl7xfCNFb4YSo12OnwKLl+1/+2FuDkxvz483rAMUPbp83q j3EgSUEKL5SaItl5mJCvoaJpxiCz9Eu47N7a2S/4FrPWiTlR9MlfWSyzcqUDC8NNPWqV 5Zh3DZ/+Mc6wGSq/TrOGzm20I+NpDMjqNLigQBXKGrdIcpRM1AZ30on/VajmTOmbK2xU fVfdi1Hx3qu1N5L8m6mJ8uOya6faknyEQNsHaw9cX8AcdjLQF2ESN3q/gl0fP+3JkYer b3zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165763; x=1709770563; 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=nnw8j+u3lnjVu4UTXXzRJGFzX9SHr9I3FGbOrJjWHHs=; b=OUIfotaXXwbprMk6BD4T4jo870n9NLJWbO6MhSuxzbOGW/aNAaRUlDmDYuLOBo4h8h hq5Xm8G58a+UiNtfxqUGvMRoQ4JHhvrzswRzITt+uxcS3f6eY89c/CC/AnY8T7RRL7tN 8hQWDopZIn1ZVpJxhVouy+EtBoaLkmM4W7niQB1yOeVsHCdMOdfCg4VrD53nS6DycC2L HDWE+otOvJnILYwC+MAgkcgDyBAtQwFml6kZln8AKjdtfKNI8R3dVU521moRjN+IMFcD BdH/kBFWIGSjaJwuAVX/xRcJIF5alge5sGB0saSp96de3hvFlzA7kCAZFh83azKK68Id 2brg== X-Forwarded-Encrypted: i=1; AJvYcCXPZeyhDwIpIpNhl+OdDgX4ScQX7mCKTonCbfuMcSsqkpG2R3NZTcTF49dCAd5rwL1XmDEnlyRvi1s55EtUiQL+6cU82UXbiBslsZQX X-Gm-Message-State: AOJu0YxY/eYfTrg4tG0KfCzQMm0ZuWg2a46Pbjpe+E4IHRYjRpGHzno7 a91mOmWfnRHGJOZbgJAUyjzzS8IqgObkTA3VCbB7LtuPoZpqFjB7lANyWmKZUL+H4wFhdahmVhJ LY1QSPA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:18c3:b0:dcd:875:4c40 with SMTP id ck3-20020a05690218c300b00dcd08754c40mr209662ybb.10.1709165763612; Wed, 28 Feb 2024 16:16:03 -0800 (PST) Date: Wed, 28 Feb 2024 16:15:33 -0800 In-Reply-To: <20240229001537.4158049-1-irogers@google.com> Message-Id: <20240229001537.4158049-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: <20240229001537.4158049-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 09/13] perf jevents: Add uncore l3 metric group for AMD From: Ian Rogers To: Sandipan Das , Ravi Bangoria , 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: 1792190336885335567 X-GMAIL-MSGID: 1792190336885335567 Metrics use the amd_l3 PMU for access/miss/hit information. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index be10acb40762..f4a4ece551ef 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -467,6 +467,23 @@ def Rapl() -> MetricGroup: return MetricGroup("cpu_power", metrics, description="Processor socket power consumption estimates") +def UncoreL3(): + acc = Event("l3_lookup_state.all_coherent_accesses_to_l3", + "l3_lookup_state.all_l3_req_typs") + miss = Event("l3_lookup_state.l3_miss", + "l3_comb_clstr_state.request_miss") + acc = max(acc, miss) + hits = acc - miss + + return MetricGroup("l3", [ + Metric("l3_accesses", "L3 victim cache accesses", + d_ratio(acc, interval_sec), "accesses/sec"), + Metric("l3_hits", "L3 victim cache hit rate", d_ratio(hits, acc), "100%"), + Metric("l3_miss", "L3 victim cache miss rate", d_ratio(miss, acc), + "100%"), + ], description="L3 cache breakdown per CCX") + + all_metrics = MetricGroup("", [ AmdBr(), AmdDtlb(), @@ -476,6 +493,7 @@ all_metrics = MetricGroup("", [ AmdUpc(), Idle(), Rapl(), + UncoreL3(), ]) if args.metricgroups: From patchwork Thu Feb 29 00:15:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208089 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp88791dyb; Wed, 28 Feb 2024 16:18:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+RDMHg7VbfvFHL0qTdcfzyLFs4ND54Kc9F9tP8yWcbJp9GtX67LOVrDbgexDXwPm0ZmqOrfQyggVYPFcOUEZZEjt/jQ== X-Google-Smtp-Source: AGHT+IEztoX0OlcU7Jkl7XrAcfANozQUCWyCl/qS2NWZakp5v6H0OqKB6DU2r4D03ltcwcVhM9Yx X-Received: by 2002:a05:6402:5245:b0:566:4a85:ceb7 with SMTP id t5-20020a056402524500b005664a85ceb7mr378224edd.28.1709165913155; Wed, 28 Feb 2024 16:18:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165913; cv=pass; d=google.com; s=arc-20160816; b=0m4qS7gfkyxrtlJMssOy4oM5YAJ7xPshU87Orl3TAAc0CdoGwIETmazpJel2+No2oG iNVW6QHKcxQ5GSW2t7emki0GepPOVsA2DXuAWZnOciP65RuXbC0WE7DpeN6BJnVC9Wti kN8OpMijxQxq5IjFThR/Ej90dh/n9JwyCvkZMT0fh5pmzRXvWfoB+PmuMrqSyBG2v/2E ML+0TFqIeScuVRWXHxO2nXpWRXXcl5/EIbGO80jbt80JtC4CS6nErDsoONRBlztIBSg5 mVwbG9ber1WK0f9wSs2iGWeqm10TZYaoAgRZ42jjC3qv958yCyZx++u3/RgKjbtUbSZZ 8DVg== 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=riQkIrg8TOM4HvcpMUBBinltQ/7KCgNPQM/xCcL0170=; fh=kBRrC6ePgSDp01LH3f4u4oypd38gn0gU+/wDnRub+w8=; b=dBpbKHj89o4LuFdljKeCLdCeX9jt6d7x5VDfAmM/0v7+FtavpixQh6aOPhJRBrZ8h9 oNHCDFahAuYdYn5wcFKxyy06Zv/euN0BGlDyZp2gq7H0+7fWu7ekYMbdxzJtOH3oS+bS HtlcHy78v2ufZwoMq7/fvlHPYnI2+7obowdQjfVmbP37/hrZNG/XXT9OZQ29EqyBFC8/ GqQCZKRLNNZn4mBJD52hbmw1Tn7zCSkxbxP9OUtHoYQbQBezyQgpz3i8JamTIrRwpWlP /sZupjZeuQ5uV25ZlcVQrPJ99eQrSQ3eTDdbRMlN+N8d7HqKxa3WDVQm5hPI+JXuxVhd jf7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hRywBCjv; 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-85887-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85887-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 h19-20020aa7c613000000b005669d6bdb92si51997edq.397.2024.02.28.16.18.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:18:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85887-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=hRywBCjv; 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-85887-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85887-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 8863F1F212AC for ; Thu, 29 Feb 2024 00:18:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0698556B81; Thu, 29 Feb 2024 00:16:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hRywBCjv" 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 077B254FA0 for ; Thu, 29 Feb 2024 00:16:06 +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=1709165768; cv=none; b=IQaCx6L7P4B7vkdpDNQJDNQTBMYjPjyF5qCJYHEJCEwz3gmxv344Q40V22GkY+pgK6IJwXelllP4oJE1DsJ0w8uBlSLC+ql12/Z9D8C5jQHuKyFAN8Acw4iNf7/0c9fSxuOMv7TDxxBgaR9IJ1kl7oKdv0KhlAM30a8rLZXiSe8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165768; c=relaxed/simple; bh=D/pwwQ6dXV1q6dCmwwHAP89kxtCQNH4Hvs09U28fH3I=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Q1jvF69/JQ42jGiayRuGg/dK9cAfv+9ptIU7uDpZUJsaM0le1lwvIfR8cUR+kzX+0S6F/qsQJ6Xp5in5EikqlObWPrSjbNJrhN5Bi/M2LBd2tCmtOFPbOp/doyIidcvhk6YYnM2QXFWX0e8TlafAQ55Tv+2ySXgtYswULIfhbMY= 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=hRywBCjv; 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-dc64b659a9cso695632276.3 for ; Wed, 28 Feb 2024 16:16:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165766; x=1709770566; 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=riQkIrg8TOM4HvcpMUBBinltQ/7KCgNPQM/xCcL0170=; b=hRywBCjvzfJZQOkn13J2PPQ2wZr8CbjfKRuR27Xw0UmfDORncBjZyHz9+f2frDNmJ6 mOFj8fmQXzCiOqAnTytXUq6ALHqALr2TaaSkmZAeGJY2MQP4KeYO7ie/b5MQ9rq5pCBv L5yXbv27K7YcrEOV6+ZlUuV5UOTcIZGG8wMAHW858OMrIh4T84YeoMN0vLkGPLe4iHdw flpm0cdTst7Qc7ruI5sH2GnFis/vSMDasXeCSLGE5f4y7N+mex1/hIm4D1fDt5IYfg7L 7lOoXvQH6sjOw7ksqTY0OdETl925SKVRyZjN8zqj7eiMGcPGijsCjaLTfiya5AUwuYIS tTXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165766; x=1709770566; 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=riQkIrg8TOM4HvcpMUBBinltQ/7KCgNPQM/xCcL0170=; b=QOCuu9NAEOb2LZiIqYgNhKbFB4y8T3OjsI19g1Y0Sf16jsWTTlyJARaGtoQAJQ6QPy G8usP6RKsmtrgoMvuKrMy+TSfEMeW86gNRM2Kah5M99A9f26UCQ0L6g5rLQDKQchs8Ut Q568FfBDzAkONiIsfvEiG/CXr6mWuYNdTqBFuRcwGHCIrU4zSAbm3QQoiGMzRONh/Z/w jU5IApyaz7ur33lO/n4UNKBNfrXzGCpU88LJNQAU/Kl5Ju5+bAQivLo+LSYbsxBoXTfl 2jHOdjRUTszrrOuWah6ZyWdwcUOVjyCw164x4mLHo3YAk2CFoGSScjt8891MeJAhR9Ix HJLg== X-Forwarded-Encrypted: i=1; AJvYcCXrV7IZo5O134r1NwIk3nmLiDSxg3sFUVtLBhZfyuI/c2j41hnKaoXH4NwqjeNPFIaynCyNfFDhGhV7f7c+Z2m5HtlOp62TBbdBfuJ3 X-Gm-Message-State: AOJu0YxKbNZTG3rr/rR13g9pyyroBy+4p2+iTWpHFzYM3MevtRqk4f4R ppvpJoJzrYgZ5wkTth2ViV7bJNjwMJJk0TBN+mNsp1vIlynkJqqXEGAw5ZA7Ds3+E7NSzEh0MUt 5ltb6lw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a25:abc5:0:b0:dc6:eea0:1578 with SMTP id v63-20020a25abc5000000b00dc6eea01578mr195854ybi.13.1709165766077; Wed, 28 Feb 2024 16:16:06 -0800 (PST) Date: Wed, 28 Feb 2024 16:15:34 -0800 In-Reply-To: <20240229001537.4158049-1-irogers@google.com> Message-Id: <20240229001537.4158049-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: <20240229001537.4158049-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 10/13] perf jevents: Add load store breakdown metrics ldst for AMD From: Ian Rogers To: Sandipan Das , Ravi Bangoria , 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: 1792190356632930689 X-GMAIL-MSGID: 1792190356632930689 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/amd_metrics.py | 75 ++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index f4a4ece551ef..6b182a9bbfe5 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -278,6 +278,80 @@ def AmdItlb(): ], description="Instruction TLB breakdown") +def AmdLdSt() -> MetricGroup: + ldst_ld = Event("ls_dispatch.ld_dispatch") + ldst_st = Event("ls_dispatch.store_dispatch") + ldst_ldc1 = Event(f"{ldst_ld}/cmask=1/") + ldst_stc1 = Event(f"{ldst_st}/cmask=1/") + ldst_ldc2 = Event(f"{ldst_ld}/cmask=2/") + ldst_stc2 = Event(f"{ldst_st}/cmask=2/") + ldst_ldc3 = Event(f"{ldst_ld}/cmask=3/") + ldst_stc3 = Event(f"{ldst_st}/cmask=3/") + ldst_cyc = Event("ls_not_halted_cyc") + + ld_rate = d_ratio(ldst_ld, interval_sec) + st_rate = d_ratio(ldst_st, interval_sec) + + ld_v1 = max(ldst_ldc1 - ldst_ldc2, 0) + ld_v2 = max(ldst_ldc2 - ldst_ldc3, 0) + ld_v3 = ldst_ldc3 + + st_v1 = max(ldst_stc1 - ldst_stc2, 0) + st_v2 = max(ldst_stc2 - ldst_stc3, 0) + st_v3 = ldst_stc3 + + return MetricGroup("ldst", [ + MetricGroup("ldst_total", [ + Metric("ldst_total_ld", "Number of loads dispatched per second.", + ld_rate, "insns/sec"), + Metric("ldst_total_st", "Number of stores dispatched per second.", + st_rate, "insns/sec"), + ]), + MetricGroup("ldst_percent_insn", [ + Metric("ldst_percent_insn_ld", + "Load instructions as a percentage of all instructions.", + d_ratio(ldst_ld, ins), "100%"), + Metric("ldst_percent_insn_st", + "Store instructions as a percentage of all instructions.", + d_ratio(ldst_st, ins), "100%"), + ]), + MetricGroup("ldst_ret_loads_per_cycle", [ + Metric( + "ldst_ret_loads_per_cycle_1", + "Load instructions retiring in 1 cycle as a percentage of all " + "unhalted cycles.", d_ratio(ld_v1, ldst_cyc), "100%"), + Metric( + "ldst_ret_loads_per_cycle_2", + "Load instructions retiring in 2 cycles as a percentage of all " + "unhalted cycles.", d_ratio(ld_v2, ldst_cyc), "100%"), + Metric( + "ldst_ret_loads_per_cycle_3", + "Load instructions retiring in 3 or more cycles as a percentage" + "of all unhalted cycles.", d_ratio(ld_v3, ldst_cyc), "100%"), + ]), + MetricGroup("ldst_ret_stores_per_cycle", [ + Metric( + "ldst_ret_stores_per_cycle_1", + "Store instructions retiring in 1 cycle as a percentage of all " + "unhalted cycles.", d_ratio(st_v1, ldst_cyc), "100%"), + Metric( + "ldst_ret_stores_per_cycle_2", + "Store instructions retiring in 2 cycles as a percentage of all " + "unhalted cycles.", d_ratio(st_v2, ldst_cyc), "100%"), + Metric( + "ldst_ret_stores_per_cycle_3", + "Store instructions retiring in 3 or more cycles as a percentage" + "of all unhalted cycles.", d_ratio(st_v3, ldst_cyc), "100%"), + ]), + MetricGroup("ldst_insn_bt", [ + Metric("ldst_insn_bt_ld", "Number of instructions between loads.", + d_ratio(ins, ldst_ld), "insns"), + Metric("ldst_insn_bt_st", "Number of instructions between stores.", + d_ratio(ins, ldst_st), "insns"), + ]) + ], description="Breakdown of load/store instructions") + + def AmdHwpf(): """Returns a MetricGroup representing AMD hardware prefetch metrics.""" if zen_model <= 1: @@ -488,6 +562,7 @@ all_metrics = MetricGroup("", [ AmdBr(), AmdDtlb(), AmdItlb(), + AmdLdSt(), AmdHwpf(), AmdSwpf(), AmdUpc(), From patchwork Thu Feb 29 00:15:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208090 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp88852dyb; Wed, 28 Feb 2024 16:18:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW4rSgZi5IGj9jTAHXx9Sk8KGWNx2bSFKXybrG4cm5qUzqkkM8Dh2UPrslOugOHFYOQJgHwh6vYpPL+4vsV9oz3a/l54g== X-Google-Smtp-Source: AGHT+IHqpn9MQV0TDvIITwBKUmXc/2JqHUGNOdd2VSXyunp/0568Tquclyrb2j6PQHcWMcZVeJ4+ X-Received: by 2002:a05:6214:aab:b0:690:1e55:6df7 with SMTP id ew11-20020a0562140aab00b006901e556df7mr669691qvb.25.1709165923904; Wed, 28 Feb 2024 16:18:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165923; cv=pass; d=google.com; s=arc-20160816; b=Bj7u0ze5nBJmzaYJcw1zlnw54q6KXZsDEhp0WzU/NsEGi9ifR9hZZpAn3kA7xL0mCQ h/Yetp9Rcs5wZYvukXqZdWF/PyyNJrgPJIAHql/0vucFPb7udHuEwuNuATHjaFaXpRNP WX6QGVoO9xBP48caK7Oq93vkE5q/q8NSE7PvYyAFTJM44xaz1PgT8E0lgeDZodHDH3+M 7ZTi0xEVE3/qmikIFPFBjcCJDK/Km4xN/ptp+2xS2MeRUEBRlhFmCtB3IGwzx3xLt4ni +crR+phfXIpgK0gZ/ojPtwYh5s7QXhgrj9iFJk1Aa2KbTCzvBlhUoaB2Mdwz04FbExkz 9itA== 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=cHahQF2BiK1eIw2Re/KcTjpVIHmS0xMmp3oAqD999cA=; fh=DhxRhR228jOED760NErR45691AOXo1z8E8IYLzczCPw=; b=h3bUfInK0re0Z9rtuIMb8x+TvkI0c0zTru6XJ0nrZ2IwNFXwj8s/Nwqafm2j0yBitj JGAsQNkKCtgymBl2T4guSphkiFjxffXuk3KjZzffHggRW5mspg4+q3O/zqI1NrbRcq6d 5BOG55IvwbCHBFnIvpW8UDaBk5mcCJ5ZlSXo9IkZQEkUOzFkzAgPb4VKWtUruoHwGJLA t4fSzpF1BMRcN+1Iva9I7A7slDOSS0Twp8+i/5q8GsBBjTM4s86SGtJSt0BBZl/u8V1S icJmNaeKZJe39Xgjv9w/HrJ+CqTWe9VNluCXm71XcJVhfLGLdBwkLeZw88+uRDm54Epz x+nA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=evhdKGJQ; 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-85888-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85888-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 12-20020a05621420ec00b00690191023c1si238433qvk.561.2024.02.28.16.18.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:18:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85888-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=evhdKGJQ; 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-85888-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85888-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 B06D71C21833 for ; Thu, 29 Feb 2024 00:18:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1242459148; Thu, 29 Feb 2024 00:16:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="evhdKGJQ" 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 412FC56B6D for ; Thu, 29 Feb 2024 00:16:09 +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=1709165770; cv=none; b=c+UNjg/f1LOdMnePDFpb4NyTeq2UztE6ibpvDeUKxyMatpjtjV6Qhd47Tps3hkngkLd5YcBxq1qr+bSR/TAxSP2/21RmFAJHToEozR1na9Y0APYzk2B94+Hb1zvNb9f66+pZSCdOB7Skf7CoEsO6kUvS5UO++l517zkVGYJ0H7A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165770; c=relaxed/simple; bh=rdT/e0Jk04uz/hli1au/7w9zNoOK9Gsygo85Wow1ix4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Z3YYF4IswhA/cdh2Uh27vt/PhjCF4Buti6Gmm26c6MyQo21lH9G/6/sFfn/SyTNjVJBW/6q/dhiGxfhsVz+kZCeg3w3wVPOrWBQA+M0e6tx0QchOcTQ8xjJng+YOUXCy0x2ujfo2H6a2XaI+G1bbsmE8zYD8l20feaKzNBDOs1E= 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=evhdKGJQ; 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-60957e0b914so6068667b3.0 for ; Wed, 28 Feb 2024 16:16:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165768; x=1709770568; 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=cHahQF2BiK1eIw2Re/KcTjpVIHmS0xMmp3oAqD999cA=; b=evhdKGJQU2b/oZ/NAsFgZvxh0AxV5W85oves5f90jukk/PFjqkBIrTxVeG6UJ2XB+g nKsO7IVHIa32CZS9+y25N/SXDYIQkJfd/ZWdISUvJnJwu/r9usdwbKgepMG6ocWythzi EHwA7W5n30THvvCxxihJMHKDq1Az8aL8yoyscFjl34fzNVVH3122aJijbg6yPDdBnLaq YvAaz5EwR2Auh6eNn745Bzxs9J8UQ2aXtajLVnqZlZQvzNV1pmk+88Q+u66u9RUgBOhC aHOQ0GiHuiGDzKP/ENaXjhIMZ3n4Rfu3WuIXpfdLCq1AGxZz7Lz+rXxSptSgHqifQBf9 yHBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165768; x=1709770568; 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=cHahQF2BiK1eIw2Re/KcTjpVIHmS0xMmp3oAqD999cA=; b=tXsL/gHs0kF5XVelwfGfuhnsTOGL4jQ7absUAc3cBHzjCzJWVGIt9LyD+/bBWGAsZg oJuB05+HJkxYXRsVYeEJSSoStTrX+5EDBO4lipDfvKI8O6IX8HOnkn0vgVpjiwiqU/yy q1vIdSISrNwO3g6KAk+NmP1OzT/vw43GpO32SAYYwy50FLYy42usmFyoe4aCpmvXJTjZ 4oXRRUpc+l4K5oXJRLkQt4NUHtzVsX6Jsop5M/8EarhMSKXaypy1Y5eNA0EhNvE102No hD5csXCiGv77xaOTaZAvAtxD86O0pGfmMfDjCGptZlwWxHSY0sXClKYlh+cxemM7CHJh WkmQ== X-Forwarded-Encrypted: i=1; AJvYcCUxMYKWWW56pDAfhOjT24RatDowyiC1S8AZETASnAk5L9D2kJKKOe9rYTO/FN8MPaCZLQiCm2RoOe/HedOFBzl7IjpMJSn08T3UZo3z X-Gm-Message-State: AOJu0YxHmwppv2k5OphHCV/Ly64/1+hz9GHm4WLBp9u+a5ZAnkHYDaf/ 2X10xL/JjUAVaQq/gIgDxR47xnkXfvvoK7zDlGreclUUi6LZK837kmtZK143DPgXog133TlydBM b/000pw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:690c:c1e:b0:609:4c74:5cab with SMTP id cl30-20020a05690c0c1e00b006094c745cabmr139123ywb.2.1709165768568; Wed, 28 Feb 2024 16:16:08 -0800 (PST) Date: Wed, 28 Feb 2024 16:15:35 -0800 In-Reply-To: <20240229001537.4158049-1-irogers@google.com> Message-Id: <20240229001537.4158049-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: <20240229001537.4158049-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 11/13] perf jevents: Add ILP metrics for AMD From: Ian Rogers To: Sandipan Das , Ravi Bangoria , 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: 1792190368144618547 X-GMAIL-MSGID: 1792190368144618547 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/amd_metrics.py | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index 6b182a9bbfe5..91f323c1a149 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -125,6 +125,35 @@ def AmdBr(): description="breakdown of retired branch instructions") +def AmdIlp() -> MetricGroup: + tsc = Event("msr/tsc/") + c0 = Event("msr/mperf/") + low = tsc - c0 + inst_ret = Event("ex_ret_instr") + 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), cycles) for x in range(0, 4)] + ilp.append(d_ratio(inst_ret_c[4], 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 AmdDtlb() -> Optional[MetricGroup]: if zen_model >= 4: return None @@ -560,6 +589,7 @@ def UncoreL3(): all_metrics = MetricGroup("", [ AmdBr(), + AmdIlp(), AmdDtlb(), AmdItlb(), AmdLdSt(), From patchwork Thu Feb 29 00:15:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208091 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp89062dyb; Wed, 28 Feb 2024 16:19:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWVixv4TMBEmBWW4JNlUqkFC0x6cRVQkzMtJa+MiXpI9yZw7JFo5gfVD32mLuG7UnxpBv6OWUWr/ZAvGr5pDXRWSMXqpA== X-Google-Smtp-Source: AGHT+IFh1pTDmVWiKt4ux1Mrq+oxnAQxPly3K1yFv2lcyFx9czlxqNH8ahdLIX1r/Ha10ugr/pyW X-Received: by 2002:a17:903:2350:b0:1dc:66da:d21a with SMTP id c16-20020a170903235000b001dc66dad21amr553853plh.28.1709165957243; Wed, 28 Feb 2024 16:19:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165957; cv=pass; d=google.com; s=arc-20160816; b=Dz6RiBrP2gP1Fq6smz0kf9n+oJgw87DUYnW6PKbN+LZ2vbr0sY5zgTpVMErUlDWLig EYuSEuzRWRJEhUEimu4T9TUbLoc2wOCT166EttsKVDhktwY8TjYR8srkStrkU856Q4Rx YahYFJpXULeSB2DDeug0V/DvXH08XcS67UiQC8FzsHdzr+2wMEZRwbOFxye5Bh8VIkmT uldsZc0JYvLa/jX36jDxL+iG1hObd9u8GdpI+zoEjzDdZ5SO+3HA4jFZHzdvgQ7JkJcL 4qv8NN63LrVH6o/ujebRRcmn7c2H6VVx59bdb32wAi71bf6BcpjpoXNMQuPNHpIeEDlE f+HA== 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=rDmb+1G4FeL2VOjrPNtrbYg/sNUzgE2lO0wYF9ntEME=; fh=9JFLhk5TWj+zf26RIZuAduwNsozD3c0R/TYAVyv9FKk=; b=Y4VhHQTxhF6sAMx3LEricN5+4Lg/M2xmHXb9cuIIvqMunlUPqJ1G6DdUSV4obvgxb8 5p7KSjlRCXHeinU1Z9Cka/f65pWOH6TD5W4sbSdquXuwOO1nCBdq1TPMyKFCqWKD7V+I Y4GNSPxkHVxi11hTPx9hT6Trp460Q4RrY6Aj/Llu6WkpSw31L6pcMQ1gxTFOetfBZ5aP 9alnd5kI64oJC+SUv9+AfzZAJEFIBLc1LkUDTVOPHHSxP3+xlK0a1sM9wVpFbgtOX1yU fgq6/w6w1UdhHpcqzyU6kXad081FiCqzUxQiCa5aLmETQMV4SgDdpyaojREBnezL7s9D mfSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SgHzwcdz; 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-85889-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85889-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p14-20020a170902ebce00b001dcabe7a18fsi117253plg.126.2024.02.28.16.19.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:19:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85889-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SgHzwcdz; 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-85889-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85889-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 89944288D52 for ; Thu, 29 Feb 2024 00:18:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B0DE5A0F2; Thu, 29 Feb 2024 00:16:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SgHzwcdz" 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 C068B5731F for ; Thu, 29 Feb 2024 00:16:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165773; cv=none; b=APEaKQB07PPvDEFnWvcxh+owu8QZIDIKDqBm0ea4Apjwv4EBZ5zbos0+TslTlGPN5QeoOGL7GGxSItKpg0xtLuPvNPIpgtQlW0v5MyMR0IZWxeTdPIbUayCm9QC1dqifGZKPZ9pvb+PkiiG3AYbcTYIYoBThTxowBaGQN/VPAD8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165773; c=relaxed/simple; bh=UwkjYK+U+f8LwVeVeyTQSJU60/nxqzY/uXtXOkioAuY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=k3h9OYmYGTaORV9cxg9PINf3tSRPzzozgS5WN9f1JmFFhoa1cHWx5pxwqs/NxJ2F/STO2NACpsE/A9RWqK586J4h3UP2Wza0KMFdYi8QYe7U5u0Ez8yTYLUbMvEBqg9nVWupfP5WGtHvOj+tRAc2Q4f2sC2/YUfd+5j4M2Rcqxc= 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=SgHzwcdz; 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-608e88ca078so6106957b3.1 for ; Wed, 28 Feb 2024 16:16:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165771; x=1709770571; 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=rDmb+1G4FeL2VOjrPNtrbYg/sNUzgE2lO0wYF9ntEME=; b=SgHzwcdzxtbE3LV6tT49xoXoF0G1I3qHqCSHLstVUpKDA+rPt4ij6Co35vmgEqJ3Es pWuAv0zcTZza77OUKteWVcOhmzba/T2EquJ5uwWJZYVt+oZWmPBGWYQW8YnNAqMfS55M a5+xtLy1f5yT5wBXbPFcqbL7/N5o4KfyOpfQ7fcpvDoG207nZvptqPD8ByhfMcGtcdX5 nizVyuRg8Bo+lhNRTo8s1H7AeWjDEomblTGatvnhM8yJoQqh2hgBtZJTgLXeflXkN3ch GsUX2JoBM/7CupIf/ua8sTt4tenamFTHQwHKPlEhxYPsqhaNGyFUofIeBF/JJGFdqWnf wcPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165771; x=1709770571; 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=rDmb+1G4FeL2VOjrPNtrbYg/sNUzgE2lO0wYF9ntEME=; b=bZ3DVD46aHhaWiFIdH0DSYd4M86Ifjx+w68JgdqMuMXi53cuDUXOcz5c15P1iLlNkT jZUPgbqYnjszINkou3x/GBABlMuLvssKwZdaAN7RHoW3l67rMQ/cFvHxYU2sXrXM23Fk Nyx5KLB6B4nhoNq2zCIx3zXZ2HME1hsths9p4R6eIFOsyRBec3rWAE8tgv9hYIcvbdhg LJ2XrO8YjvzIaUjtgUxfUC7fyrkvFLX+eMWZWvk866Zez0RAAcUDPbJYPgA3eNd7Utoc t1g5FRHXrsQicJboAK0nBdNHXkKR3aBQb69vk0ElnwH1M1WnJ0pDCDpnxKHe2TpAJheN Pkjg== X-Forwarded-Encrypted: i=1; AJvYcCVnyx/r4s97lyYpxJFnJLcAoPqTk30dJm7OyarxsWUmRy/jlCBmh0sfKIHQpV6deAnbJPMR//QG0I0dlRtKgV5xv9qM1L5I/vXtmifI X-Gm-Message-State: AOJu0YwzN2NwFzDkYa2L7V+4sgtTMsmGB6ikK4HJr2mhACeLZf4ntA3D 5mEm8A7kvHLhOR4IBYWEtKx5VF5ru2bIKFC2o2lomjhmgPK5kufzl493pKaGsZW9TJ6h3K2U5yA f6GllPA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:1c9:b0:dc6:cafd:dce5 with SMTP id u9-20020a05690201c900b00dc6cafddce5mr209364ybh.12.1709165770873; Wed, 28 Feb 2024 16:16:10 -0800 (PST) Date: Wed, 28 Feb 2024 16:15:36 -0800 In-Reply-To: <20240229001537.4158049-1-irogers@google.com> Message-Id: <20240229001537.4158049-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: <20240229001537.4158049-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 12/13] perf jevents: Add context switch metrics for AMD From: Ian Rogers To: Sandipan Das , Ravi Bangoria , 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: 1792190402965782129 X-GMAIL-MSGID: 1792190402965782129 Metrics break down context switches for different kinds of instruction. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index 91f323c1a149..377ce413d051 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -125,6 +125,37 @@ def AmdBr(): description="breakdown of retired branch instructions") +def AmdCtxSw() -> 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")) + + ev = Event("ls_dispatch.ld_dispatch") + metrics.append(Metric("cs_loads", "Loads per context switch", + d_ratio(ev, cs), "loads/cs")) + + ev = Event("ls_dispatch.store_dispatch") + metrics.append(Metric("cs_stores", "Stores per context switch", + d_ratio(ev, cs), "stores/cs")) + + ev = Event("ex_ret_brn_tkn") + metrics.append(Metric("cs_br_taken", "Branches taken per context switch", + d_ratio(ev, cs), "br_taken/cs")) + + return MetricGroup("cs", metrics, + description = ("Number of context switches per second, instructions " + "retired & core cycles between context switches")) + + def AmdIlp() -> MetricGroup: tsc = Event("msr/tsc/") c0 = Event("msr/mperf/") @@ -589,6 +620,7 @@ def UncoreL3(): all_metrics = MetricGroup("", [ AmdBr(), + AmdCtxSw(), AmdIlp(), AmdDtlb(), AmdItlb(), From patchwork Thu Feb 29 00:15:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208092 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp89226dyb; Wed, 28 Feb 2024 16:19:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVZQqdT70e2w/KKWPYSkaNkOPHIGNf4VAnXEzyAjzvrFsdGphv6/oD9PGVGnp9RaTyY0eJqw6adUSBmSx+Wl1RzO/NXIg== X-Google-Smtp-Source: AGHT+IGeXV09VadgA2/KD9AvA2uk9SlIWpjVw4fYMsuccX9xlPrQ/h+xIDUQ8HUNYLJpPDQ6kW2I X-Received: by 2002:a17:90a:fc94:b0:299:d17:a558 with SMTP id ci20-20020a17090afc9400b002990d17a558mr772066pjb.21.1709165982444; Wed, 28 Feb 2024 16:19:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165982; cv=pass; d=google.com; s=arc-20160816; b=m/jFU7xShrwZcKMgHbbMMB+IbMg4O4WR0+YZWAKJHirSuDGp1PcsdWHHgEwCbdnsJt 31iKcuygHC7/mZNk5O3Tof7iH49owDKtwy6Nvs4wAgO1d6SNJwXoa97DLhkLDPNajvmq VLwfRu7hsH1+2K2ctzvuExu40rIhGW2LPVd4YVEnyopV9HtanMNCFE5xuvMyt604qo+j a3bP3W0z2zfYSRtWU6SCzJFiLcbQePirxaHt5zYyeRerZVHXnXAum8V3rmVo2UCAnJnr /XT1B+SlXhKKfVyvnGJ3xzLWMjlaDCGU8UxcfsDU900WAlKvuljAIVgMG39tFz2rAeE9 1Pag== 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=1AfLiGExWQ7LJtXjB9I1zr2EY79Wd3x7GNxPRkAZ0FM=; fh=na3yS1F+mAXNreYMzaEexG2B8cj1IGBeTP5u3sNaqLY=; b=Kbo/rHPNkObVBQGdH/5jdl2txr6+FcjVAwGQxTdeIiGneZE25fG7HlzFHZG+x/Mcn3 WOeBN0qjXZJ9/3YGZceilLg0s52nTRT0mSrPxzv66nRwrpOfZH0X5vZnIF/hzKSYT1ZN Yn6lHSvtwTMk5JTswH7oqk0VGI6UB10lXBZI4Nr+7+bAMrlm6lRu3KsDeIEiPPtxoxOe 7ZgCtl8Iyz61aCYISQN48kYYyLAEDjBnkt6QyhsSx1I24K7huulT7XA6FPi4Gz2X+8fM Gl0Uq6ls1beFFS1jqK+rZUfkwEQu1sj3lPl6P/SsSSDHg1zxEvTzvDgNHm5YdVR+A0Mm snpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=CP2Sa1r7; 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-85890-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85890-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 mh15-20020a17090b4acf00b0029af3b2b337si293860pjb.140.2024.02.28.16.19.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:19:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85890-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=CP2Sa1r7; 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-85890-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85890-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 39DBFB222E9 for ; Thu, 29 Feb 2024 00:19:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 448EF1DFF8; Thu, 29 Feb 2024 00:16:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CP2Sa1r7" 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 0989D57334 for ; Thu, 29 Feb 2024 00:16:14 +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=1709165775; cv=none; b=sMS+EJTtHbX5lENdZvlEkHgDkka10rWpFIIfq+xjnqxUlXzn4fKHaGCs+lbh+YZjQu8BCEAYvCUdRU2kPJ5drQtdIYoXdxWP5oYuMHQrPmy69LqzxdYHa2jYyevoDIcVwNvbcQlJf3PjPZ1PExG7tqWNSeKvfnDqWWhCjrWkUco= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165775; c=relaxed/simple; bh=Ws6o7/tvtsGwdgLcPgbopHYfQtUw+y5EJAHJUjeoJ3s=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=UepjpZEZ92XPMSiu3WkiCISziQOg3XquYp5xlJ12fGnpLFJIkkQHquX9tiq6IqlRheyHi5t+rr9V9U7seKZ1MqPlCD0ZiehMX2RYxWQlwyv5JBw4Aw2mhYRWSoN5JvMuuojQ2F8xZCNo0G2/QGb4DQLm5b/+zbsBu5Nw9j8nOu4= 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=CP2Sa1r7; 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-6047fed0132so5918517b3.1 for ; Wed, 28 Feb 2024 16:16:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165773; x=1709770573; 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=1AfLiGExWQ7LJtXjB9I1zr2EY79Wd3x7GNxPRkAZ0FM=; b=CP2Sa1r7lcFvXFJMyTk5Kw9+CFf19L0mh/gqK6+9aMM1xmTrj0cUXPR5Baz0d5Jmhc wVC+2LSYJZLKrdGehyKMhEaJnrFd3LmMIAZxRo+PGysxq+qR65nZsb8EpVsMnYwyCVTE YRy8fw79PWP8mfNzHNU1ispsc4mUFvw37ZWr+txh8GEbqX5uZBGSCMhuUa+3rmNu00bZ qyU8tvGNI8PlxhrQ2WDQ+1BKubH8wC0HGzizyO0Qg1fFucvF+sCulRNFwApewE0jl6wP +fFfWnFj706TPbidsdVEI4MT13CW+snNPT+eWocu2qkCTAm4VeqSQnS+ryEbpTwk7Ax9 l0DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165773; x=1709770573; 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=1AfLiGExWQ7LJtXjB9I1zr2EY79Wd3x7GNxPRkAZ0FM=; b=BcSa7FhTwamtvwgJpgI2w6T3nfzp6rwSskmgnZJTcydDc4NtxFxSZhWVSaBgvdZShx sJ25Qp9xr6VLDL68+4HG7NiUuev7IRVRs5eS47CHGLr7N1Kk2uimbQsHyHHrcjCcEcfD AJTshb/Dzg2dv0lJqLqtc0CU6/SLyeqauvEqjZl8ctWKgDwh8OGz5pdTt/PanZUMAjmG UXhuheNAAmYwBRI0Zo1AKzwQpg9mr7J0+3uYHtkor084rdgqGsls5alcM+CpqlQ0MzWO U/gjvQKe+Bh4f2/dbEzR2ltjJiO8Yp76lq5vCVnMilhwEmKzwufbbxhqCF7GGKru83/C K1eg== X-Forwarded-Encrypted: i=1; AJvYcCX6t8GszXRio441zZc8End3XeZkNiZqm4hlTiaWdRY5Jx5bVn/EhtENxWhJ2UflRSKDY2mXzR7ixdydFscB/aVkswmNZcrjt3Cq8yil X-Gm-Message-State: AOJu0Yz+rv77pyoS5K6x4xWABhskyI4xlp19RtAaKjUVF/Qpg9dYEU5W zlU3bQ+X55MvetDJXd4OROfejX27Hq42M6WDPTl8k/lJN6xhWyEe28BYfN+38qbWWLMNI/oP1Rc jfTiR0A== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a81:9acc:0:b0:608:398c:33bf with SMTP id r195-20020a819acc000000b00608398c33bfmr135323ywg.8.1709165773285; Wed, 28 Feb 2024 16:16:13 -0800 (PST) Date: Wed, 28 Feb 2024 16:15:37 -0800 In-Reply-To: <20240229001537.4158049-1-irogers@google.com> Message-Id: <20240229001537.4158049-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: <20240229001537.4158049-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 13/13] perf jevents: Add cycles breakdown metric for AMD From: Ian Rogers To: Sandipan Das , Ravi Bangoria , 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: 1792190429040788576 X-GMAIL-MSGID: 1792190429040788576 Breakdown cycles to user, kernel and guest. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index 377ce413d051..2def2adf232e 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -572,6 +572,24 @@ def AmdUpc() -> Metric: return Metric("upc", "Micro-ops retired per core cycle (higher is better)", upc, "uops/cycle") + +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/") @@ -628,6 +646,7 @@ all_metrics = MetricGroup("", [ AmdHwpf(), AmdSwpf(), AmdUpc(), + Cycles(), Idle(), Rapl(), UncoreL3(),