From patchwork Fri Mar 1 18:47: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: 209015 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp82713dyc; Fri, 1 Mar 2024 10:48:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUM84SA3KpHWc3yGn8PWNHF823+JdGQ5BavYHsDLfV0LDwt9Srr3B3AHV7623/LHmctm3qXNkizRvj6yXTSZxmMHWyJZw== X-Google-Smtp-Source: AGHT+IHkbfJTAp3fZjvmd4wahKAFBP5bCIYNOmfnOtLieT8mLtPXaSNFBvXUdxl02R1+iLb2FMGx X-Received: by 2002:a05:6a00:63c7:b0:6e5:d2e4:bc72 with SMTP id gi7-20020a056a0063c700b006e5d2e4bc72mr1290145pfb.8.1709318897882; Fri, 01 Mar 2024 10:48:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709318897; cv=pass; d=google.com; s=arc-20160816; b=uxYsE7BIX7N7chS2gA5VmSwLdL10QtLsubkjpPhqqpJl85cuSOtw/Hp6wCrhSd1oCq iWPeioy9v4aoJA7cXa139dOPaXtKURMrWmgTOvVmh+kn44fUjyr8PQsQpq79m5ASna1C tCjJdyRhHCTV383frxbB85nBj+091pvRJYd0mgP8gJEtZMf5byQ2hSM5V9MGNqFyULkz VCxw7PJBb0I/zF8FY2AEcMHlbPWvp8P0cscY6Jy3cJzlMbGQftggxMe2/UQRMTM3ZTk9 hGmGeyo2DcyqRq73O8BF5QR/pWmb5Pnj2WgYibi2VILsiu1JEuJPeU8Aky4pYEUYUHUL PK5g== 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=iz25i9uW9HGamPpwPIb9YcCLb/qpX5yzXUOYOmCIaWU=; b=TThyo+48MvonEc5VKWmW8DhwwKWjjFWYm1RkyH4VpRBnk0tcbZ0/2P6eap+2WZlf7M laJ/oaXkySeMpKHVDxKqSVN3z0QYqFj2BHZopnOL1eSaCflWRTgIBmlY1mPvZkvq5wui T23ecgNrkNEULJdXfoBX8jOdGhckc0DqXb4EYdOSBA/ydUyeTJ0P9oK0aaQdcGV0wKw1 Zw83VY/g8G+B7zeodEZeXehxFKj5mFQ377nrh+JubBWdDsfxgGCFLNLNPU/Gl5NxHODU xpMKE6xyDUdVpTRugbrZ8/6B7Rz6QS4FmGzmS+dwgwT/K3xdzmGz25n1+B+z7ecEuvj4 Mo4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=1Sixqs21; 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-88938-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88938-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 ay16-20020a056a00301000b006e5ae7ddf95si2758487pfb.282.2024.03.01.10.48.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:48:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88938-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=1Sixqs21; 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-88938-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88938-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 A88C028248B for ; Fri, 1 Mar 2024 18:48:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00AF13A294; Fri, 1 Mar 2024 18:47:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="1Sixqs21" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BABDF39AF6 for ; Fri, 1 Mar 2024 18:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318871; cv=none; b=SXAPiOiMEScNysBvoPBM8Z5y4m4UGDyyvZxjWaGRcXi+THJI8YV9Gy9kzYeW8vQ130zc+1b97l0XPu7BGf+vyeiyuWhO9IuaVss+x4c1SRzBeO99c2J4FrlvGlcOhNB3sLdxo9QnznOOmMI/OqVyg1NJz73pwo3TDWWlaYi1x8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318871; c=relaxed/simple; bh=RzPNAkcYFaWtPD0d/orbD+ZkcQxuwvwqzQzOuKyN1IE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=eSrb+hxAde04YLPmqAhP72AK5Z/jVz8zs+RSUe/dsBys92MpXr+Ww1113vxK+48tiM2sjFEXaHNaDoD1L+/ZmwlDep9WyRLpEjFHoEKGjOV/X0QzDikBXO1XG4qVaS6uTEsTuo2DG8yrk1pp3CcwiK5t02kB4Hs/63pReIZwUiY= 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=1Sixqs21; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc746178515so3500027276.2 for ; Fri, 01 Mar 2024 10:47:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709318869; x=1709923669; 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=1Sixqs21LI2Q8+b0hz22jeQsPK1Pyp9lTx6foX7/mvlu6EFagVWgAQEuXAyZ0XCcqG ZcwV+01ok3ktnDlZDOyFjV6Xxsd4mZDTwY5OzLL2pdeqv6RgLO+arZ+OE+PxvULqgK8q t6KjhC9HldfqmksE9Ago7BrxJ3Xn9r9GTis+S6+8iTJyt7gieellQSWgzbzNHZ7gYZo2 FnKX++BZL/NCfWKKxjo1yBglhKwcbxeu0PQj+WR7alTlaXYi8x5ZpAf4/0L5yIsLdtL/ aFyAQ06PiVeKpwkjAnBnF3FNsWGpExPKauxuT/yjiJgkKRGT13PyLb2JWH41SAnZ1M3i ebJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709318869; x=1709923669; 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=JFS8pDSW07JjnPSXfQWCnOXpTnWnSnNutIPE4eIzlBsQy/+9FMHCINMhrbXHaJ09j8 A7DxWJLBofn6H4Zh9U/Gjxro0ZsGmdsS4NtbdMPWpdr4q2DvmToojttN4EYSdgznCohQ haEIOiq6iDFO0HXPI3/ub8wKv/u1cWkmPpAujBnRmEfrCMq9RKBlh4fG5DdeB5N+l81U uu+bY2dZaKgaFX4m3EDWoYvSMKQP5me1FEZHpp8D81KH7aEkUQGkjSfkM1lqfshgQDBP ZE7BFphPDDhd6qv9n7zJDZ3+PnibBDBojDmwLLNTOIQP3O+vt8oFLrJPf790Ed07/W31 AAEg== X-Forwarded-Encrypted: i=1; AJvYcCU3fiU0poWkcvlC3kkDo3LfSVRAd7WVHC9v/7kcx8gkageeRdhazs4aXBILfNYDcxt8mdlfYdcw0ZIhmK+PYcRPJlL9Q8Wrl/vRgLfR X-Gm-Message-State: AOJu0Yw9EZ7aS946PJt3+XUOirFsSIH9+prDtA7naM4HImVlraPfiK8M WBkpWSQkKyakggYU2ZcztDuYfKBh18LD6EhcCfdDFRJy8AYA1S8KyP8TmC8CGwohR9JWjBByiRo LmRZc9g== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a25:2688:0:b0:dc6:eea0:1578 with SMTP id m130-20020a252688000000b00dc6eea01578mr531960ybm.13.1709318868700; Fri, 01 Mar 2024 10:47:48 -0800 (PST) Date: Fri, 1 Mar 2024 10:47:26 -0800 In-Reply-To: <20240301184737.2660108-1-irogers@google.com> Message-Id: <20240301184737.2660108-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: <20240301184737.2660108-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 01/12] 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: 1792350772490739638 X-GMAIL-MSGID: 1792350772490739638 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 Fri Mar 1 18:47: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: 209016 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp82858dyc; Fri, 1 Mar 2024 10:48:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXLz/ASR4hxTyc5d1KZmMGZQuCvE58+meRsvvT7GrQNQno38HqVDTIQ3SWR/s1IO0eh6MCsMIyVBHwhsJQxldBgRE7ljA== X-Google-Smtp-Source: AGHT+IG8sGJ0BtLUGTCOggQrMwy6tRV6GRQY9lxA4GmE8nXfAsisoGg1J/+id9cDlm6aCAvYq0cb X-Received: by 2002:a05:6358:7e98:b0:17b:88c2:5c13 with SMTP id o24-20020a0563587e9800b0017b88c25c13mr3031495rwn.7.1709318915495; Fri, 01 Mar 2024 10:48:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709318915; cv=pass; d=google.com; s=arc-20160816; b=ZD5C3GG61wbXNOtUOnf875sPFkUDwmRN/xFvl2tirPkxLhekmnASTAlnZxEw60xN6e eHM8pAl69Hm+dRjVgYx0RA5c+W+dzAnbVMokSpAuztlzZFMLw8HoIV0Sskk7veLC6Xnn zvJRcC6CXGTUayabC3beSE1PoQuNELr9DqVmK0lD3Orq/LTa50g27MYmS9OCLiOv2Jef tooSoZKgf+d1X4sdSvs3+hj15Zq++wZEuy2oy31799DYqJ6CqNe8EHCaRnmp8rvMaK86 Jp24GN8+nlm6VmgE7GoEBxIvLc8FhCsJfFP6DJaxroqg2U6Uw4fHhP6GttezgehvSges HQ8A== 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=x7+UV1uPxnM0VkiswCpWFmjhXlM5mTnh/EUzeRuAWQA=; b=W3duu5aiEjmZiLxPsALR+P8ZA7P5gf6lskAufVfB45BlpOq8vTotKDFUC/egDoFlLa 8bnDYI+fNB5uefsg3vkYcw4BQsi/WS/2KczFUka/9XBzZGau64kT7rQ16vKlvbLnNlgF NcRcraMrfAVk0pln+/ty4tvePomKMOqFvW/SUD0+K9By4GBZfRfXrvh68AniNVjzEK3E qbMUuqG8mq+Ux4EbOLEe9T9TLBMm9IWz0KAsvRhMxgkIk8oEB63cnYMzhSN53a0sf5BM aPrXWH26WEeLsPedwSIsZFlmccojimUF2GmrIKyEPuP/aYzMrm6tMaLVSFSmuz1qCDXx 22kw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="P/lklG85"; 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-88939-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88939-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 e9-20020a0562140d8900b0068fcacfb34asi3979616qve.235.2024.03.01.10.48.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:48:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88939-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="P/lklG85"; 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-88939-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88939-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 3BD991C22ABE for ; Fri, 1 Mar 2024 18:48:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A773F3A8ED; Fri, 1 Mar 2024 18:47:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="P/lklG85" 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 76FF23A1CB for ; Fri, 1 Mar 2024 18:47: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=1709318873; cv=none; b=uMRuj/QSg9MByNtoOzxjQdTmndUDsf3U1nun77WoxjsW8mTTr1ke+pc4lo9csQePHN9RcF44pE3tMS0MAf/jzLkAMGBco3+OpfIzubMhy154X/T8Bg/yiaikTX9dvxnKnumRKfUi2tDhRJJnA0leonMCewiPFX5cN0jwiGs31XI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318873; c=relaxed/simple; bh=Dfpdo2YwplSQDWWpMc73Uzmy+I+y4UMFYX3EUMZzsvM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=a94qQvCl41scC26XVMImtrfoABsSAQgtBI3ElxpoK2guzL1EQ9mnACWcD6nYIl1rJXz7jlH3ZBSt3PgJjdCfq8pSIa16GIkKUNVTT0gZW8dnjSI9Me4Qwp1C0wa+MOHP2waPUQH1o/5fKd5Dk8oUG8CBazYEUcJXcuaQihCGr9c= 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=P/lklG85; 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-dccc49ef73eso4227592276.2 for ; Fri, 01 Mar 2024 10:47:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709318871; x=1709923671; 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=P/lklG85DrBGjnJvJCtcGNEFpzfLaJUIxPTojlYtHk25zI5/skH/M+2+Kq8KB9Uo8l T6XMcL5z+eQOxZKBx0DGVZ/mo8mb5awbK6fKZfqyqwgBwCL6Bb+YXLi3UsyQnmNzhn/m yHLH+o7v4f1G3ThXg7VqYXxAjN1x3FsYxNDOEfraHFgwKrvlN07LQ0dvHb+GFnhUPxhg 6e1+9BzYO1l1nem147r1x996ADOvDaZSkq1KUwcmoegCYhVB0N0k6knrgWrI6dnVXKRm 7OFUkrMc27wuQ1u9R0Fm1o5qJdwrTPlITYSaWZqcLyzDJ4mBcZWwEReBAiao2R1gvvoo ZXhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709318871; x=1709923671; 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=Z1dXKT2LfG2yiw59hYz0RL5UDZcsP4FPbmN+H5JTF9rfrQlGB//UvTOYwwAf1/5/MN EZ9TfPIa8/aWKfEeyDeMm7B8kqfzX5c1KxQOZdu28QTkb1Veqnekt0o1kULqS96mlHny EoHF7EiSIvBYYdIkvWlyb062VU411XStYFpTMmdWtQ4ona7aGWV/lAyfwJF2r1Ue8WCh 7hqR8ooYO/5+qn4jkkUQmTi9DSLBWJX2bg9W6ht3vHFwgBPEryrkFLdWSfBk0RjMBiT5 zQdpc2fF5sQZyNtpf1GzUWl1FZs+SUC1WuNEpqvDEbXvg14jSXI4TEWJ3SB4NTNY5D12 mItQ== X-Forwarded-Encrypted: i=1; AJvYcCU2Q4ePzmfectBzfxxXxkTvV1nRoyTnTPNKyZtNxmaZlBAJ804kZPOzHtFgOj/zYTDc6YXX9Cbgu4mDUIA30E6EOsGpmobp0gMD0Bad X-Gm-Message-State: AOJu0Yxxo/pnaycWeQEubaakJyeI8pkyKmbkD4MuS7ek/2QFE+nVnLde ISQeJRGR/dnq0bHxVT6cKl6f+8oeBiGC+JxK128R+HWz/LBv9Ou4WAT58zK9mqHvC4tAkenwLr1 LSK2eAQ== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a25:2690:0:b0:dbd:73bd:e55a with SMTP id m138-20020a252690000000b00dbd73bde55amr91844ybm.4.1709318871487; Fri, 01 Mar 2024 10:47:51 -0800 (PST) Date: Fri, 1 Mar 2024 10:47:27 -0800 In-Reply-To: <20240301184737.2660108-1-irogers@google.com> Message-Id: <20240301184737.2660108-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: <20240301184737.2660108-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 02/12] 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: 1792350790985881287 X-GMAIL-MSGID: 1792350790985881287 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 Fri Mar 1 18:47: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: 209017 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp83000dyc; Fri, 1 Mar 2024 10:48:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU3mDQaOnUSkuT9Rv0lFdl02trVsgtfuUXeWSQqxSbRWBZlkog2zQ3gj6BkbnjENoDzRpd7w4eW56H9uakU1/f9iooe0Q== X-Google-Smtp-Source: AGHT+IHbez6Nb5IcHbhtUJ1Zjn7nvekCnWuhFkbteUqBKst9xIbC49ERQycMq5z96x50QTc2mL0s X-Received: by 2002:a05:6830:200a:b0:6e4:7762:bff with SMTP id e10-20020a056830200a00b006e477620bffmr2975167otp.34.1709318930277; Fri, 01 Mar 2024 10:48:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709318930; cv=pass; d=google.com; s=arc-20160816; b=gLbMhOKgBmsiTMsp/eiuO6fFeghROBAUuzbjyImIz/XsmT9UJJN3hj/ViwRYj0OSnk wXQd+zLp/Ew207LYSbonnS6mEQbSAqQ+mfvinPW4ESkCAiRcD1CuJXhx1FnTTx7pKAA+ dVuCGWb2JPBs9VADtYuv5OEt9YZtEC6qYFNzjEA3fCzEA7t1iG8d0ZSSqSJ3ZBWHRHva lyDju9P0g2VjyzcyBRSZexdcLlV8RmTdx+OILiNvD0BH2069LolDGDBJuu5pFernfoRW EEbGhc9Rou9D2iStquVniRCdI2tZrEH/D5YiZ0BtlmGU4Fw+P+S//hYQDR9V+6XO9quq OroQ== 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=nszVAuzxoacFZP9MYxm6jRTT+MugTO1Hq6y6yKi0T3o=; b=cX91NClnnxLmEJsUdY/jHcUOGujL6tCv4mX+gc+FlVlvr+4IutAaXR/kqFNUPpDQ16 /BBcuRfn5NxchBU3/8j6iFTTvZNaH3oQFUjjcNh+nE5Kg7NDM6RiYjtaPfkguMdQw2FC Q+PrdaBsLsNHkW6vQPKtu9uv6L0ePCYyn2lNZV+c9is+pF+epPlUCORwg1bK2GzCrycq 2YN7OHbyLuoRixwX53KbFIlKV0ORVBmjdf6Q6ioRrdI0xTgBEzHxih5xCe0ZMtwPbEq0 PlxF0iCpwcoJuqFmZdztvEnxRy7vZLewCotMFVA/WpAJSq4j1wPA5Suh6iWjaCChiPdh rEwA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Y1D6q+WK; 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-88940-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88940-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 c16-20020a63ef50000000b005e2c2fc5125si4137927pgk.249.2024.03.01.10.48.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:48:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88940-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=Y1D6q+WK; 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-88940-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88940-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 175082879C4 for ; Fri, 1 Mar 2024 18:48:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E72A43B795; Fri, 1 Mar 2024 18:47:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Y1D6q+WK" 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 A250139AF6 for ; Fri, 1 Mar 2024 18:47: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=1709318876; cv=none; b=f+XwoKmzBpgPvpeaMU5n3gBDf8AqLEXhBOwLii2YA32R3SsILA97ploji/+ya5tVbgTbC/AyqJNoxR2OkitmjJCaFwaAbzEwMoXdqhdQM6pUwITzKOX6+WVlr8xmL6EiHyRPxcAY8NJjCFwRUnqfcO7Fx/wtGD8133CEqQ1HcM0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318876; c=relaxed/simple; bh=yEm8gDDiOp2kaCb7bjt8yDfO5lzyLygQrwL/+bKOLd4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=SF7I/Wmj4WrPkeG3Xd3rhL9KgDCO0j16JwCBqpMwRrP8FK8oXxi/q/1fiMPQXBBnmFfMC4Cs1dR/GTaHy4boVI4tXyHvIqedKjVhoZQ2UdMCMLpiwc8YPN0EHjM2KfJXpBmsGF5jXO81HCm2dcBtUod3VgiIUFKBlXhnXTRISXw= 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=Y1D6q+WK; 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-6098d88e994so5067677b3.0 for ; Fri, 01 Mar 2024 10:47:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709318874; x=1709923674; 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=Y1D6q+WKyJ7+I+ltfXM5u87F7qgTMdnqW18Bhuh+ivJpubUsD3SE1UOaUMRVc8TPiH KQQq38JqzLqcgklJzqpK2Aq7hqfZWEqSD2mNtpPZQt3ixGmO/foTGYCzDGc0OMgOSF2U 6TRIILIGnrBP1/Zz/X0l3U0f6no/Yd8gbQ3IV2QmQbz9cnBeyX9SABeNNHSFPVYbglRU zBU49X0VKwE+gCexNQPE2Y0elZaJUNCVPHFrdSrvuiZo37oNxNbOzF1+uuTmoIL7zIBB EtPK04VEs+MwcTwBQCxa5lsca0eVI0pGLUzoDQFK9rdQbQlDyfKJrtHhWugdnBcReTEO Htug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709318874; x=1709923674; 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=Rj4IPQZupkkJh/udza9MQ2S06Y2MjwblrS8xrZH9Isr1UbqzloR73xTLcto5efUSkh MfhYIithOQ9RLhC17vUTVQiT7nIeNeZTx/Za6cWA1LZD5rpcft9OICMKl52/lJWOAtD0 JroOJt9JC1ewDjiF4DcHZGgX8Uqd9zNkGJTJ4/3iwMlNtPJOU1V4zV/xM9kY8ebKXw5t 8ksLW68iWimk1qmUxQwPuOeR6Xv9AsEO4TqXjZmAGTW7DJTiqGFL2F436mUo+rXt9MDT M4mFJbYxKkdB9o2ksDmiJHCLUerzXG9Zl4pusp3Hd2nwPFK9xWCHlI2KBuRa2ta/DqOs OGbQ== X-Forwarded-Encrypted: i=1; AJvYcCUVfiGm2rHSIwiUtowESuf85wdnxnP7e5hIX0FDqIfvFgjQN1YuUErTqhnDXVP6XQI2LaZCOXs353pdu1E3tTXn6qx0mabuHkAduw/u X-Gm-Message-State: AOJu0YwRFKN5hWmEzetpHtADIT00qTPTqNAGSSWIBwB4IA8yr3b5cH+6 sWVgaNpFS8/mXIfXw2oQQhLv3ZoGNuwhpJPcxzvkPS0twxlD1j0lYo7HZBUQxt8valto5TLN2b0 EcIDcbw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:690c:3702:b0:608:1b39:245c with SMTP id fv2-20020a05690c370200b006081b39245cmr631942ywb.9.1709318873830; Fri, 01 Mar 2024 10:47:53 -0800 (PST) Date: Fri, 1 Mar 2024 10:47:28 -0800 In-Reply-To: <20240301184737.2660108-1-irogers@google.com> Message-Id: <20240301184737.2660108-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: <20240301184737.2660108-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 03/12] 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: 1792350806788074476 X-GMAIL-MSGID: 1792350806788074476 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 Fri Mar 1 18:47: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: 209018 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp83161dyc; Fri, 1 Mar 2024 10:49:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVq2Q0hGhSKTXPPS8eRym6d8pJGZG9WP+1x1rklXZUVMEWLnCsKy96vg3XdgF2EUz5Ero+yHbHRsB9LGHcIHEl1UUTcmQ== X-Google-Smtp-Source: AGHT+IEvbJ3riTyzb5C26ns164h+U9MHcQ88ntQHwfYlWTmp+/+kLWRUc0/vu4D+qpee9WkarGre X-Received: by 2002:a05:6830:112:b0:6e4:ca90:4526 with SMTP id i18-20020a056830011200b006e4ca904526mr2976179otp.20.1709318948325; Fri, 01 Mar 2024 10:49:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709318948; cv=pass; d=google.com; s=arc-20160816; b=uixNoFK4OU9CTUFi7PzwtAD6LZNPDD1j/DJxKxXS/ZN5KPe706+MDm4Ax3ektmHH4D mGE0KGNl7Kk7qXSP4EvancKhxDYqFgBFN4R2Tfu6zVj0s1ZmpcZ9a7SUeC+ko/EP0OHA NZISUT5U0JJcpUG+w0E1cod/a7UKqUsyQ8Q2Tdhsc2HazNLw78bz2jAepuaxUTw3Npdl n0ClIbA3je6aYK07Khpgz50iB1a5PBb52tXZlw/XnyEijGjnv97t/T3FcLzAxJA++bak EE+hi4R1fFVbbMIpjAWNdNv4gw1gpoa3iuK8x1cztIrIveumOvSPZZ73mcDl+VkCzMdg l7vg== 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=R9UQ2wTcPnHGV71l8F3V55zmOE+cpNIjTnb7xjTkBqg=; b=mRo9g2I4s50vzVS5NDUbdrlIgzfFYOFo29MUXLBWppWihxE+kJkbst56v/JTduuRKq u2y0oM8HXrCRVkv2uk+QfjSUFlYz3VvXvPqqW6Xlt2ihSrMF/WJzmQYRiairfZ39QoPb a4lL2BMADfZ1+uoBQzfW8W/kByk6M22HrUzxzSL3OOgE16JxDlSWTg4UDDZ7S+Etcr8y L0aD81StGfTGVOXuT4fUDUoj86rHn0WeyunA4UyYmrE9diKIREvBol0YhvYeC9QkoSPd UktTDuFxidyshMfl0hDwWiC/8Ap03XKd3S2JB0QVBCN6SInvcQsBXggeU9WkOM6NgbYR ck4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=yH3OGAUy; 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-88941-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88941-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 y13-20020a63180d000000b005ce016cce21si4048090pgl.191.2024.03.01.10.49.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:49:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88941-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=yH3OGAUy; 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-88941-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88941-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 1F7E7287A90 for ; Fri, 1 Mar 2024 18:49:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D47F93BB52; Fri, 1 Mar 2024 18:48:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="yH3OGAUy" 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 B11812900 for ; Fri, 1 Mar 2024 18:47:56 +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=1709318878; cv=none; b=IpL3jwUgegvCZblOafEucULCNyzuEoLTywP23lWAvXXhJMwu3q7AM3QC++HPhq5m5fcycbTlnxOVSfRSgDPCHGFCjcGCe3+1L60u1qrt3VJ8j/O5RQRs/38/E4Bpm/oR2b8jnSjBRmuuxqX2W8YhEUU3wonkjt2RjKdKRFmtok0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318878; c=relaxed/simple; bh=YIxmuBzBhglh4md55W8onI4xgQ9tn1Wuzd6FPGsaM/I=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Gd7ouPTeAlXjDdHzIAM9xEJ4aK6XE3rjAUJyrQHw5sd/4vAEWazpEm/dXRquXwZWl5fVcB0EWyqM+Vgg93rzELdXWdEQgeALihHzG6F5DGwRBc0XqxlCfghAE3ooXLBd7Z/TieTSLJl4w08nhNem3G/PfOFgmvMZlj41rodw69Y= 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=yH3OGAUy; 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-60942936e31so43519337b3.1 for ; Fri, 01 Mar 2024 10:47:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709318876; x=1709923676; 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=yH3OGAUySB209hsYUXvNYToJJzxjq4DTKItQNGML61GQ5U64i9Cp72Sj9rX4U4WwBK YaGOxcmgNuS5hWIZUxOu2GfqZU1OiIIsLjlRcubZ3411LizS38zwv5iDL4ilRdebCB3F OjQUieCT6HZG5QhVrhUdCo+7efXaenQpeIKo/J7IaGAL3yzTnM7AQrIc7BSOhaS6nj5v bAkLr7b9T577qn7zX0gq6J3BPXR1YZmt+zGMuljCAP9Qt342Xc+HPfq2hpzFM2xlH4If ZpIwM4l4ss4ogAMiW9ezIDarxGfkrykZlUPjGhGJPTEwPbTI/Z5qblTlXdnJIRpmVuKE /9YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709318876; x=1709923676; 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=HWpXpuIUjpT2DdE4eUfCP3HeIdRP/chIbJA8OoeoJiyntv2mnNuSFMz1DIXuuLuJ5H c4fnP0/4y4RTm4fKuOVYBbZ7bbxkLL7q6JA9p+fxhTdOcaXoES+7rkp/QUQmuzdqa2MX JPaiaRCAtXLHXmpnfSxENOWWD+JdgsHcaC69hiKL/KhXsO5gkakMa59JbwVKC9W7eeal eSYjUM/JRK1hQzYHFpe4GuLAohk5SAmQ44+VacXFn839iq889t6tDaP0DYUwvbbY9Nod kNM3B3k7YqtO+OlhMHeRKxy78Lu+G1Tl/dl44Dqc1zSzPTC1RNUGXx0fZSybkkLscMy0 GlRw== X-Forwarded-Encrypted: i=1; AJvYcCUtdEnxt0r9gohHP0bUFq/FsUiyTNYL/mRfInbnywCOJcCIIN2sgV3PrKwBKsHwBx+T70rtvROxBFf9R5E3Q7ofjVR90e8pfy57cYQ7 X-Gm-Message-State: AOJu0YyVYsXLvVcTlmG1QYJz91pE/PJPe+hpKdkHoXIjCEQ1l/pOgZjM R/DhU8Cxpku2XI/6HoRV8dJNSw4yKpZb0dWrjKN4Wm222HP2qHW+BcC2/jXIK0PYLdkpAXLHL9u SAVUzaw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a81:9809:0:b0:609:2031:1e09 with SMTP id p9-20020a819809000000b0060920311e09mr600157ywg.6.1709318875876; Fri, 01 Mar 2024 10:47:55 -0800 (PST) Date: Fri, 1 Mar 2024 10:47:29 -0800 In-Reply-To: <20240301184737.2660108-1-irogers@google.com> Message-Id: <20240301184737.2660108-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: <20240301184737.2660108-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 04/12] 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: 1792350825574862097 X-GMAIL-MSGID: 1792350825574862097 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 Fri Mar 1 18:47: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: 209019 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp83322dyc; Fri, 1 Mar 2024 10:49:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUbWiDlvTpK8d2hlQhIHdAc/qQtBkkkqLuuONRsinEuAwR7U7dtnFhNP+0mHLuhdOsZkDIfmHI0pD8tCCcK9wOO3vEbSw== X-Google-Smtp-Source: AGHT+IFuEtTRCCR3VSSbkl9VFUddtzXzYsPatqx97rzcUzPULwLU6DvvKxU3SEGSXRaiAe0BpE1l X-Received: by 2002:a17:906:34c6:b0:a3e:f79e:ce56 with SMTP id h6-20020a17090634c600b00a3ef79ece56mr1740755ejb.45.1709318965904; Fri, 01 Mar 2024 10:49:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709318965; cv=pass; d=google.com; s=arc-20160816; b=ERhHPPDXBRO/RPd38pxZz2zwxukMIN/oyYI5ziCuF7RzbVTfJ+ZltLI8xxOUfwvTn6 B2Cho2lfT2MtT5nBF2B1jLUc5vUdV7FmrwU7vem/GFh3wyZrdQjvTJYmZ3txG0nDzEta UII4G3ojkhQQ7OYnOCUTZL9iLk5ikkIdoAfporKVs3jtac/eOicIz47b90txzgnD2PzE 3OZGAkxywX4tFtEN6aycVYl5x19iAhwToqFQ+HfcgViFtd4TrD+Uk4LCUX796jr9bp3q XTzS1tgVpIqwve6mwD8EorGK1UL3BrI9SkR8ct9biudze/sQRRQoeYonEiXj3NYV8+cI JrQQ== 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=e2K4ORCWwRvrWujysehHBbmLotlNvmXtw++YjgMskls=; b=pCbS2EHJCUyaaDDgg1sMt7tDUyQ3+5D8eL99Hay8VVERAnwkGC855d6xVDSCeeHll5 BTI46+xRzeDSXn79WanJanR4V3kxc62xXfTkPsRhFLmyykgyCRFhQsx+nbSK1j6kCjjT FMLD7/hVmpntqKL1jrehCvnrAVJgAkRVAlLSAON4m5gjLPYlC/w/9OtQSBXZGWNTnb5A X4LOKluvQKhWHNenhd8l0LDiLOr9NZmlky0wR+R4MYwO87mc7DwbWT1+/uA3z+rO6Bwv P+eeHUiBpIf+RRO3ImNlTZX07FUSouoD5fCQBXttuILkDH4/P/oUPNg3/iLPo3vf4K3g QeAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=awb4jSZ3; 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-88942-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88942-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id sa19-20020a1709076d1300b00a43bf12748asi773873ejc.537.2024.03.01.10.49.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:49:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88942-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=awb4jSZ3; 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-88942-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88942-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 5CFCB1F25E56 for ; Fri, 1 Mar 2024 18:49:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E50C3C469; Fri, 1 Mar 2024 18:48:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="awb4jSZ3" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6D643B194 for ; Fri, 1 Mar 2024 18:47:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318880; cv=none; b=TCmk6zjdxR4oxuJlf02Pk47LT3t+Am11tEBU/rDmtPH2SdLWwGOHF4WAA86aJvqieURqnP7A+V7MmDDUMTSrYN1MAnRpE/UKeomQSlUMklUUfya26Q64S/P6AmyrNlaoHl8QesBDR4QJy1BeaS2iX93DXhEZ6Yu5KapNTR0v6ew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318880; c=relaxed/simple; bh=+avI6OXSebapAM2pF6TaSl95UtS1MYUkS9EvCqrF/LU=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=t6OLIM/MgRevY7k+gI4qQ7MwyNnjAvaVxQ9ntAX+OfX2SC4+3dyPy45ut484XDPrzGw5KV1wqk7L8eyxdDv8Buk7QvXdH2yHix2/ES7czuOluF7YgBW4aT5ItF1HBqdsNJERRgSoHu90tED+e57w4ZS3hfZDbe1XlTwVhzPVLRs= 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=awb4jSZ3; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc6b269686aso3600397276.1 for ; Fri, 01 Mar 2024 10:47:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709318878; x=1709923678; 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=awb4jSZ3qKGejA5dbO4I1dDLUhX2A4dEiNDwODlpM2rsclpB9N1Wpnrv5uNhGfjmrL C+MhNWFWMF5Ch6eQNVjLfBouAUUNisEgzmwmV8bniLCz6c4I3WD+vTC8KsSdMK8qBN8n blESTGOeek7w9oCKIw2RRNbrJQUy5Oxr4Z8kE0d0eVX+HLXfAJs3U4T7p4A/a84y2cho 9wyvqV0hoTU4A19+WjGl5RJJEr/TF5dZi06UUyYqM8nswmGAYOHbSu8XCiovpGtp5gxR dkgendH7iG1ufBofpsT0ChkSksRS0AFUVKaSKJYK1ETe9cH0wQfZC3HeAjxWsL1ZFCTe hdEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709318878; x=1709923678; 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=IR5n5lIttG4oYBP+zARRTs3ykWsrtiKf34R6Qj95ZmBov2aaJUNXBUZYw/fQfH/HOX BwtPm5N3A2/gebYzrbnseSYYluuDREn+ZIi//ri/1/FuvzCUMsh2EogClZAj5mqmzKxP /bCe/hP0kSewXI+1y0TWlNrmPoez03mKvRXzRiIatsYmTJ4dgjDj2wTGol7G/8GxWAaT dLVvzFGLMaJFL1HbmN8I85TWCoA4a/xza//k++Fzp4h6/cetpItOMx2FHojM77rfntou 5sjITi93WPwUE+Pugy21fkxSjrO1zQW+J2x9A43jOh2vSW9t0ProYWhhlGc6iFppkEvz VYzA== X-Forwarded-Encrypted: i=1; AJvYcCVf6VZGpVs5/4ScQzgBSknsq/S4iYCRZHZCpl/81dRkmKQxXW+c6K9UpQ1Kwu1HhTi+X+vBsd2j+AUYXZ6OWmA/Pm+/gE+BYFlgkbSn X-Gm-Message-State: AOJu0YwlRLAfo52GRHsRrXqoSR3rjdtK5e2CDAcB99VYNlrys35HZDnX 0MGlHFgpeIweLJ2hn6O55RxkeYCrfQZjUmhNzpIiedk/ZWUn3NC3JA1UuDhO2HL87VCDM7EKB9V dEdvVfw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:6902:188f:b0:dc6:b768:2994 with SMTP id cj15-20020a056902188f00b00dc6b7682994mr108005ybb.0.1709318878023; Fri, 01 Mar 2024 10:47:58 -0800 (PST) Date: Fri, 1 Mar 2024 10:47:30 -0800 In-Reply-To: <20240301184737.2660108-1-irogers@google.com> Message-Id: <20240301184737.2660108-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: <20240301184737.2660108-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 05/12] 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: 1792350844349440345 X-GMAIL-MSGID: 1792350844349440345 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 Fri Mar 1 18:47: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: 209055 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp104074dyc; Fri, 1 Mar 2024 11:21:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXwtuilT9aHW/RkztzJ8M8ri6yuZOjMIHD2MKgHle52vQNb4Y7GbYTEE5RlPP7CWqLIwS0iTufJeVY/SKBYEMDvqgQwvw== X-Google-Smtp-Source: AGHT+IGmaui3D3PB94cjOT0XdFtllq+GROrjp+mMY9c7y/qmPyVPcodod+zwHhxecVAQxGH+/fYw X-Received: by 2002:a92:ca46:0:b0:365:1a59:dd6f with SMTP id q6-20020a92ca46000000b003651a59dd6fmr2959599ilo.21.1709320887917; Fri, 01 Mar 2024 11:21:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709320887; cv=pass; d=google.com; s=arc-20160816; b=bwuOyMlgFr6Y/eFzXk3YB+t1soqbapoI2B4XeZhCEZx6r+9+g7oIZScXkFrv3rmqX5 Gne8VTb9Wm57GvLpMLoWKn2nou5XjvwdwlFjhmI1icl0+5zJz3Q7MQlsiTCVYHpha7VG WlGeCfxEAwZqtaD/HHF3tpTNh/6Mj3oo07vEzkf36Au78HEtr5hLyjwRtQmooz+7IpeM wM2vv40Y9lp5FZ7+Nnj5raACyadT+JVX0e44TKpHLTjtKogAJ8L1pT6+01eFX+S3Z2/M Ctk+86R91x7rrt+FrNQyYt4C+U5yK/ouc7T2T1JiFEmL3eVHDArnf5Dm/qYdfchn2tJA EZdg== 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=OIBiXJpVEkmzE1Ohw998Q5PiBNaEsMY9hz1RfGrlfA8=; b=Y3Q6uoXPWeW4PweOFCxGXIBnwSlzRXbeyQYWdHt2pw4BBcp+8tHZOeukmAQDnMQ1vE rG13RNFAql6X217FkU27eOYkzbbnZb2K76icTCTF9PqDk0gCINoGblMVbh2XY47S55fC O3Sf54zLi00Thix8Lcg2gNakflfjMLd1JiaJpBsYRMtEi0wDUqoyTyFZ9KA0iNim1Gt4 /FFLRxIO+C1D/0LHZte13C4anogdQNMhVID8Ect/Tj8r5SWQQD/mDpVU/EIlxG+GEpYr xFcYbpdGLj0VW2H5DvzkF+Rex7s50sNILkSEshCApCUVY2vlBVq1uZGUseO4RcGVP8TV UdEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Evknf8o/"; 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-88943-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88943-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 s12-20020a63770c000000b005dbd5035dcdsi4120716pgc.192.2024.03.01.11.21.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 11:21:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88943-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="Evknf8o/"; 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-88943-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88943-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 6A2FAB2E611 for ; Fri, 1 Mar 2024 18:49:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0093F3C684; Fri, 1 Mar 2024 18:48:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Evknf8o/" 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 E86E43BB33 for ; Fri, 1 Mar 2024 18:48:00 +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=1709318882; cv=none; b=ug/IvV4Bbw7sFS5/qMPm6pL/OMIyrSf9FUuOKhRAdGSH3dsR/rCa79DKZ+05EXSQC3fprpJvstOc+zpKV3FpnQ8jw4gARY/mq8ZgNmk/75d2H/VIDgLDAgE4pQ+5Foz459yVaOqh+Cgy7oYZ0cKC9XV3HxUT5atSKe1DLz7gv+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318882; c=relaxed/simple; bh=5rPQbQbgB4a9rwpPs3GZO8lIicUTIgfjGCJZshFzKwg=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=LUXP6cjrZ2a4RCHFqT9QZ7gAuplYw7RBj4fW/aWZ44MZL0efseP/f24ujmwjrDsWLRUHNTa/4Fp896AeYoETFE3G2xH1MtUD1fju6vgHW1XQdOu8ubpNqCphc2/+3sW9D7koPtAZXjPkoKaf44fEabflCZMCVAFz42Vo3MrAXwc= 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=Evknf8o/; 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-dcc58cddb50so4185367276.0 for ; Fri, 01 Mar 2024 10:48:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709318880; x=1709923680; 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=Evknf8o/nqyk2JNM7kr8uuxwOFw4tsN3TnEF97Pj2+ODXPRwmBoLjZamMZMiHf3PYH NjRFBk3MX6vxd4leLLxZbPtOeK3IirKAMrabqjyW5o4ModALpsKeVZgn185X8MGoLLtF skXqSdFkccJba7WT8hB1miExbblFcdsveUSex3ELF5Kk5668f+0j7P8oHsnrwInBpPDa LpCr7HL7adFf+D/Bqd+YsBdBySpsShHXVUkdM4Zyy49ZE0DejcL8+1/EYekTxZiK56C1 X5Q5dd59py0hE7z3Vck84w5Y3te8Mhp4Fxw4mpux+oyDF/A7Rxv+aB3RTq9anvNnb/+H msQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709318880; x=1709923680; 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=Hmxd4/AjmlM3dliTMCdslY7Y2VZXDMuxhNBSLjpWyUqfhUbk1hWHX54RhFDLLaE3J9 wnuP/eeytOL/qcDQucpeIm+ZiFekVMqAMN3So3viYQywRqUotBsTLimwGop1MZanm1SH QFXW78dWpALdIZI3Kgx+W+hJ0AhnzhkryVMHHddih36RnWpOGzo3lVi//RFrGFvQUI0i MJoj5uFsUrrH1Me+qFEuJXBlIHOfFcKku+PZ/PKxBIYUmQaVvyn2at/tqQiicfgNLgyt mFnfImASuG52RbCyAJsx2nzqfHT/ZOEnHizAK4Qcy6+BMGL/zKj+CD56vg7rVGDfKSLi aWhQ== X-Forwarded-Encrypted: i=1; AJvYcCWTYbbIC+xu6W4uU/APWAZQjnMEro+vWgAhtGGaYt9qKQpKijL6ffH1pbKP+KfcdFnPtuKUg3KgfUq9fMUI6I1hzyn4MIeRjbSoHPqr X-Gm-Message-State: AOJu0Yz0UTOIhmCIjdabcb8/3Gj6qsU/pRHiaAGTSSKyf8l0h7RMDOp1 aq9LVNRKqMjEjFuKqFBrjV6deA8H6Aqq9pMuAYAG1PN0DhrmBYWVRb0dOmrpxKEUqwrm+35JpE+ oTUdunQ== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a25:dbc9:0:b0:dc6:dfc6:4207 with SMTP id g192-20020a25dbc9000000b00dc6dfc64207mr528160ybf.10.1709318880106; Fri, 01 Mar 2024 10:48:00 -0800 (PST) Date: Fri, 1 Mar 2024 10:47:31 -0800 In-Reply-To: <20240301184737.2660108-1-irogers@google.com> Message-Id: <20240301184737.2660108-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: <20240301184737.2660108-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 06/12] 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: 1792352859666793747 X-GMAIL-MSGID: 1792352859666793747 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 Fri Mar 1 18:47: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: 209020 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp83555dyc; Fri, 1 Mar 2024 10:49:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUmYgzwOeN8JgkYm2G3ZkjzUV+OaAqo2yjYDYuFB0rIMPWqFiNcScO7D8Oc/7k4B2GmSKeQ+V2iRseTayvSschq/KL0hQ== X-Google-Smtp-Source: AGHT+IGwRvUnGAS0KqW9Sy8USLaiEPfBS2gf4s3BuNefq02PNKlrtcff08ttAkAQnP1i8AxIErzE X-Received: by 2002:a05:622a:295:b0:42e:c595:d9f0 with SMTP id z21-20020a05622a029500b0042ec595d9f0mr2594468qtw.16.1709318992279; Fri, 01 Mar 2024 10:49:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709318992; cv=pass; d=google.com; s=arc-20160816; b=nYdY88ziGcRLmtYzbUZYnX9CZev2HkCC90E8/sAq0UETq2y+ckErXmeWfvEaI3jfqU /5oUzwMh229k7M8NydCxaCh9yXDaqH5QwYcXtCPwxXSOg4ipXOhbpJ/TM/2gPjqhi/wT sGbNIMCHLCVAib7Nhfb89oDHfQrTmc8XJ2raVbpuUicCb6lV3Qs7KFprK1rZi4ph7wtu RNPsC1qKuZm14dSyU6Vq9doqqDtApOjCalu6Bqtqc65vsMbUoJffgdRyLQ194XQUi4Tp JdFvTjgBDtDYaGCgv8aAXd6HDgfGqjiKT9wknoTaSjaOuRF3wQ4yqJ3Od04VJOJ4kxY4 R+1w== 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=PxNm+6s41qw2yeQMzRS2tdnnmyvSll7dVqKoXbpM8XM=; b=WgjwLGEq01lncgSpXjLvKeDLFM99iBGv15KVydUp7ideClUoqFqkOzI32kOdmdbbEA 4AsQBFookaWdhBsuHHvkQiq6g6oLCq5FZRh5Ha19E9C2o4VTYNEPkUciCX3q3pI+w1ME I8wBrLCQ/K9ndygcL/+O/xzxKsWVmu9Jfen6/xVrljxbs4NfAD+TGhLs3o3kbJGzrMCY iapVoqHmo3TGr2p72c3Rd4WJR9o1fkmo9ynjEzgxn6GGWVFNJEwyMYV+BaaxYtD6wD/Q +Qe70Qw1m8XX16YyK927M4C5sJTjMl0j15V01c7lFrBJ6XGWsW3RV1BrGbXkPFzeE5bY BWSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=wQWq69kw; 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-88944-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88944-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 r22-20020ac85216000000b0042e5da7c959si3864866qtn.119.2024.03.01.10.49.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:49:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88944-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=wQWq69kw; 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-88944-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88944-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 16AB71C23299 for ; Fri, 1 Mar 2024 18:49:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 20AB63CF6D; Fri, 1 Mar 2024 18:48:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="wQWq69kw" 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 82C9E3C097 for ; Fri, 1 Mar 2024 18:48:03 +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=1709318885; cv=none; b=VOfQt1YzKYYPIOZgIIKEVFjMHReJKlGdxBJbXZh4oQKr8iNqNKuwr1RDVAgahtFQDmURDTBChc02K/ILixav8yvsX5/CNluZ+xsCVGijuIiNEYqrPSB4trOwZXbIau7Cb5IhBnoGb65qeYCY45N+O21Ch629TS0WGtIi3Gm38XQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318885; c=relaxed/simple; bh=Ttu1a53AKHn6jERMdPOWyCk47DSzrYVS6BszAMd1Sa0=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=QumkMjTJJBC0BHoFW12StUI4TDoQ/NdXKBE0zImk2+PPCV/G+RPESqh6t7XoHngpywkCOWaMsdHQ2RziOcyK8FIknHzQGiz1UUeO6FXICjE4pPT/R/l/ETdTGd4G/AIJL+G7/y2DiLeASRsPk2YoTBBRx4qTG3jZUxdy9rKzRYE= 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=wQWq69kw; 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-dcbfe1a42a4so4654337276.2 for ; Fri, 01 Mar 2024 10:48:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709318882; x=1709923682; 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=wQWq69kwH3Rxc5XR4IZg6z7sSYSQ+gwrT9+lWcLDFtaT3J0HFpU5lOzMQiRyOGrNWr SijFzn+D5oWQOnr/MzG2YI6/vJ5H9zuKV0/8Ktxbpc7bCznfq53NydHiQbdcJgOkgvHC Bk1pDH7aqDRvrGNFt7pnC17sTbxbQ684n4NSQ4E1ZjpK4e36Z2Q/MyEDgB0L2UlsIU1a PnY6hAl00clcfh0D1J65ckUo5VaIeamURn6IkdZPy4DD6LZOIUm9PjXHtW7YzYPYNyCl TfI600VoxtXz2UlSYsTfNrqed9rB1nAYIYpN4vU+sZn/EVUrffNu2yLY6mX8HBeraMpT P16A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709318882; x=1709923682; 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=kvmaSN9a136mWxiPBHTrLERu8KL+USugcHR5xWb/qu079w1MHp62zKKcea9Hve1ErR QmdEt4ERteDBB+4c+Xe8tKgAP786QsZzB8/aNsp1uegYgfeZgdth4yhRZFtuyp7xOGhb MjlJQVC6Y+bPa36SGrCPP2YvnujnyGA6Ws9hKXLyuQ64gLcIjrVxBLYKT1zKnvTQx5UD Lf0+MamG+mbCeRwC8IVYebaNGBLKPRh7DBFkwyQhTtuLIqfwSAG+jHmQudINRCL414Yn OZ8HPYYUinDWudNpIELe4ZO8doXjg55LDLJwgOqTTiclyVHhO0owDN0VJVgaesOtcoHc y9nQ== X-Forwarded-Encrypted: i=1; AJvYcCUb9AJ9NPqkZiUgtsMP5Xk4qfOh5cXqeWx1T6fhHrikMvECNZaLdJ0L9RzHoU1euFwMesFbjuCHUgd9Bfnlp78p8WGnicl+A9BoqtFg X-Gm-Message-State: AOJu0YyucXpylPu/3cLp3HH5WL26Vl8lN46WbDFSEg4He83xDKBXIz4X Cuz9Qc6jYUqmRRvP7SdCThmtznYwxl6tndIRJd4vS029FGMx53YGPECJ3xwpq0KxdEZnPt0Qapy eW1/dWQ== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:6902:f0b:b0:dc9:5ef8:2b2d with SMTP id et11-20020a0569020f0b00b00dc95ef82b2dmr530873ybb.4.1709318882598; Fri, 01 Mar 2024 10:48:02 -0800 (PST) Date: Fri, 1 Mar 2024 10:47:32 -0800 In-Reply-To: <20240301184737.2660108-1-irogers@google.com> Message-Id: <20240301184737.2660108-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: <20240301184737.2660108-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 07/12] 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: 1792350871658257453 X-GMAIL-MSGID: 1792350871658257453 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 Fri Mar 1 18:47: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: 209021 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp83724dyc; Fri, 1 Mar 2024 10:50:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV4bArw0vB5I5v9s+tCaz6N++dtVQmsy1AujDHVVNtKffuC4vF94RyJAFlFM3Vgyg6YrVTsXRmtyw1KmQOinfPwSOwsgw== X-Google-Smtp-Source: AGHT+IHbSvs6MLE3p9F1JlbkgKz+BQQpEbuMhDlbzeebu0nlj3rkFXJf4Tk376l4BK5HTebjX39I X-Received: by 2002:a05:6358:6383:b0:17b:f319:9449 with SMTP id k3-20020a056358638300b0017bf3199449mr2819882rwh.7.1709319012365; Fri, 01 Mar 2024 10:50:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319012; cv=pass; d=google.com; s=arc-20160816; b=SkhWXbU3nBNQcs5oUV8F0Erxml6wR1Pd5vU3SLTGmvkISrw6hl3s/9TmzTGGkSajBB XBj2UBIgHAr5lPR5+6+a68jAUQ0RVij45TLKVbEg2twHjvWwy0xlUmoellkXLgfQPR5p +qljLOUQNg+J3HuVrjdWJKLuilxbSXlDPMVRzGIFd1opsl/R/e2SOv4n7+CAiewqaIGP Dx5h8EAHIIEU/h7A1WkEYSNI7YoJXMFcfMqHoP+XjYpWg4hV1PAXPqIdibI0Vw1Yqs8K YF3U9pnRw5qzwqJP+5RhhicqK26G5rtC2JJRVrQqeXdr2hugG6bc3kohWVUShxz97FXu VKvg== 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=JIcDopxR21k6IPyleH0yZtAQ05uKuHvL7phqx7p1vlM=; b=hDWbxNnAn5Lq4M3sQa4dB13ijUtJhyV4VGldgWVbb01/a0kt7S+LKPTfcXuiAeMlr5 jUH/4QeXgJZWhf68LdLdv8avzVCh7hdZFKjeffNvB7JsUbawBxlHaUExT3JT8hM5y4GQ B7Uz+XyMKSLMDjuDmwAk6XXu0nTWy2O8XICeOdXvmpAhUXUXxALUhp7L51ee6ml4NFZg a7p5cbPcOIjt31fIewtQnv08yEs5F7TUnEBiSjI8CyOCBaCEc9jIPTM4BjZou2rgvp5i /eI8P/niBuWPfZmf/RSxvaqczcYGmoeJ5P1MqqqStj9W5jtpVdGKPaubpilH3GWTVbq8 /kRg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SqCkYMSe; 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-88945-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88945-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 iu13-20020ad45ccd000000b0068fe28213f3si4100466qvb.74.2024.03.01.10.50.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:50:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88945-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=SqCkYMSe; 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-88945-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88945-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 1B0451C233E6 for ; Fri, 1 Mar 2024 18:50:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4558D3D0D1; Fri, 1 Mar 2024 18:48:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SqCkYMSe" 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 B39613C49A for ; Fri, 1 Mar 2024 18:48:05 +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=1709318887; cv=none; b=Gl9NkBJxYXFzpa/6FM9+4D0rHg20h54xvvcMmVQaHcsBdDRKus0pETLN+2HfG+iIvj3anf7/rFne2CdxwV66BEth0HS+Ad4nMG9jjAh3HXKrpDmp3b7w1MS4nOukNuOxhrP0nwUFXTWOKBwSVLg9TxrS8yR0xvJOyP9I05BbJ+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318887; c=relaxed/simple; bh=XBT9PFw4GJEI1QEQOFY5V3VQlW/6wsuXkDB+REWJty8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=GWZ6yWnJPkxUe1vE1ey6XTHSVTxN/ZSM6z/yfffMFP6ys0gJVKZue0JOO1bvMmUJlTBWttaUP+QmeLSB1SNGDz2PueMCmQ5+f9Fl07l8k6ncb7lfAArw/fONJiB92rYfgv6BCMW6fAczDunMTuzAQoUxsI8m8EjjnXpEwyV7nB8= 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=SqCkYMSe; 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-607838c0800so38912087b3.1 for ; Fri, 01 Mar 2024 10:48:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709318885; x=1709923685; 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=SqCkYMSegblOi7eJ1yNAYlydT0U/Jp1fbEVwXiQDqcgaCJD8BYfycN8NcFkjnDgAWd BBjJbY6VzCjKJeY9rHQZoI0HtR9xo97YAkjmeyr762x3BCH4KuyaI6ncy2zeEW6Io4Vc /1xCUF2EN7pwGXbRVjShjdmF2RmyQYshBqvmtwdRG9/yypINhWFT27jVN9+YujoDU3DW 9w784GQVT2hsSfB/vGQ5MmiCMWF9rl6A2dp+cJz9GFtrfJLGl10O/C3E2G9xhfZGJ716 LfugjHv04cf4qG2WSxRmKfC1yLcUjFs4xH1ORvuxBYmKxKDkyEhL+OKEK0IWUiHYOHjs XZhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709318885; x=1709923685; 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=LhXaJAAovpp8B53JisJDSxyi7W5Dxdq6XbVq175TAX/YIjIfthoDxXiDQLCVsXGjjL sHNQ618jy3RC4SMlvZj5UHD7VdlovwBqPtn0vi4x9WLOCBvBWBN+pkH1L0gmnah1u19z 9V3Bo7fRof6f/BlJBK8fbE88thmNY5UHPibihcZM0bux7yr2KDw6xlhgKg0YkhiMmOVF KNipsaOO7h9uPTKHL432dfy7D1pGyXNRYw3X0JDMlwYirYr8lUHnycNa1qUk5Db34zDh 1zni3ojvZI839G7Z4gVzq+fV+MLgcsnk4Ap/lEGTuFXBY/2maWwtKkpW9S50BF1hf08s Kcvg== X-Forwarded-Encrypted: i=1; AJvYcCUP4B8zX75NyLYT8H+TVbUmaTENY/XiL0rkb6QQvs1MlCadRDBsxxhcD5wBmk4+Nj+eBS6amVYSF/VVEhUxjNHXRHe51PRXHJ7G8FZz X-Gm-Message-State: AOJu0Yw8X63nVEb3Fpl7pGuWtuvWUaJKt8CbmQnXXDAam0brCWdAzPEr NVtT8U7yXe3/U/29NlaLUB10MxjCMopc38WX/XsIOeuEc+8ftN6aZYa8hn1LAv3/UZgqcHPPAFc sA4Sz3Q== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:6902:110d:b0:dc6:e884:2342 with SMTP id o13-20020a056902110d00b00dc6e8842342mr710276ybu.5.1709318884811; Fri, 01 Mar 2024 10:48:04 -0800 (PST) Date: Fri, 1 Mar 2024 10:47:33 -0800 In-Reply-To: <20240301184737.2660108-1-irogers@google.com> Message-Id: <20240301184737.2660108-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: <20240301184737.2660108-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 08/12] 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: 1792350892587387147 X-GMAIL-MSGID: 1792350892587387147 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 Fri Mar 1 18:47: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: 209022 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp83811dyc; Fri, 1 Mar 2024 10:50:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV9jjjSpeEIQAM2JLhKgILjdzN9L3mGHHrmonHNq9TT5bnO6Ncpcd+XIzCjWtw8xTKL1Yz7MhvFm2UfUHB7fkLNNL4i1g== X-Google-Smtp-Source: AGHT+IH8F2dLSD8FBE8h5SuhFr2N3hjHUJPGLbljXAOjKARJn9UVlIX98mIO+ftOaes0nFN3DXvP X-Received: by 2002:a05:6402:1d8f:b0:566:ac71:97c5 with SMTP id dk15-20020a0564021d8f00b00566ac7197c5mr1836257edb.18.1709319023285; Fri, 01 Mar 2024 10:50:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319023; cv=pass; d=google.com; s=arc-20160816; b=t4FnPebcpTn7xuv51xvE8WmF9t0KRur8LJLBGdT++FyB0rfxODV4cd5EbaZomcIPtO jSThOqUQQ5NIu+VBEp0gy2A3eoXlBWWegZMt87FZ27+CG0eJUnOf50qjAK7ePJ+OcPQm U9HxkDSGbYTIfhfCGcwnfiUI39jl458qZWc41N28BPMuET/QhtFx+Ko29k8eKZxyzYen ScsizipertAIDfHnxPtRpDL22rbdLREpGO/SDViIczpbCE6z+26l0OTw6Yqf9OVkhg3r TqDGVJGWJmHXiCXU4Ywt1iCTj0hM1bL3QZAmRhsqurs1TpFS+FUHAqQyIHpyqucjuRx9 3KQQ== 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=NDTKPDogy5Au0Mzgux9s7JinoZgM7oCiu+z4Xl2FVNU=; b=JwKs+LOby/74TeQO6ajzwvPs1p+KOcYGHBGjvETvaocszRbpymr9X/IoERp5RcYltH rQ4debRwrD7iRpHrSgspL5/tCs417i9nXlAD3IDsPFk8hRpHi6PZq9QXTiNqUlvf9Jbw ejAOPh08mlEymfO6Kzs9cQ9PCZ0KhmtqRPA9/jo4/fOhrTQs3KibqVadbBdIV1NHEFlr w1rIJCr1IR5pLMQ3sJz9efdlzv6gRcJUp2aMUZuVwlKSRtZybXYWI+fwqbZBUI5VX2lp 3/Y/EanxSOagyNivVIEhM/D0l+rDf9ntdUnarZhipBH9QjZLmJvmvvGs8+Q0ZoVb/lqs Lyag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Ahg71M3n; 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-88946-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88946-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r22-20020a50d696000000b005640f00f50bsi1605809edi.415.2024.03.01.10.50.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:50:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88946-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Ahg71M3n; 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-88946-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88946-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 DF69A1F26AFA for ; Fri, 1 Mar 2024 18:50:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 968D53D3A7; Fri, 1 Mar 2024 18:48:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Ahg71M3n" 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 2D9C13CF74 for ; Fri, 1 Mar 2024 18:48:07 +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=1709318889; cv=none; b=iqf105zcKidTYlVJfZtPM5wHbzAzeOHrJrnuSkqyZB2mFpWW9jci2GJ0zuW1polu6k8vylcAjsTzjKXHTxWzAYHRHHQ1j1KmD7pyQVPZuX3ssVsSCPsk+Tl7MfcbID7xZDqgTtoGykWJAeA67sxdhfz/w10jvCCx4oJV+uKG+1Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318889; c=relaxed/simple; bh=xBfxlNT0aaXEMy2J3656vmd02rMeN9x8F3Ypxz5k1Kk=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Aqgw3XUU0S0gvT0FffNO2T9ljOaj1OQ282GzlB7hgsaSrQlOd2iriTOv6A6e9xr9ALkz75dx2Llv3phYGswJKDd7lXDN+ByvOcwKvJeWrxLPKCBlrgW5Bp/Uf4ipMns9dCOl4zT4CH048jL1u3ua9r8Sd2A4sE5pOuSd5xZui9k= 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=Ahg71M3n; 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-dc746178515so3500327276.2 for ; Fri, 01 Mar 2024 10:48:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709318887; x=1709923687; 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=Ahg71M3n0naNsQXjrkAS1qZhpfiRGx9o2Y15Pl2hEOyNdnM6frSa6/BXytIQvfbDKM 2SJ8F+8TMQ5W2HdVnDzyk0b7A4xD36/aEx4NTITmSg1cakySxMxS57NtE4YlgG4ZUmBB VBgtlrPQc4NH3/XCT86vvbPJEWEoFDeRr0brz6vSwHXBY+C7ZLsOVK7l6UxN8FfGUiTI 4QDxqBcpdZaSkRM3eG5MiezkU5hmcJfPLSS+URNfA4ZGbsykjAmJxtTsQTHgzvO5Gxfl ovdr4Zk/NfzagBKQIDEkMcRwauO6agfPRUxqtv2ZS6A1p29hFUXs03IMnPlPKZDv4uQj Nx+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709318887; x=1709923687; 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=dccdzsx4zC4rBcUOp9SacZB020tAbzRcWVUG0nNp5Rnt7um/1y8tZJth2HWtIyGX7Q xhol+kD1u3Tqh6BWO94MBn5LplhZA3WQSsHRyOlBE2S+sQp92bVIpewC4EODob5ADxE/ EWL55A/LKO/ZZrgz7uu9dSm5kLGwxZI87QtyFo73a095DnON83UB9ZUsHHtOHI+J3PSf 7iyPaA8jFVjqHUaxfRVylxAHwqNLoGfoAbk8TSyMeUEvyTMXoVRvz1svSM8NqLKYj3BI p+iq62UWPUPc78KlKnqa6dsqT1nyCaIdS0EksVMOy++bF6durwMQJKDM9K09FKkD9KFR pJVg== X-Forwarded-Encrypted: i=1; AJvYcCUXtH0cXUcFu8eQWFfLNZOjnpoStFRUCmP5uOVrPzAHA2ACiHmEoVPDo2xrqDGjvpDqgtMKiDaqdyTCmd/s8Lma/HwyvpcfcCqmu/oZ X-Gm-Message-State: AOJu0YwmvUNOT1U5Row6h6Ef1H8iJMGE1TvA6+n36nne5YgxASoxybjz lPmpJdikip/jzOkwzE0P7wzNioCvRw9J2RiWwgPYmssvJ4X7BTKOT/RjiQakuHKnDqKIqyQWaM7 Ne9K7og== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a25:c782:0:b0:dcd:88e9:e508 with SMTP id w124-20020a25c782000000b00dcd88e9e508mr536559ybe.5.1709318887193; Fri, 01 Mar 2024 10:48:07 -0800 (PST) Date: Fri, 1 Mar 2024 10:47:34 -0800 In-Reply-To: <20240301184737.2660108-1-irogers@google.com> Message-Id: <20240301184737.2660108-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: <20240301184737.2660108-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 09/12] 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: 1792350903976847207 X-GMAIL-MSGID: 1792350903976847207 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 Fri Mar 1 18:47: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: 209023 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp83932dyc; Fri, 1 Mar 2024 10:50:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVYnJWx/q/VgQFzUPcs56SvzyKw6uooDm2iu0XcwTABkAQc7TCvlc0oNjepnPRYJeIVV+EafgWOacaOUOAW5OAUX6WaFg== X-Google-Smtp-Source: AGHT+IEE0yKQNbZ+72gPjjGAB5wzOd8XUvGNPyO5DiLgy+l0bCuVvm+NEVUDBKrBnAMWVBQg07VG X-Received: by 2002:a05:6808:2027:b0:3c1:d91f:d9aa with SMTP id q39-20020a056808202700b003c1d91fd9aamr1080741oiw.0.1709319039646; Fri, 01 Mar 2024 10:50:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319039; cv=pass; d=google.com; s=arc-20160816; b=ahtst8qMUYKOjvKlBpwADYAw/0u21tMcoLvtoybDjygukID8c8cqbEgLEEbZgQvt8E sZaavnYosoPxMxGFXsQXFse1R/a5ggWtPHYzdeZwr8/uq20pbqFs96xXhumTo3BrcTb/ RsxAYGKCuTGUrexQRvEyYoKfAs8LccOmy+oj9n1vUXhcixKNBpADVkOzk+ywamtBjChp oKLUyxlP5Bc6OEyojY+MtFPo1cPGHgKbAirT8XgP+aPJwD/IRSNXp7JSJ4Axst9drInp 0IsHbQxDCTqgy2JWj1h4gn81FCnXAfEo2ke09ojGpMFDpDrF60d21B5k1pcfXFgAfl0t C0mA== 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=LkApuQUH/L0R2pbhiLWd1yOt2VyLgVO082+kt9yCT+E=; b=Ccx8DXqwdnrWzZDw8vhWvR/Z9fvdgs5iWmBqKuTRXd7198ik7XXvSYsqGH/fm/Eie9 17MD7ND8YCHKVhBOP7tc+zlKdJ3X5oReWAh7HQNzDxQkOKDT1FAgjIfZ+dTFFfD1uaBP OGIbNksxJY8iTmAF4woKDnU8O44/C4Zff9oYXQSKlvs9swNMo+xWJYk+blh4ocdOq3jT U38Ll/z44cQbwYpnufft/lIhKQFpBy5GxnUAH1I4Skp2YYDfVgf3R8YGn0hBGvP0JjtG ckU+XHL3ZKLY5CPR+5awLetMDpVKVn3q2KDCkoPHX0W0yhbzJ738LSc79FnZjZw4oWmQ GFAw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MClWlq8y; 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-88947-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88947-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 c16-20020a63ef50000000b005e2c2fc5125si4137927pgk.249.2024.03.01.10.50.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:50:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88947-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=MClWlq8y; 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-88947-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88947-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 6CE85288495 for ; Fri, 1 Mar 2024 18:50:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2485F3D569; Fri, 1 Mar 2024 18:48:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MClWlq8y" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C2A93D0C2 for ; Fri, 1 Mar 2024 18:48:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318892; cv=none; b=T+b5Z3yhJyxH6BfXhes/4Tg9kbzhF8iOyn7JZ1CS3dHanFAgI8ptZIpCHfhWyyP+yGonASJxlpgEBsmS+maL0IvV1Lo1xES379xpZVCDqePgbffLuynGsZTnOKL+g6jSVH9B2ZQ0jHMhiub+Qo/6E/o90FmCScUv2mbk8rodPCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318892; c=relaxed/simple; bh=D/pwwQ6dXV1q6dCmwwHAP89kxtCQNH4Hvs09U28fH3I=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=PgearrSSBXhGNJLQCRgSAHKZ4oUU++YUxIsmC4HCaE5eU87pwQM/8a+Q6zvo8QCKxjQDmo6lzFuEvxGCxA+A+5hnDlVsnPmu0cuXvvL3cMDZL6/RkgK9ook0QGCFWFtxzjmrLW9a9KzN8sbEH+w+r60V/8WZNp3W8j2iTbL+I98= 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=MClWlq8y; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc6b269686aso3600771276.1 for ; Fri, 01 Mar 2024 10:48:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709318889; x=1709923689; 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=MClWlq8y/bQU6H1OOaWHyivNZhpJWu4W3rSpyHfIwhAkmT8lh1FUBHAKU4vaybXo1/ tKFkCLq65yFP0YRkyf1pPiYsE8hJD7aGOykAiFwQPPI5qsvmEUqvDgJvrQLrgJAathVJ DUNR3LaMMEvtLetZUkjCzol7Padal//yzJZrIba/jgxmhoj8raLKMpo225lUGsdVaQSL fOARpAfXiy9M4ZdI6bSfERHisEp7ulOQzO+IeA39AnpKlnnllerDk5GInJuiu3XOYYlv 1XxGv/9wg3vfh/HjklDQhH4yzRdk2gDQ2NBloeprx9js/ZND6GrcqftNtw7SNqAHdil4 7tgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709318889; x=1709923689; 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=pmI4mJWXur6aqOrBfRYu16qAXYLHuo7WkQ1D24kzxdNegeHjxvbtxEjxrwh+i+jL26 BFU2rJ9i049HxEOAv7xBiCLL15zQoLnmWmHTFJbg5OvHw+J7Uyx8NXB/M9IrchrWi/QY 8Syju+cU5hCl1tYKpOZ7S70TAfneEJYD9IoYGqwTajmgV61aSM7XuTSMDN8Xfjhpg7LP 3quSjeh/bjFG+SyJdxAvSS4bAE1WYEsJlvL5LcpCFsheh5lnPBSEuNHkaUXVmzJZH1cU y5bxjZkfsBOmkbMZw5P3uUTxSbvUNoPuqwgYifXNCL0JbudSTlmzLOzFLiNPtWXAUtYD ZuFQ== X-Forwarded-Encrypted: i=1; AJvYcCWKLznCd+7m4ojT0AjsWBcurXwK0T9xhZ8/Db1aa0QvGeGTKO3OrrhlGS9V47SfxZ96uC7QoqhJ/cSmboWuxqhLeGrNSERncUleB0nG X-Gm-Message-State: AOJu0YyOvPzeiZ8WH3PEbpa6hLGASi+nI+dAGUa/6mYytL/AMftgz2Br YzTtJA+o9T/EitsRx9emGOXttr/cr+UnVfoZGcBGuyLfOjNQqUCAh+rL5/VSjEf5xHN8jafehsf ZR9YQBA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:6902:1821:b0:dc7:9218:df3b with SMTP id cf33-20020a056902182100b00dc79218df3bmr100318ybb.10.1709318889581; Fri, 01 Mar 2024 10:48:09 -0800 (PST) Date: Fri, 1 Mar 2024 10:47:35 -0800 In-Reply-To: <20240301184737.2660108-1-irogers@google.com> Message-Id: <20240301184737.2660108-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: <20240301184737.2660108-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 10/12] 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: 1792350921635322699 X-GMAIL-MSGID: 1792350921635322699 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 Fri Mar 1 18:47: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: 209024 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp84084dyc; Fri, 1 Mar 2024 10:50:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWx6IjCufBq6x5ZYaya8ftbdo14c0mXdoiDf+TsHF5+jX7bkNrBq7ZA9tsAgdyJdev6CXTXhNX1Hncv7LbmkO1NCbrxbw== X-Google-Smtp-Source: AGHT+IFo5ZWEd1cUF1gA4ZTNFRHXkKJgbW7IlVECyNA3g7iqjF37IilWiIrQMPlPG13qX744od57 X-Received: by 2002:a17:906:4547:b0:a44:7cd8:fd34 with SMTP id s7-20020a170906454700b00a447cd8fd34mr1659288ejq.37.1709319056340; Fri, 01 Mar 2024 10:50:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319056; cv=pass; d=google.com; s=arc-20160816; b=WqlRjt5zAEz0Z+0G/CocPWfJdEE/n0IZ5wQWOXTb//52ZxVk80W96t67k05p2pY2sW Tk7e5vf2y064dBd5E73IhlyDAM2dd2T+goxFrMguBgx6Q3Vt+3jhO9Hcj6CYqQiAb3S7 7yuFL0wS/4Hs63v0YCIZSvdLtjoM6ely/VUyOLeH7Ss2A4MI2hiUw8dzLGj0bNZAmHBR 3WN25uRj6+aGrfgyZYPFJ1L7hj1EVgl/qHDEtTVDxxCXA5PBn5avfBp7av/PMEm631gB /K/pI8lBnQ2HFKfU7EsgGOg81SL/UCdKuKDoVejWAGEaGRvtr/cckL1qJqiSbGu+qSMK E6ug== 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=NfMeFYVZ5RGXtoZtwv9zK9oVr6w0xIC4q4msOKo6esc=; b=ALEdhmg6z3PvPoGA++GOB34iH1FJsGTIJQVBXpQpTcHU0e3vEmcKVdmGgG1D89K1lb +lewLdhn0D2F0xLFqjoVR+CoXFIVIu1deCHrjbEQ2OezJ9BzWtf35jUG6xh5g1fW6zFp lPSbubwL9qsTzOMhlb8ksDJVm1kSHKqJec8JRUiUT2gtyeTZVPhXrzXtnK0DwHpe6Xah u8EJb0hdnXoPBjO/C4fLOwUmO85KICHS6AylXKh4LjjssuFXlWPRM9+QcMu+QHrjA9qE sXUOp49QH8gMWG5tMQ1JPJtjLlTbDvzfT/uPA8I2ejPgJTkXrx3u88jXgrMdl1jXAbAr HapA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hGOARVnE; 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-88948-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88948-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m11-20020a170906234b00b00a3fc622b1a8si1583914eja.595.2024.03.01.10.50.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:50:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88948-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hGOARVnE; 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-88948-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88948-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 C9BEE1F26CB5 for ; Fri, 1 Mar 2024 18:50:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 673CD3D982; Fri, 1 Mar 2024 18:48:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hGOARVnE" 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 E5D2D3D3BB for ; Fri, 1 Mar 2024 18:48:12 +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=1709318894; cv=none; b=JODEdumDYj1/PSPdIDVOpsCuGTbDNL1yDpaToA1BMznlHDZhz3Y8cpWXSz5KjaNjTLqKXDAo6K9S/wkKwIIvJig3KziYnyv/LoXxjvznyNR6tjnXehsSFo4DHsm4cPfuOMigq7olJBk2/9M2rJIec07OE1xvMOTKOor3KakAaEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318894; c=relaxed/simple; bh=rdT/e0Jk04uz/hli1au/7w9zNoOK9Gsygo85Wow1ix4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=oA0ow3TPVaBMDeW1r6Y0UCCV9ehA5QX2haqX/lZ0fcg9vhcSR8BJ4AZ7NSnELybWzai3TrgxaHvN2xFSPeGcM2EqbgdlVHTw8ZiSFMCHvAnWyFusDGOXVLb1yZ8ew/Xj7PgvCIIzLawaqcD7onIiY3+hjc0kNAS2JEynJaVWSm0= 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=hGOARVnE; 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-6093f75fc81so43465157b3.1 for ; Fri, 01 Mar 2024 10:48:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709318892; x=1709923692; 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=hGOARVnEr5xFFtpzaNPWOObxPn2dAndkDKpQzVtrO+tAoB5NZ2q2KHAbuDwAS3cI23 aqar3Vsrzl2gRropVv0tX1HlfF1ykioTUjcLvzcXBx+kNPaNrJack3kyEaZPmMDuPbcP JatgyUP6ooa2qXNltuvHXbXLFla4ZOktfgJkhPkLV8wLecHSqx8MSoZHGYaiKmOdwOlB C2Vx73CmXSxvYLCEoRDmzbW72NeNc135uB0xYlYHbSS00SFSr79Tj0VIrrGFEz5oZdn9 lCHxg0FQtA9+oN4E12lC4NrwMRr61RjTNOoehp1+BJHaIlv2dL0h7p4Zla0qup36cXWo m3iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709318892; x=1709923692; 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=AwQUwDGzaqiGJoZ66v7UOic0CAcPHvqoTgqSS7B6mdVelH3vTvxKn3ur6DlV3dXOws Fy9z/gd8c+YI2QQVwencOi1Ngg0fUXTkA23N1ux3HuCLath6JS0dCbXWYX9lTFzqifTz esd7oHF1ZCVP+4k9IaFj9iqP12g74CNTC3AZ/g69v8DkwB/C2L5am47E7vnTpVqeKdu9 WGbwdGTCx06B135i0g9uqQAhPm7Vv9f+zyDZy22v9MsbXdCPZLO0/oQ0+aGdFybznpcV eQzCFVGkhEpy/OMhghOakPHzxaOIkYCBGvZD1kW7GoDccfFnyBAKyxhXKuuHLvAgwYWW SFUA== X-Forwarded-Encrypted: i=1; AJvYcCWleeCm/+FtKwZhM17LD2/rWOJyIO+5pIsTH0HAvpUnuksORMOD/tlV8qTjzY4HXuf+bXKlvyCo91jBkZh5sSwDRGIBFigm4bRn+DMp X-Gm-Message-State: AOJu0Yz7FtHvyqaKox7pVtpmEmPB673blbpp79kE8OAuIyRRAuzXq6zG Fr8yMMq/xtXARgTlTBuC81wY3WWOp5HFIsS2sihP7RDIFx7i1R+6gs5vbmqzCDTukT0IupkIdD0 AWKHAXg== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:690c:b15:b0:608:e4fc:aada with SMTP id cj21-20020a05690c0b1500b00608e4fcaadamr631228ywb.8.1709318892155; Fri, 01 Mar 2024 10:48:12 -0800 (PST) Date: Fri, 1 Mar 2024 10:47:36 -0800 In-Reply-To: <20240301184737.2660108-1-irogers@google.com> Message-Id: <20240301184737.2660108-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: <20240301184737.2660108-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 11/12] 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: 1792350938777804218 X-GMAIL-MSGID: 1792350938777804218 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 Fri Mar 1 18:47: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: 209027 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp85292dyc; Fri, 1 Mar 2024 10:53:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVIycS4uFRDarvLV5F85iWm6pMu4qleBYd+TqD7vqFlOOgGb+hWzR8wAJkw8ajoxsgWapA3a8T4vHI2BlPB/EI5hdaoyg== X-Google-Smtp-Source: AGHT+IHvCi8dPx6NMJKudAzqSzr8uowH0cHbVqdVwpC2UMGJArBwsSwhZ2nNbcRDeXAIoAAChoIm X-Received: by 2002:a05:6808:201f:b0:3c1:9456:e0c5 with SMTP id q31-20020a056808201f00b003c19456e0c5mr2839413oiw.58.1709319205624; Fri, 01 Mar 2024 10:53:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319205; cv=pass; d=google.com; s=arc-20160816; b=ZKJQbCqFyHKCTH9Y8/WFe3jhjAlPbjVC/zXVFAx0ZolLKfFLIsuzONPVDCYVBYWL0M UulU0H/7qFjpfllHaP2C2pjkH1pHO+JKE6oKUf1XLAW0pWvsYwRs9crupGlU7lIDiZ3U lqtoaujn569OSNInhqqpDQ7/6maDbBeyB8W/KRi2lQw0rVxDdzeILcStKMz1FIpCV1DX TzVuVEpXfMhUevEwWzJoyLNZ2AgFStZdf/MJIBp/e821vsU6AyF+BtuQjmQ+6SpcfQ99 2pdgW++kTUnghK2BCsHCDmGy8C1CxO0/sjYsFW83qytMTXCkteWjPASLhI/y9HYXXPo5 Kxzw== 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=q3Eu0u6jntl3WogKo1CH+a3D85EqIwRi4kSFGUOWvuI=; b=zg6qm0iVhvoh+ff7SSGqllPfnP/LE4Z8Ho8nWxcwIWmKWKMHitH8uMW1XUlG2dFk5g bsiMvNmqerziERqjDbT+7cdL4xD4xpdH/awboXRxsLRprHxFdA351exnspIWAbBZ5T52 T7PK41NEGUNRZVvU4ogTGWjX8bKMo6CQFE8QTd/U5lBTQ5deN54irrY8bImJkqCZdIJo aZtU9QXVr4WqbLYk42kue7MqKqayXsIM3MTZUECGDwZuhHmMUh5ZSw498Ct4BLtuPXPP 0Qzb2H0vZp2tcjxQO4u/VUuHxeiPAveqhE3HqGQjEkXePUEG+hbE0/p2Ai0aiJk/fTtq cGYw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KlnRSczW; 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-88949-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88949-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 d17-20020a631d11000000b005d8e3a18794si4012025pgd.474.2024.03.01.10.53.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:53:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88949-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=KlnRSczW; 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-88949-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88949-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 65FD52824FF for ; Fri, 1 Mar 2024 18:51:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2B9A3A294; Fri, 1 Mar 2024 18:48:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KlnRSczW" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F8AE3D56F for ; Fri, 1 Mar 2024 18:48:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318896; cv=none; b=U0xgfQzkqV5rn8jPoUSAgJgQXn3M/sdWpq7NCckgKAEXQcONzqpL12X4eS+o9viO0byJkdujVVaFyUuaNbOde3qsiSHdHkJqVifX2GBTReREscidZXLwm/UJ6ABbNebzgHKTQ6z6NFNqAB5afclU2snY3uUBMswtIMJFuPt+RKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318896; 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=oYclqJZucPE1xUSl/PcrLX7SAm5wm1XnvCCf4luEYdGqKZN0KOS5fFGJuLf3baLRcpJiDW746K415diQ7eG36J7xBWoNmnmm7xvBggE2uj8d8GN4Ch8BCw0yxwmsM/W5Dq+KyM8YGx943Gx5RmY/zxEz/FInDQD8YhtN3CXa69c= 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=KlnRSczW; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc743cc50a6so3228725276.2 for ; Fri, 01 Mar 2024 10:48:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709318894; x=1709923694; 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=KlnRSczWV9Ue3URYn+VSNWt8DdbUZdt9dwyGMTyN1+kV1Yo1nVLPyv1m3UBNaGtWSL Jf0FqqHVnjGRso4FzECrta+bQ08ZuuNamme9jE7cD8SHzDaLMeLkBo6SXQzFCVJcHA1K qcRxeNRmwoyUQBSLV7bJ1/Ns0nGdUxO4IaqXKApplrZsKmUYKXrL0U/Ay+IndTIb/ETy KQAf2pph9Yw3M7L78bXx8cWWF7kmddl8iRjB1BRf6IrBoMMiA/p6RRP3Nc+CfgOQ750r LlTUieFjno8lpOkPmio9hqF/3+OgKQ/4nQ6GTlLNDITXs+cfj8yS8++560kr/+zKWiFn Wlag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709318894; x=1709923694; 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=tfTq/H8tZFVyhfKY5xViPzAF+KRYSlc4sEWE6cCTk5PXIugvAzppRWaLdnG8KvtDRM 6UYiiI8P6LRWpiK/doBabDNp+/m7ODi2rkSirN/k4Fo09obH1O/eIX3U+ZtHPcwHSbqf ms5CMdNBTxlsImvFIGJZsSc4pakeiEFp70Z4liGKP7+EWAmsqmfLuCEgVjRq7FMbSFTT Ka+cRYSRyFp4a+voGhs3+RfgN6PiMNQPblOcPxJ7jIOERGmIm5eCAZYV2j0h8G3fsmAc pUlgQOTdyXEczur0njvY/PpQp55mTbwsIBhnFZFBVuL1YC6qq3Adx6//ByLYazkEAc8b okkA== X-Forwarded-Encrypted: i=1; AJvYcCVyx06jvWU/9wShrHIt1qjcTFvgzrOcj8z6aoURLKI1CHKnTVaQ77BODQjWjvTjg288ky/40BXB8p6+k4UECHyJvO7Uppc5A+zvBVaz X-Gm-Message-State: AOJu0YzHhmegCxkRh9T3dD5gMU8xchG/rPkqag18Q8Dbhc5rL6ad3Ngv 9w1GISGm4NePJeLSUh5pyKWOrVmi92ELVE/6fD7GmXOI6SrqHicyRinX/MENgtb8PX/h2YROk/8 pjnLolg== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:6902:1024:b0:dc2:5273:53f9 with SMTP id x4-20020a056902102400b00dc2527353f9mr93587ybt.1.1709318894486; Fri, 01 Mar 2024 10:48:14 -0800 (PST) Date: Fri, 1 Mar 2024 10:47:37 -0800 In-Reply-To: <20240301184737.2660108-1-irogers@google.com> Message-Id: <20240301184737.2660108-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: <20240301184737.2660108-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 12/12] 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: 1792351095242268465 X-GMAIL-MSGID: 1792351095242268465 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(),