Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp170047rbe; Wed, 28 Feb 2024 16:22:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVBLkfeFvt/LYQ7mpeoR7wBT1roNvtx5DK3/JxwpqhnspFjPYlWr68AkyACKvdxEr3qUMUrt8ktGonLA5NpfE5IdS1Tlnq3OIF3yJ2azQ== X-Google-Smtp-Source: AGHT+IH2NlCx+Z4qJAdA7t9r1IqjpMT6dSgF9aGedKiSX0aO6n4AKJOxCN3zTbo7XuoJKUgnhaZT X-Received: by 2002:ac8:7f8d:0:b0:42e:a06b:415c with SMTP id z13-20020ac87f8d000000b0042ea06b415cmr684864qtj.15.1709166164234; Wed, 28 Feb 2024 16:22:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166164; cv=pass; d=google.com; s=arc-20160816; b=0xLNbSV0oSZM/C8o+iRHUD1eUlGphRBWXGnx636QrFbVoNxLlaPyZG9VMkv1nbu4wn 7c83EWZkU3Crf55L3N3nb27nyvt1EQLhyJ2t5kB02RGjqQI7eumBA9UwOaSt7UaxkIvv 3sizk6+lh0ih9l0OTdaUbIX6SJ0sBS3DcXI35rfhh6vqvNUlEVcsh+Brwqi5vjhGDDkc yKdWiqLiLqfghSGWceMzn166GoBsW9i9TybIIuJKHMKrECg/3lzImWfOo2Z+N3vO4smv 3ptMyAWD32bsGypjFzGl6xJhFWXkGHHJf4AT1BtRCkNOJV/97rMic4npdk8BDXwFhnCF 2heg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=nEWMbeD73ltjKkx6wjteD4TdhZhnTqNw+z4QfFdR0Xg=; fh=yuf2r3hBiI/TLwPbI98an2/7NeMzGgDYowb8iY6Oies=; b=xumNecwYsiK/bkKNqSitMToEwlLNe6+magx+LfdP6Zm4eMUhE3EZ2b/3QVAFG6d63g AUEl5PX0s8VV998yqNkos2TGFfoUx7a6DsNp5ZNFAgHmdOIwXdZ3G+eig7vbKlny7wbe HXx1vKhT6UJ8dCBYuXS5Aam295EzPXPoBDygFdOiEZsPD+JHcEhh/yvrTEThsm5o7MVQ ZCTo+s0YgY0Pvb1sDBRcA8RF6XoBr+EnHyCQ2QRjEZafJjEVsn8V+8Fe+oUxVvO0l85Q sjrYpJc00nEV02NEpR76EuvWJ/fFajf7ZBSHTOhR0g6tDKjrf9MutWU6TMOMjgsbHhNe w1Gw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=cv5Mz9Xn; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-85906-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85906-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o10-20020ac872ca000000b0042e68e360fbsi300109qtp.152.2024.02.28.16.22.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:22:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85906-linux.lists.archive=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=cv5Mz9Xn; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-85906-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85906-linux.lists.archive=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 E745F1C215DF for ; Thu, 29 Feb 2024 00:22:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 704665C8E4; Thu, 29 Feb 2024 00:18:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cv5Mz9Xn" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F93D5A0EA for ; Thu, 29 Feb 2024 00:18:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165936; cv=none; b=nr3buHyCS7PahX1ulNkCVO9mRez3Qk3cxuYwII1Af3dC5OFHHCsNDEeDGWnse72oG0/3iviDFpWsaJ+rm5Ux6LlGpLWtf28L4cj8/afQOGHDo/JiPsiVL1ZKnrUBRoIGKZjwcO01bQv9eFFf2dfLwHExLhKnBfDI4BI5oIZzPCE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165936; c=relaxed/simple; bh=v5ABchTQpnOktYWaziSCuW1XX126+T9HD5NGgP4r64Q=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=qdQS8FdzDKpslGOQgDtGku5hvkaTf0mBxOU8wqioq0iCkOh1Ni6qn8q8/JVMMmEWw7PcKMDo6oKcwuH8RsrK1wpuubmTcQzOYZ3WJWvgxVRHlmyjaDmi8czFZWnI9sLYDdoAPbcsEnFLXAC9Y9DKI5bMvSd8da39Imvd/Hk0nj4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=cv5Mz9Xn; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6dbdcfd39so705879276.2 for ; Wed, 28 Feb 2024 16:18:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165934; x=1709770734; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=nEWMbeD73ltjKkx6wjteD4TdhZhnTqNw+z4QfFdR0Xg=; b=cv5Mz9Xn851PoHzwY/s7tDctOCA1uwhB84iMDCNAWRukfJB5/61FSTKs0BUFAZ+oYn ABhK2ZAqwsTETsRP36y66QwLGBTGGg3gZR2oJPucKHoXrqi9UFxf9iwWlcboB71s0gvx oOknQGF4vB6+boswVezJnRQfgnhoWuRYhDEXW+WfqZwFzT2UiJz3BZAQM4RlM1PuCjrB 0VkvGCCQKajdsCwsLDJ0t8IcBgwobZw2u6VQRhUnasHddcoh87xiEUZkAmEfKYpHE30Z zJoztG8o5CaO/Prq69rhZLP1IVEq/j4jmE2+Hvy4APEv1HnTbeHXBSMU6e2XtGiwN7J9 OWVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165934; x=1709770734; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nEWMbeD73ltjKkx6wjteD4TdhZhnTqNw+z4QfFdR0Xg=; b=es9CkG4z85dwXvImo463u8cjDdP5zoJdR0WIdDHeg/DNIVyOPXdpj3oQy0tX3+VJHD rVTOngv7X5rGwwUc/hKDs+ocWuJ6SvnCT2fJqyNsUF+/6dh+s8/r0qIXD2KS/QlCBLsc VwYcexe+MSQTzzbDz5CbPKM3D7ptt6BPzy5FDD1Q6K9SY2aMuT49U2yiMP7n2yEQ2hvV No9zQo1q9U4158KqCE5kOwJqS52VlARHZLT54aXrWuC9oNBrU7tpVBhto0Fe2NPhVgJ5 6tD/ZaHiLjqVOUgM3gqOUJdMtc92BiXdhFJuoDSNDt71c4X2Eb9GF3I+tsaaSwy+o9qJ N9ag== X-Forwarded-Encrypted: i=1; AJvYcCUz514+ssvJscIz/gCUTQIXhAzK8zMD2HZLvnl0114H8zqleWdzq4n5wH4J6a476OpEwzVa7d3mTsqeD9vQfpYRywMEH+dtARu0cKeD X-Gm-Message-State: AOJu0YwKNw0HQIfApvyeOEUd9oUxB0oERMOfxRIkrq3hzmEty0iTrVeJ kaTskZlihob0x2i09gwOb+HFr0R01Vh1ZheEkSQoKiBNxTuR7TqSkUgAGFWYhl/T3LttNpqfwKh cSmhTEQ== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a25:b225:0:b0:dcf:6b50:9bd7 with SMTP id i37-20020a25b225000000b00dcf6b509bd7mr214560ybj.7.1709165934246; Wed, 28 Feb 2024 16:18:54 -0800 (PST) Date: Wed, 28 Feb 2024 16:17:58 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-14-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240229001806.4158429-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 13/20] perf jevents: Add cycles breakdown metric for Intel From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Andi Kleen , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Stephane Eranian Content-Type: text/plain; charset="UTF-8" Breakdown cycles to user, kernel and guest. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index dae44d296861..fef40969a4b8 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -26,6 +26,23 @@ core_cycles = Event("CPU_CLK_UNHALTED.THREAD_P_ANY", smt_cycles = Select(core_cycles / 2, Literal("#smt_on"), core_cycles) +def Cycles() -> MetricGroup: + cyc_k = Event("cycles:kHh") + cyc_g = Event("cycles:G") + cyc_u = Event("cycles:uH") + cyc = cyc_k + cyc_g + cyc_u + + return MetricGroup("cycles", [ + Metric("cycles_total", "Total number of cycles", cyc, "cycles"), + Metric("cycles_user", "User cycles as a percentage of all cycles", + d_ratio(cyc_u, cyc), "100%"), + Metric("cycles_kernel", "Kernel cycles as a percentage of all cycles", + d_ratio(cyc_k, cyc), "100%"), + Metric("cycles_guest", "Hypervisor guest cycles as a percentage of all cycles", + d_ratio(cyc_g, cyc), "100%"), + ], description = "cycles breakdown per privilege level (users, kernel, guest)") + + def Idle() -> Metric: cyc = Event("msr/mperf/") tsc = Event("msr/tsc/") @@ -770,6 +787,7 @@ def IntelLdSt() -> Optional[MetricGroup]: all_metrics = MetricGroup("", [ + Cycles(), Idle(), Rapl(), Smi(), -- 2.44.0.278.ge034bb2e1d-goog