From patchwork Thu Feb 29 00:15:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208081 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp88140dyb; Wed, 28 Feb 2024 16:16:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUNaIX2H2U2MZLgJOGfqnOpczo31gRgkZ8VdLQG/r5UrmtU6fVJ/w4pulmRjYtUoikvnJo0ukRNzosB0WA82WZsWFBOkw== X-Google-Smtp-Source: AGHT+IHtV0zMFJcQGyEdONgxc0+oE6PsVrhWGITZKI7/Ru/ibitm6NqdrqNtExi7n7Y60x6JClAJ X-Received: by 2002:a50:858a:0:b0:565:a6a4:2ecc with SMTP id a10-20020a50858a000000b00565a6a42eccmr302149edh.2.1709165819078; Wed, 28 Feb 2024 16:16:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165819; cv=pass; d=google.com; s=arc-20160816; b=uC0KYh+4V9I6jOSyM+yrIdysrG3KPo9KWkCUlSlLo0volWIcZx/VjmAP/bi05ZEyKq uwszFpRkEU8wFH4PmQTrBhP/gjpKDqoWUaWQNjGgG6ZYukAMnJhCY642E4dwEnS2LzZG KE/9EAf+yyfMWxIhIsuj4x19NMm6m1MOghnqV/k7QMGc941q3WT2CU05T+pNj+eZXhwz 2X6juxeVvXzN6WaAqRh7MMhZihbL6GkXLdfjFaKS2BbvmCJB2KSqWX0zFgy3nFZwBjfG TW1gi+Hi8SkAiLLxTCA7mt5uttnm/WJaiiZZNT23Ixe420v353Jc1wMWRcfNGw3rz+/B hcUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=f7UsDzYt66DPsayZORzPPicQ8YRzeND3f/RE4XjTOWg=; fh=LO31QwenY26UWtwbR3uFkInFG8IW9+smokWseiRIH3w=; b=yebKgcJXGaVb5+uZtQ5oG0umAUUi+3syPOR2xV8+81RDi4/JxjeZQbTWGprltbSVq0 xpREaSw0dX/O9c52kyqD2z3AxcfudQ/z9RVc9zArA2d7bIxNxVZ4Ci5lwD2q0U43tjNe 8BK1RiIyczF+VfBUf9WGd87Yhi6/d/HNVGc3mo7I/cNQeOjv9j/7Za+HoLVARdzmP0Z9 kAJTrpC/FMjzC9rrS/2DrTktvaHq5h4mQ20SDh5ajPKB1U+ru/GRFopd5jklJHPJW09i ijCGo2vcdadGSp848P7ZbtCnrNHIE0Y3qj05DT6cpQ7zvyxcgsf36okXg6aU7FkHkQ2w gZZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Sh7eK20/"; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-85880-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85880-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f19-20020a0564021e9300b0056694dcef39si57207edf.137.2024.02.28.16.16.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:16:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85880-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Sh7eK20/"; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-85880-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85880-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4796A1F21AA5 for ; Thu, 29 Feb 2024 00:16:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE3E6374DD; Thu, 29 Feb 2024 00:15:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Sh7eK20/" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FC1A29D03 for ; Thu, 29 Feb 2024 00:15:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165752; cv=none; b=IR5GO0XU8OcG0hPSp5Sg7Q4MR++Qi6L8xsm15OW+9HY/heB1HDstZAk8z9yQLHhXlSuesUIeOFbMpSb5apkyRKymTIAq/oM7HjWqiSwK3whpdIhDFyLEQf/GRXJ2nCyo5Z3pRfJPH50MdjsHfMv9k9ttlhSDimNeLANrAvKr/1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165752; c=relaxed/simple; bh=yEm8gDDiOp2kaCb7bjt8yDfO5lzyLygQrwL/+bKOLd4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Tdj0xdsUtq0tqlrj6Yx8YPOmsy7aAjVYvJHfpfMMA/ds4SuiE4JAHT1caADXVxXbtS5GJKDLPkeoOoKqLJ9UA3cyrS8bm4vku3xnlOY4RsBzJXJC2dTe+xUaSahyX5jI6zd+4+5vJ5QXxtv4DKW+5wpuRCEXUJRewUIE+UuhZuo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Sh7eK20/; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6dbdcfd39so701672276.2 for ; Wed, 28 Feb 2024 16:15:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165750; x=1709770550; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=f7UsDzYt66DPsayZORzPPicQ8YRzeND3f/RE4XjTOWg=; b=Sh7eK20/wFBkujUG6QvGgVXr/rgoGkp1JkNvxePRmf5ZpfTVyLQ7O4g7KCYiuPpSfM x72SEs0osdODMzGjvoDa/USFldosOkBKy+tdXRQgDRcfOsxk+024K+73IepFNyU8tSkR a5DCxwhT+DJFhSkfg1FDZVHnvUI1xZGpLqT+mYgtvUaEFUEAIDSADXHj239fnlRM7nL/ n6ULHi+M+LCO+RddZTk3I6Clgy3IxlmizIOmw2/OGhQbBArW/lWOyalv+zqBu7hXMsmE FSaiagDkDbAoRBI3DYQpbjQN1RS+rCNl/XvRxTGOuf59L0qUL63n+s22rh73vqw55HaB EnVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165750; x=1709770550; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=f7UsDzYt66DPsayZORzPPicQ8YRzeND3f/RE4XjTOWg=; b=Sz2GsB+B27rZ3GkygBReV7pWq4VzrLoqFvEMARcef/rvNqSbXF1uaDMxn7c9Trbres /GFsFPbrSmtZU7/f6IvO4Nitv0wIp37kg68ruNXdJkcOaGtHcq3I01ZPwZfVgoIiDkx6 ORppUB1iz+4ZnlyRcvl71t9kuYy+FhoWgjVXjTxMPvafPpaB6sIyzPSaoCeQ1JCzHwCB wNXoAqvCJ+pVXVwWQ7FgKddx6wc1K2yxUSoRPs7OUeWO+kCvhygNzOvFWOkuA3IG1sJu /AJPlIVH1a9015cijR6KrHlmp8a+AcWKJ41hk9QcUujbo7/6uxUGUdW3Gk6ivVikabkx VFAw== X-Forwarded-Encrypted: i=1; AJvYcCVe8NrGvj7k3Herckg49fGqXpP6cqPw0SSI7S+vx5bdhhl2dIrW407hzBsiWCEYouOWZQyDT7HwYlwuQfbSlQopSrfPo6Sri0gJy33O X-Gm-Message-State: AOJu0Yxk1wdhHrlcaheC35GIvr+unaKLTmh20CC7LJ+/QO+sEvysJSS0 48mWY4E+V7z4k3/jF+uLDvzfEQDwxMyeMi9NTNcKzx/k6h0uEdNLf0FVfCnu1K/+aNNn6Uh2LtR ABKeq2w== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:723:b0:dc2:1f34:fac4 with SMTP id l3-20020a056902072300b00dc21f34fac4mr215253ybt.2.1709165749852; Wed, 28 Feb 2024 16:15:49 -0800 (PST) Date: Wed, 28 Feb 2024 16:15:27 -0800 In-Reply-To: <20240229001537.4158049-1-irogers@google.com> Message-Id: <20240229001537.4158049-4-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240229001537.4158049-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 03/13] perf jevents: Add upc metric for uops per cycle for AMD From: Ian Rogers To: Sandipan Das , Ravi Bangoria , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792190258122507446 X-GMAIL-MSGID: 1792190258122507446 The metric adjusts for whether or not SMT is on. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index fd3095cb5c1d..ce3d1535483a 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) from metric import (d_ratio, has_event, max, Event, JsonEncodeMetric, - JsonEncodeMetricGroupDescriptions, LoadEvents, Metric, - MetricGroup, Select) + JsonEncodeMetricGroupDescriptions, Literal, LoadEvents, + Metric, MetricGroup, Select) import argparse import json import math @@ -16,9 +16,17 @@ args = parser.parse_args() directory = f"{os.path.dirname(os.path.realpath(__file__))}/arch/x86/{args.model}/" LoadEvents(directory) -all_metrics = MetricGroup("",[]) - +zen_model = int(args.model[6:]) interval_sec = Event("duration_time") +cycles = Event("cycles") +# Number of CPU cycles scaled for SMT. +smt_cycles = Select(cycles / 2, Literal("#smt_on"), cycles) + +def AmdUpc() -> Metric: + ops = Event("ex_ret_ops", "ex_ret_cops") + upc = d_ratio(ops, smt_cycles) + return Metric("upc", "Micro-ops retired per core cycle (higher is better)", + upc, "uops/cycle") def Idle() -> Metric: cyc = Event("msr/mperf/") @@ -50,6 +58,7 @@ def Rapl() -> MetricGroup: description="Processor socket power consumption estimates") all_metrics = MetricGroup("", [ + AmdUpc(), Idle(), Rapl(), ])