From patchwork Thu Feb 29 00:15:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 208092 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp89226dyb; Wed, 28 Feb 2024 16:19:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVZQqdT70e2w/KKWPYSkaNkOPHIGNf4VAnXEzyAjzvrFsdGphv6/oD9PGVGnp9RaTyY0eJqw6adUSBmSx+Wl1RzO/NXIg== X-Google-Smtp-Source: AGHT+IGeXV09VadgA2/KD9AvA2uk9SlIWpjVw4fYMsuccX9xlPrQ/h+xIDUQ8HUNYLJpPDQ6kW2I X-Received: by 2002:a17:90a:fc94:b0:299:d17:a558 with SMTP id ci20-20020a17090afc9400b002990d17a558mr772066pjb.21.1709165982444; Wed, 28 Feb 2024 16:19:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165982; cv=pass; d=google.com; s=arc-20160816; b=m/jFU7xShrwZcKMgHbbMMB+IbMg4O4WR0+YZWAKJHirSuDGp1PcsdWHHgEwCbdnsJt 31iKcuygHC7/mZNk5O3Tof7iH49owDKtwy6Nvs4wAgO1d6SNJwXoa97DLhkLDPNajvmq VLwfRu7hsH1+2K2ctzvuExu40rIhGW2LPVd4YVEnyopV9HtanMNCFE5xuvMyt604qo+j a3bP3W0z2zfYSRtWU6SCzJFiLcbQePirxaHt5zYyeRerZVHXnXAum8V3rmVo2UCAnJnr /XT1B+SlXhKKfVyvnGJ3xzLWMjlaDCGU8UxcfsDU900WAlKvuljAIVgMG39tFz2rAeE9 1Pag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=1AfLiGExWQ7LJtXjB9I1zr2EY79Wd3x7GNxPRkAZ0FM=; fh=na3yS1F+mAXNreYMzaEexG2B8cj1IGBeTP5u3sNaqLY=; b=Kbo/rHPNkObVBQGdH/5jdl2txr6+FcjVAwGQxTdeIiGneZE25fG7HlzFHZG+x/Mcn3 WOeBN0qjXZJ9/3YGZceilLg0s52nTRT0mSrPxzv66nRwrpOfZH0X5vZnIF/hzKSYT1ZN Yn6lHSvtwTMk5JTswH7oqk0VGI6UB10lXBZI4Nr+7+bAMrlm6lRu3KsDeIEiPPtxoxOe 7ZgCtl8Iyz61aCYISQN48kYYyLAEDjBnkt6QyhsSx1I24K7huulT7XA6FPi4Gz2X+8fM Gl0Uq6ls1beFFS1jqK+rZUfkwEQu1sj3lPl6P/SsSSDHg1zxEvTzvDgNHm5YdVR+A0Mm snpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=CP2Sa1r7; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-85890-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85890-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id mh15-20020a17090b4acf00b0029af3b2b337si293860pjb.140.2024.02.28.16.19.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:19:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85890-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=CP2Sa1r7; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-85890-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85890-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 39DBFB222E9 for ; Thu, 29 Feb 2024 00:19:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 448EF1DFF8; Thu, 29 Feb 2024 00:16:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CP2Sa1r7" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0989D57334 for ; Thu, 29 Feb 2024 00:16:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165775; cv=none; b=sMS+EJTtHbX5lENdZvlEkHgDkka10rWpFIIfq+xjnqxUlXzn4fKHaGCs+lbh+YZjQu8BCEAYvCUdRU2kPJ5drQtdIYoXdxWP5oYuMHQrPmy69LqzxdYHa2jYyevoDIcVwNvbcQlJf3PjPZ1PExG7tqWNSeKvfnDqWWhCjrWkUco= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165775; c=relaxed/simple; bh=Ws6o7/tvtsGwdgLcPgbopHYfQtUw+y5EJAHJUjeoJ3s=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=UepjpZEZ92XPMSiu3WkiCISziQOg3XquYp5xlJ12fGnpLFJIkkQHquX9tiq6IqlRheyHi5t+rr9V9U7seKZ1MqPlCD0ZiehMX2RYxWQlwyv5JBw4Aw2mhYRWSoN5JvMuuojQ2F8xZCNo0G2/QGb4DQLm5b/+zbsBu5Nw9j8nOu4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=CP2Sa1r7; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6047fed0132so5918517b3.1 for ; Wed, 28 Feb 2024 16:16:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165773; x=1709770573; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=1AfLiGExWQ7LJtXjB9I1zr2EY79Wd3x7GNxPRkAZ0FM=; b=CP2Sa1r7lcFvXFJMyTk5Kw9+CFf19L0mh/gqK6+9aMM1xmTrj0cUXPR5Baz0d5Jmhc wVC+2LSYJZLKrdGehyKMhEaJnrFd3LmMIAZxRo+PGysxq+qR65nZsb8EpVsMnYwyCVTE YRy8fw79PWP8mfNzHNU1ispsc4mUFvw37ZWr+txh8GEbqX5uZBGSCMhuUa+3rmNu00bZ qyU8tvGNI8PlxhrQ2WDQ+1BKubH8wC0HGzizyO0Qg1fFucvF+sCulRNFwApewE0jl6wP +fFfWnFj706TPbidsdVEI4MT13CW+snNPT+eWocu2qkCTAm4VeqSQnS+ryEbpTwk7Ax9 l0DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165773; x=1709770573; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1AfLiGExWQ7LJtXjB9I1zr2EY79Wd3x7GNxPRkAZ0FM=; b=BcSa7FhTwamtvwgJpgI2w6T3nfzp6rwSskmgnZJTcydDc4NtxFxSZhWVSaBgvdZShx sJ25Qp9xr6VLDL68+4HG7NiUuev7IRVRs5eS47CHGLr7N1Kk2uimbQsHyHHrcjCcEcfD AJTshb/Dzg2dv0lJqLqtc0CU6/SLyeqauvEqjZl8ctWKgDwh8OGz5pdTt/PanZUMAjmG UXhuheNAAmYwBRI0Zo1AKzwQpg9mr7J0+3uYHtkor084rdgqGsls5alcM+CpqlQ0MzWO U/gjvQKe+Bh4f2/dbEzR2ltjJiO8Yp76lq5vCVnMilhwEmKzwufbbxhqCF7GGKru83/C K1eg== X-Forwarded-Encrypted: i=1; AJvYcCX6t8GszXRio441zZc8End3XeZkNiZqm4hlTiaWdRY5Jx5bVn/EhtENxWhJ2UflRSKDY2mXzR7ixdydFscB/aVkswmNZcrjt3Cq8yil X-Gm-Message-State: AOJu0Yz+rv77pyoS5K6x4xWABhskyI4xlp19RtAaKjUVF/Qpg9dYEU5W zlU3bQ+X55MvetDJXd4OROfejX27Hq42M6WDPTl8k/lJN6xhWyEe28BYfN+38qbWWLMNI/oP1Rc jfTiR0A== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a81:9acc:0:b0:608:398c:33bf with SMTP id r195-20020a819acc000000b00608398c33bfmr135323ywg.8.1709165773285; Wed, 28 Feb 2024 16:16:13 -0800 (PST) Date: Wed, 28 Feb 2024 16:15:37 -0800 In-Reply-To: <20240229001537.4158049-1-irogers@google.com> Message-Id: <20240229001537.4158049-14-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240229001537.4158049-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 13/13] perf jevents: Add cycles breakdown metric for AMD From: Ian Rogers To: Sandipan Das , Ravi Bangoria , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792190429040788576 X-GMAIL-MSGID: 1792190429040788576 Breakdown cycles to user, kernel and guest. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index 377ce413d051..2def2adf232e 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -572,6 +572,24 @@ def AmdUpc() -> Metric: return Metric("upc", "Micro-ops retired per core cycle (higher is better)", upc, "uops/cycle") + +def Cycles() -> MetricGroup: + cyc_k = Event("cycles:kHh") + cyc_g = Event("cycles:G") + cyc_u = Event("cycles:uH") + cyc = cyc_k + cyc_g + cyc_u + + return MetricGroup("cycles", [ + Metric("cycles_total", "Total number of cycles", cyc, "cycles"), + Metric("cycles_user", "User cycles as a percentage of all cycles", + d_ratio(cyc_u, cyc), "100%"), + Metric("cycles_kernel", "Kernel cycles as a percentage of all cycles", + d_ratio(cyc_k, cyc), "100%"), + Metric("cycles_guest", "Hypervisor guest cycles as a percentage of all cycles", + d_ratio(cyc_g, cyc), "100%"), + ], description = "cycles breakdown per privilege level (users, kernel, guest)") + + def Idle() -> Metric: cyc = Event("msr/mperf/") tsc = Event("msr/tsc/") @@ -628,6 +646,7 @@ all_metrics = MetricGroup("", [ AmdHwpf(), AmdSwpf(), AmdUpc(), + Cycles(), Idle(), Rapl(), UncoreL3(),