From patchwork Fri Mar 1 18:55:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209030 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp87062dyc; Fri, 1 Mar 2024 10:56:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVHPgoz+1kSWgavsDSjnWoLnDMxbj+PONG2KZJj1dV+3WsyhQAP8ZrSkpC+yoyg9Xc4Oh5HhrhdVYHyuG2KKJB6XJDsGw== X-Google-Smtp-Source: AGHT+IE6iTZUZz0qteuq10Fqt8h8RvCnwseRVSfTZN2ZguHKudzlYXgC6Q51vKbd6eK9qAyKFdIn X-Received: by 2002:a05:622a:1105:b0:42e:d766:4fd0 with SMTP id e5-20020a05622a110500b0042ed7664fd0mr306353qty.29.1709319412766; Fri, 01 Mar 2024 10:56:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319412; cv=pass; d=google.com; s=arc-20160816; b=P/AH/aY8dtexzhzIrxu+Lchqa3DK+rj0ZnVwnkjv52A3/VZieLwe+5jLpgEeJqh4IS bhnng4KELZ3vTew1xUbi3MjoE7XmJlKl0EiAHHj1dI1EnE9LQ3T2Q/NK9LssvmqeZM42 Sn7GbFa1dS1ox7SORMbe5kUj1a0vUViJ8l9xFBoglLWBPy8ET15oTyyz0syLRwZMKTPl ZGVSS06usaPmDZ09UYMnC5to5ZbCbTr+MkKW6hd80GDXEnGUe1eYlCb9v7zEUvrUcJuL B7ejcJqO+L02JPqu3zBxH3TlsJS8/aIsLYNfvvX95JgFQV5Q26FTQLpsrv0EXL0r8d+z 1p6A== 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=h3PxAWhsu0Wk1JCVDmtXtAqqbWoqISlhy4eOUAXnDEI=; fh=+sbKbCNwmO2654c4LwnT1erJIp5G/w3Yl7kVi6WP6g4=; b=xt5k7RONDufRnw3Y9ybQ8vbNp4ESFOcbUDRvcWYABsy8A/uHbbFitxMK7VuLNXqHVk Q7dSXqrKEwUD2hOkDtVLjh299bQ4439AM69qCJp0MjEHL8Y6QS0dZdXf93oAtZocqj/i tH7h19rNRdaVQJIn3XJJ6ehbQcQLnpp51P8G3Ds4HbrOTMwylN3dX/UvxlgL777Jk1rj EbAS1zzjXzzqbHdhRP2vdid5+RB2BX4STdX66FTTvCJDPqhzA5len0kdaIs4eFCEoCaq We5kgYIl4NyP1aNmFEcUviHIleZAXeQOyxpGkS8+oZFrre0+oHXKIgI1bzXzzpwyYTvs N0uw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RzbY4fVJ; 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-88959-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88959-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 i22-20020ac84f56000000b0042e7f4cd1acsi3812762qtw.700.2024.03.01.10.56.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:56:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88959-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=RzbY4fVJ; 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-88959-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88959-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 749451C219C1 for ; Fri, 1 Mar 2024 18:56:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58A053B19D; Fri, 1 Mar 2024 18:56:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RzbY4fVJ" 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 C610B39AF6 for ; Fri, 1 Mar 2024 18:56:16 +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=1709319378; cv=none; b=KBszHy4O87rUEuC0tfFsAOTrJywBT6iVCAv25MUrtQmLXvLS/Sg3XomRNwSKyAd0sgW7lVo9aV0JwfNlPKbKdMhNgw2RYQax0RxuBFbZ0cgwxMOAs5CT2uMJFYw/QDD8pgrabviJ3l7fHORl+dnMUwsgivEU+/pfAZdY8u0/OFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319378; c=relaxed/simple; bh=eVUKJulxTaDZWA+5YoZDb5UoIVwFCiPRNSmcWb0uoWM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Vd8yGnSn3f1sAoZd0pRnkbFbdy1LsyFRAjC50JP8LiVb/5UYSQjKID5PXCxjIg1mkaL252HrNuJ4zkx3EAA9dF9Q8Q5OtuxGGMK8RQ8VHOsfrcPPeQPR+0btKnDa1jM+sP7PZeh14t81GPh/EM0EUxKvn8qBMziSBkxmyQnv8uI= 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=RzbY4fVJ; 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-608852fc324so36524647b3.2 for ; Fri, 01 Mar 2024 10:56:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319376; x=1709924176; 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=h3PxAWhsu0Wk1JCVDmtXtAqqbWoqISlhy4eOUAXnDEI=; b=RzbY4fVJ7zUHUvVgAM/nw25wC+77DsGSmfgkChOQLUetdOw/nCv+yAEMMdF/yAt72l nbGePWgeSbzdSSJ73Tzz3OLZI6XNbwMTGXR3z1MS7fsYPovCgfPmWNEEMT+rLdNj4jka nSM9POwdiNaevK3qiVHALU/FMsMJp0DZDd1djusC8vM6xwqAxuv8tdhQlZos6iyRmcmR khjwT6uqvm8ksWtd48NQgRuUgQ7hB385GI/WvWTmhLhkE0jaSfHTGZuz12vachSrsbqc mOoALSkyeROFmJYsRk9Zmm8IEwf9NCxWzEg5QbezZ1ZiuWPR7A8J5j9jdyqKs5kd/TPn oO1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319376; x=1709924176; 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=h3PxAWhsu0Wk1JCVDmtXtAqqbWoqISlhy4eOUAXnDEI=; b=sr5EYUsnnOMN1hysx1ThipjRh41wuKn+Irs/A3LFj4xgxIdUSPq/fOwQspkIjr313e ikYvu9F+4T6BK9DOlFtTdYcEPXtO/pGvBvuZkWNwIIFwKoaqz4P6tc+IBGW2zij45eUW HCcgEO6cwKEBfXFIvAujs5bqqH/NRtX++1ad20eDQUPzhgpOIONOgG3wTpiDz6trxkCc 2HDwLxilu4MNwqO8TqdI7CGbPA9kWYmYVGPDkzg8mX1Lxa+ClNlsKbWeMh7etkQ0KkPE gzLvN9U5opVNgxyCiAxIlFVFvQKv9lSDh1PihO8CFqEH1AVE3ts9oMgG/NoTZ+PkZhv7 //Nw== X-Forwarded-Encrypted: i=1; AJvYcCXboPYJAVSZKc8X5jFa+uW6/IKkad1wnEVYBdRNe8PN0wta4xf9zexwWSR72SiJJxqhMP8Z8Euz9+ItUZYSqOwHjGODKzSWSkXnf4O8 X-Gm-Message-State: AOJu0YyNMwFbhns4oId1DByGz99S7YnIDD0JbFbsTj/rSXa6+mTFuhwA feSqnDbULM0b5eBTS/KkdXRFndPbmHxla38Mt9SqEjBRGBkbPFPJH4QMtNPBOBnBngY/cNqppJB bcE/3Gg== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:6902:724:b0:dcc:5a91:aee9 with SMTP id l4-20020a056902072400b00dcc5a91aee9mr537791ybt.7.1709319375833; Fri, 01 Mar 2024 10:56:15 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:40 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-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: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 01/20] perf jevents: Add RAPL metrics for all Intel models From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351312683760342 X-GMAIL-MSGID: 1792351312683760342 Add a 'cpu_power' metric group that computes the power consumption from RAPL events if they are present. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 45 ++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 4fbb31c9eccd..7704c170a7db 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_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="Intel perf json generator") @@ -14,7 +15,45 @@ args = parser.parse_args() directory = f"{os.path.dirname(os.path.realpath(__file__))}/arch/x86/{args.model}/" LoadEvents(directory) -all_metrics = MetricGroup("",[]) +interval_sec = Event("duration_time") + +def Rapl() -> MetricGroup: + """Processor power consumption estimate. + + Use events from the running average power limit (RAPL) driver. + """ + # Watts = joules/second + pkg = Event("power/energy\-pkg/") + cond_pkg = Select(pkg, has_event(pkg), math.nan) + cores = Event("power/energy\-cores/") + cond_cores = Select(cores, has_event(cores), math.nan) + ram = Event("power/energy\-ram/") + cond_ram = Select(ram, has_event(ram), math.nan) + gpu = Event("power/energy\-gpu/") + cond_gpu = Select(gpu, has_event(gpu), math.nan) + psys = Event("power/energy\-psys/") + cond_psys = Select(psys, has_event(psys), math.nan) + scale = 2.3283064365386962890625e-10 + metrics = [ + Metric("cpu_power_pkg", "", + d_ratio(cond_pkg * scale, interval_sec), "Watts"), + Metric("cpu_power_cores", "", + d_ratio(cond_cores * scale, interval_sec), "Watts"), + Metric("cpu_power_ram", "", + d_ratio(cond_ram * scale, interval_sec), "Watts"), + Metric("cpu_power_gpu", "", + d_ratio(cond_gpu * scale, interval_sec), "Watts"), + Metric("cpu_power_psys", "", + d_ratio(cond_psys * scale, interval_sec), "Watts"), + ] + + return MetricGroup("cpu_power", metrics, + description="Running Average Power Limit (RAPL) power consumption estimates") + + +all_metrics = MetricGroup("", [ + Rapl(), +]) if args.metricgroups: print(JsonEncodeMetricGroupDescriptions(all_metrics)) From patchwork Fri Mar 1 18:55:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209031 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp87196dyc; Fri, 1 Mar 2024 10:57:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCURLju/h0CMaq5g1E0VV2RIMKAwoQ4sY70SxldKNRbR7crWb8Nuv2VHI1gt94MjDCrv9mZwGIEWXS325R94FYck/Rvc2A== X-Google-Smtp-Source: AGHT+IEu9cTX9b8Dsi68ojfiSwQMJPsKDFCdqzK19zUXB7O2+IT8xP9sEumm6C11VbNqKVm4d8Fj X-Received: by 2002:aa7:dd09:0:b0:566:d450:a362 with SMTP id i9-20020aa7dd09000000b00566d450a362mr1757058edv.24.1709319427791; Fri, 01 Mar 2024 10:57:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319427; cv=pass; d=google.com; s=arc-20160816; b=JPEnhuXMdXsTjQvMhb+4mmNoExvuJFcVhOqlYkO4V/eG/63GGyS0nVnqTi9VWJIdaT yKstSyji2usJyfZdfUT62cK+Jbi9dQIn75hdxzK19sYFr3Fb+osZBoT7KXdXPNvxvPwR r8a8u1kAyLVdOOFMFzAMwhSOX9VCTrcPSifh8976D5oLBU+ivShgMITUcEdgOJbX6gwE HG9Wr3XnI37ZiG3DaVi4eXcyBXx0tiJnE9L9RoS0NxffC3Rq8VjlpMEDX+e+PfhFp5rA RWz2M9vRiJxj1h+PePGmfvGZxATrG2gyLunBp1RDxxiU9LMrZ7kVXsx/dK8FaO25eRJg IHuQ== 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=GKFU1+MHZzi/z8CBZByS67OdqLWVZjwrZ1eTBs4nZzo=; fh=MPlJA1F4olXGbQrKYh4eCKo7mv0KbT183amjI+jYV78=; b=CkL1zcEW/rlRVib5BR8agTWLBB3DWO+oWT02RMtNOpbClih8FDSIyMsteU71/YMisw W3q1OePZLqhYEixX2tvvgf8jGAM5POVSVXl49itoXXJ58RJ8dcuxRN1Z1uyIOPNAgfP7 ysb/EDbZ5UekkBlyQu/nJTQAjC+3Bvs22ROLUWuqkk1CrLKBJT+lecM4meCZwE1T8XqY QFgVGkjJNRPZeAidaHCazTtkrnzN1wGIhSMSfg0lbtF023Wtm/FdBOYN5Ps69QZcN0y1 pzZl1RiVV1fNYdFNTin5E3RcKJbg0tBze8B6Css2Wf+AHPbFaeTI3S1hQrT9kgm4XC/u Mevg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=td1ebTcd; 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-88960-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88960-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 q15-20020a056402518f00b00565e08477b6si1792684edd.139.2024.03.01.10.57.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:57:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88960-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=td1ebTcd; 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-88960-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88960-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 614101F21AB9 for ; Fri, 1 Mar 2024 18:57:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E1473B199; Fri, 1 Mar 2024 18:56:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="td1ebTcd" 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 DAE5C3A1D7 for ; Fri, 1 Mar 2024 18:56:18 +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=1709319380; cv=none; b=bGSBZft0MoeYWWMWtFYiJJklmB4qnsEpoWGcMBjfYdcAQKy4XGPx14ftK7HnMFy11p9ZujiLwnpBOFRQsEE8X3tbypCiOWPZz/NtflXanvKXNucdmBrVsNw3DQupt6BS/t56x/jmcRyGCvq+e1pWVpX2lsfuxtRqAcivI2OvJ3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319380; c=relaxed/simple; bh=E0c1iJm+nhJFbSwna0W+hQvedFVJgQU0OfqpGYXtacY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=QtB+kvDger/oaHMA1RniFf27aa9p0JyTsybzvwaSiPVN93Y/ddk1vkbT3kIPcCkF5yckwmuT8n0S/FcKYf0S0t6hprOvwvsy6j3QvDaQNpb6BrfnFeiQS0buU3HZgfPoVXFSyqkaIqJQ+s1tpp9NF2EMPzuXTxBXLFhJe1DIFl8= 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=td1ebTcd; 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-608852fc324so36525067b3.2 for ; Fri, 01 Mar 2024 10:56:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319378; x=1709924178; 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=GKFU1+MHZzi/z8CBZByS67OdqLWVZjwrZ1eTBs4nZzo=; b=td1ebTcdZk28aPBKMd1V2gQC/JTGS0MXy7/ALgwf4r6Jt0yQPthZHqgitofER2UscW ng9fLcoJYkgeNahsctRIT2JrwiGzWgS9AIktuL49BMGjQrc4srGUEkD48qNsCDshyYHI Hm6cDJYVue5uRjdhoIVp7p6NEi0pjCdiTbzWv7gyR0XYKE+Sga7g42ALdRUwjX4r6sjU Barr+Fs6t6hR/O3N2Nc2UOenVlEAMXbfRKk0P/N8Ig9J6ZKOa9rYTIXAtU8FRvH+/kQ2 eCC//QJ57/k5qC8BhsIXpETi/xIRFibFd1PP9NahV5uFSGCE0V1uuYBh6I6aQh43jHKG iURg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319378; x=1709924178; 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=GKFU1+MHZzi/z8CBZByS67OdqLWVZjwrZ1eTBs4nZzo=; b=dGxtsn+G5aKZn/coaZQB19kWlWu9zf5b4N2LJfXEYyYXZVOu0kikL4eMTXRq6u0DRg CqE1T5pHdUw6Mg8+X5vyIEx+j3MLw18QBKGZKdTa8njoIHik1Ty2mslq6XYhzyYeT7L3 HN0YcCv4BWd5hPE+f5KCtqgA8nb072CkRd5Lrz7o1kz+pvwCqk9/Ai23eqOAkDGn74SL pLfxhrWMOzx8ivtNc70C6XLhxV+4kR4FtezI8zeV6x9tW3hzbORhP4ik+sKChtrdD5tv ldcjR3MOm06yCmU6v/Gcvo+5+aklIklZZylHsJEClvZbeyU6SjY/Mgnxk82Wh6uGqR5K M6/A== X-Forwarded-Encrypted: i=1; AJvYcCViwOadC7bryDkC48aR7OHGftPVPaBBQW7raMPRaCFEJGtehaiwhyt69VimyxR123NQl+BizAG7Y+24/XaUUxuwme7bxEF0Y3HsBT0M X-Gm-Message-State: AOJu0YyaS9IAOnKUsxvAKG7ZsaOPZQ7c9eAwLcHuhdlmMuhou1K1+Vyn 50YCCenw5j4D0EBtOq94rKgM1TctDufD+qnktCkGE4387t8/a9S4haFq6t3179elKmaSkTu2cMS ejlL+Zg== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:6902:1004:b0:dc2:3441:897f with SMTP id w4-20020a056902100400b00dc23441897fmr538112ybt.6.1709319377920; Fri, 01 Mar 2024 10:56:17 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:41 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-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: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 02/20] perf jevents: Add idle metric for Intel models From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351328240327846 X-GMAIL-MSGID: 1792351328240327846 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/intel_metrics.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 7704c170a7db..2622d4e5ff54 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_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 @@ -17,6 +18,16 @@ LoadEvents(directory) 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 power consumption estimate. @@ -52,6 +63,7 @@ def Rapl() -> MetricGroup: all_metrics = MetricGroup("", [ + Idle(), Rapl(), ]) From patchwork Fri Mar 1 18:55:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209032 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp87310dyc; Fri, 1 Mar 2024 10:57:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUxR1jw48VxFcbH6mtfNncMz4PkdDRwchr2u5PNlumB+Dr9AqqJCDjLjN93oWjr+7AfBsdMk4mGE58pNnDIHpZbjjj1zQ== X-Google-Smtp-Source: AGHT+IFQzCyl574eFPCbqrBsH+sOQ+DwC7t/lnBqN/1xf5E7PK/hcsNusY9Lf7Wu1g4cHp5z0cqF X-Received: by 2002:a17:902:da8f:b0:1dc:d515:79cb with SMTP id j15-20020a170902da8f00b001dcd51579cbmr3380128plx.3.1709319440438; Fri, 01 Mar 2024 10:57:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319440; cv=pass; d=google.com; s=arc-20160816; b=IpvHePR2xb/QO2u/hu/AW7ehPp0FuthmBarn4cctzmGI/vfmN70wFJPExGFI9Zs5Ea P0neK9UaR7qDt64BDI7ZJDrddpTmP7dzgtEvWpZNwLATSlEoNikCSdkrxSNmfsMLCU35 O45IdOo88wSw5TSSx5uol85QWYkmCv3OturF3uSq8ktRKP/5Un+5qLMKTyN2IIVMyLfu B5IWQorBoXoNo1I1uqaNbYWb5WfXyDfhfncb45ZJElsIhASNmfoZK3kIMlXlU7CZ9bc3 IdCpmrxp2WU7/laCcnMrtDmasHgTdYWpk9lgd6u8JuWjbScSn3wSqgZSmpZfJuGQQH56 Uy0A== 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=RK+fLoseEVnt8AotaCi+y9ZDN/WJ8lwPCKN8c7HO7+s=; fh=oNTxpT0EC3TDCetjWhZdNbWp31EjRxcHtTn6FtUnU+g=; b=fmdpi0nevCHr9NJcAXLeeWsaSAHYUaRk4O7tCkDFupW+Hhs1BJJ2OXLiNzKlQbQxOM ubODTOlVrafHsPSQsHMJG6W+aGkL8hrP4rRWrOCcwRl+L9HNk+0TiAiSlDwVEwQW5ocA 2X82zGIi8pUaxWEHl9Hji1HiZJb/MKyPlgTw2TDaCuzFhMBHVOrZy8F/w0QXLsdtiYS1 TPA6IEtbQaPIkqyemMvaMoVZ8NrWPJwN7hdUVcqv9uDwwgnBzpko3dpV6za4+Inj0ZO4 EKPzbcqzlJ2Jy0Awr+bAADedGUhCRAJGvrWZwkOL90G4HQQenKhxTLKiMrZyyEf7piCu Xt5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=12dW9lnK; 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-88961-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88961-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 u9-20020a17090282c900b001dbb13a5b14si3772660plz.622.2024.03.01.10.57.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:57:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88961-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=12dW9lnK; 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-88961-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88961-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 27A242833C4 for ; Fri, 1 Mar 2024 18:57:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9ADC13BB2A; Fri, 1 Mar 2024 18:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="12dW9lnK" 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 4AF2A3B198 for ; Fri, 1 Mar 2024 18:56:21 +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=1709319382; cv=none; b=fKFirw9GRpe63iZfh+yJ8M6Ao881MKy+8FbYpkL4i64pHoaoYPQu8O1a+Hzwj1uDWEn9mIM8TTYgCKpzxArhVA121qGi1uvjZSudMusmhk1pq2dLZaG8SHanMJLH2IqS9y8kiF235G9z/T3UD5nVjMwoupeDvvcHFU0WsyCRGxA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319382; c=relaxed/simple; bh=8oHWhZlncmxDfpV4axl6yS7DtQzS0saV/qldweLxMzo=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=WBm2EoM7JGPlXJvs+uXdnTpwS8xhSnwAJf1dvbGdcvGcvGL6LHfqyPVQm9esui81oPGbQegnSYrX8NicOOd2pC+jHJAKxWo/h50CZWJxSXn99wuw+5CV8T7xG95pz34dfjv2hAs4frnGN6O2y6BxOhW9j0j9XIZSdyibiR+746M= 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=12dW9lnK; 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-dcd1779adbeso4549141276.3 for ; Fri, 01 Mar 2024 10:56:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319380; x=1709924180; 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=RK+fLoseEVnt8AotaCi+y9ZDN/WJ8lwPCKN8c7HO7+s=; b=12dW9lnKkgDoBGQjOHPeh+9G6SQr8fVUDHqSyoSTIddpRuQxRxtCA24wQl8+LGcxQ6 NE8hKTKrwTZQqXr8yubxvKRZzZ/P4n1TW2B/Fgzr15bSMu25nQslO8PD6Hauya+YT6mE TIH0VQ56QfEi8EwOTPqSgAjZJ8O5eFj29VwhENAyOwyluMYY0u18qFBPc3yz3uVt8aN7 okdwnRNxGBDxPyMdqmo1RnTxfvcHwJBLdC3x1wPt8tFzn7dE7C0jng7/me/rkkP9tP5d kNwib/h3N/ZTsQIOzlITB1TK3s9kli3+9CR0lG2Ds1InbUFjuSfxM/OU4uCRg4BxW+dt 9b0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319380; x=1709924180; 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=RK+fLoseEVnt8AotaCi+y9ZDN/WJ8lwPCKN8c7HO7+s=; b=AzfXrEOYTr9IkvmqPU5zBWgVMtRsL1iuEQxoHzWflht3w62rfcIq5y0QO08VlUVgyQ 8XsjJIa21Jgq1Bmgcvs2ABUEQPo+2wPpsHuBVraWyqtLjYHbJvVLg+Vp6KC2yhd+W2oV x7GtPzYPhejl11YwwsjUf+48fGFZvMscrC46TJvNC2NlMnYU4WwFe+UF8IE3FCBYzjdT 2/STbSzlPNxPK9vGmEo6OMKFrwETl0Mh3xqFZ53VrxUcHjZ2BCYm1M/onofX23rsFC0z IeTaq2CqOlqZa0curNgDDEerfvnclZWnROgMGS3nwHhn2XKF9lfgmpw9Sf6xF39Mc1xl TUcA== X-Forwarded-Encrypted: i=1; AJvYcCXhUUvhJzoAzaIg5s+gbpdaepI2y0VWusdIBZchA5dZg5QYGmx+X3V2Gjx2K8xX1deJIFz26HGADWo8k03weP97nrmwUTdTSuql9zue X-Gm-Message-State: AOJu0YwF91n1nOElvVY2vN6H8SMv/CDowZVIa6cZDG2LAx++nujapQQP +6R5J2j1Fcr2FZCPOrNBTSmvYPoNnXqLgeeh9K3jhhtBIDDrCNySIqRnwAFM2r1CkNyQ2ajEI3x HknhB+g== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:6902:100d:b0:dc6:cd85:bcd7 with SMTP id w13-20020a056902100d00b00dc6cd85bcd7mr572697ybt.3.1709319380436; Fri, 01 Mar 2024 10:56:20 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:42 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-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: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 03/20] perf jevents: Add smi metric group for Intel models From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351341946023170 X-GMAIL-MSGID: 1792351341946023170 Allow duplicated metric to be dropped from json files. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 2622d4e5ff54..81879e68da96 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -2,7 +2,7 @@ # 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) + MetricGroup, MetricRef, Select) import argparse import json import math @@ -62,9 +62,28 @@ def Rapl() -> MetricGroup: description="Running Average Power Limit (RAPL) power consumption estimates") +def Smi() -> MetricGroup: + aperf = Event('msr/aperf/') + cycles = Event('cycles') + smi_num = Event('msr/smi/') + smi_cycles = Select(Select((aperf - cycles) / aperf, smi_num > 0, 0), + has_event(aperf), + 0) + return MetricGroup('smi', [ + Metric('smi_num', 'Number of SMI interrupts.', + Select(smi_num, has_event(smi_num), 0), 'SMI#'), + # Note, the smi_cycles "Event" is really a reference to the metric. + Metric('smi_cycles', + 'Percentage of cycles spent in System Management Interrupts. ' + 'Requires /sys/devices/cpu/freeze_on_smi to be 1.', + smi_cycles, '100%', threshold=(MetricRef('smi_cycles') > 0.10)) + ], description = 'System Management Interrupt metrics') + + all_metrics = MetricGroup("", [ Idle(), Rapl(), + Smi(), ]) if args.metricgroups: From patchwork Fri Mar 1 18:55:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209033 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp87487dyc; Fri, 1 Mar 2024 10:57:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVp3Y7N3qclUngkcI2iwbA5+nH5qZG2gkhcvQm39P91C1ihdv9QkDNHcJmmy96Yt+EPgW/UpEYNxRaHTecJpmwG6yJkhg== X-Google-Smtp-Source: AGHT+IFCakyJ5uogwFSuc52CeLiSaWD+uRgosHU5YqVt5IlSMVs/JxLPovk96U9nucdYB7WebMtM X-Received: by 2002:a17:906:3b81:b0:a43:86f3:af37 with SMTP id u1-20020a1709063b8100b00a4386f3af37mr1991004ejf.53.1709319463246; Fri, 01 Mar 2024 10:57:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319463; cv=pass; d=google.com; s=arc-20160816; b=gsGqAy2wXQkn54Q+arTmvLkXGt64AqPiIhZGJ5dhq9H84Jjim3nnwPwpcJnouh3zPX Q4+qn3NuGgrblQTvh9KvfPoiY3hlF5nQZGw7uyPFkaFc8mFb9zNRlhXqu1L1TI1S6mHd iewnb6fCsRTsGyxyizPfL4Px/qnRIgbhb1+tHQJH/7JBYrBmHYmPxqLxl1iP1Uv+6GmR DnlIIByRBoTtRBBiI3wZHT2uIKnw6bhTr666Ro6PsJJofPYwl/yA/rfuWhLn35YetSAL KH0Mjxo88NtUFtN6LhsWsVpEelDrbnrNMkp0ytuJfemQguy4Jxkb9WDybkYko4FK823j GVPw== 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=L68TwYEEJpFcSpLsVXn02dHEJdoYMq6WnWpBdckYRf8=; fh=Eltj0JGfwZITDURiNecPUXXqOAZGFb2fFTZsGOtec7g=; b=YxaFjVwz40T0JjEcYDtc9cCwNQwIkv5qOn5m4qNUNEWPOETh6naBY0D4Pf0ZRfaiwx RUMvJXKecx/6VkQwWTk0iMCfUi1rr1+XivZ6zEHhX04Z+sQ4XoRgDsOGmyEguvTvhQN7 MIap8dgfy8EFYlVBsh8ZyR2SQproB0cMp2i2Yrflndnop3aZDLjCCP5Wequ/5jK3+JAY 8Exg9R0vxgtoO1eQaszrIWUgG4LBHPSEQvbYUHndpiTLDDZAd17p8IMothuZQOJnWpNK PqbNYxJLoNycbvGAFybcl0Hed+1KixRnk9wq/Nh27DyFyG3vj2c2TdsrGgSmOe2pbl+4 wVFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=WQYNPWHT; 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-88962-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88962-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 g25-20020a17090613d900b00a4425e2c2a5si1631962ejc.298.2024.03.01.10.57.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:57:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88962-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=WQYNPWHT; 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-88962-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88962-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 AE5961F21F3D for ; Fri, 1 Mar 2024 18:57:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E7AE3C097; Fri, 1 Mar 2024 18:56:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="WQYNPWHT" 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 0F63139FC9 for ; Fri, 1 Mar 2024 18:56:23 +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=1709319385; cv=none; b=fMzALEk2RY0/bHbfgf4e58aMVScCK7M9ewlpv6C0Appvl2Zxdor67gjFv/Y9aARKiKLSNh3oB1yQ0Ez1JmN/DHQ8ucuBvtK8WVYCOcvdKtcx/rDbWHqRgWJStYDefjLb/6PsQdXKH4mHVVrj6QErsbFIcn4ezVEkf6Kg+vfXAlc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319385; c=relaxed/simple; bh=zOERgnuO1Bl3NMcQJgmZ4s42PwosJ4JFp5OUJlYIO44=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=QLFFLIiDLutf3vVSsoYPaeo9Orzsjvqh9hUvJ0kxlsl8otWUnS8O29VYHRPl6y1ji+1IJiEF/e7pXZ5ZETNYyfgy16FtR47Jqp8Nnd5+a3TmyOOopK9+vUVnBkmUreigdpzNAdYgY5VPsqLdSos08PWMz09ugKpMFYl+WE8XZdY= 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=WQYNPWHT; 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-6096493f3d3so35131687b3.2 for ; Fri, 01 Mar 2024 10:56:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319383; x=1709924183; 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=L68TwYEEJpFcSpLsVXn02dHEJdoYMq6WnWpBdckYRf8=; b=WQYNPWHTlGRr0HEaXr2GgwUPHIRvFAEAofaSmp0aG5V9xnj/I2Qu+IN1vDPop3RjdJ nXkBg9MMusnsXEV81TESokisplV4q67LjjuTTcBeUI7PJlhrktEaQQBVUhgrNk9tZfum HpgVRGSHlREvqzBWhVLlbG34dn4O08jC7jc5ZHVo+hJvsFW2jNCf0pHtXGuo6T0p0kr+ 56o/XXaumo1QmabGpUPZ28Z0abPTO6HUij4ZIC9tc7yHPGTPvs/ISZ5JkrZ5mw8yO5tq ckFuc2aDsn2MV9SCt0uEMqJVK7ZB9WMMHn8sYajK1ZFFjZpxwjxQ2K0Tnj+XRgfY3E/K b5TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319383; x=1709924183; 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=L68TwYEEJpFcSpLsVXn02dHEJdoYMq6WnWpBdckYRf8=; b=c/a1plmQhAW6hnEvTuxMjIRiWv9BJTukDgBEI8e/y1+u2PPsDlejfUFkTF1o3j2ysC Gu2nPR3+bePS31BlyW0ceseL6OD4w3EIW+XMuMBGf20r3KNSO6pehpsOOoFmxApqaS0P Cnnyb4FjKEBfWas0bNQV5MBHwVqt1vzyrIrxQnGSRI9ZKcUh5lfwXDjpX27c6hBN45qI ETQj3s5GqJSvTzthx96jrZjzybIX88PaF4eB6EgyKhuYiLPTdT7uO0JFFAdOowC+4Grv HlwHme/oGygP2bJyBECEJbDiR4q0xT9nxwCLD6zKoTOyHYjDzex+eOQ6Kk2U4oyTkkmi G2Qg== X-Forwarded-Encrypted: i=1; AJvYcCWoqGsbZ4Yed+wdGjMlvn29Kj7MzfN1odZ1gtU+JVLqcdfeyqESCpaIf+ftBw5DEptpicYo/LUgm05WBiPem4wAM2USnow1tYC2DLH2 X-Gm-Message-State: AOJu0Yy2OEdxD0LhMBweBawwaLb5R850hxMbRqDxtKe/fk8k2xjEwy/z fCk3ooPKi2Yt4cgwcHM717KgyX3LbDCnIUDdw78v0q2mFxQSDpiM2JjzX5qXdQVAdH4rZhTfvq8 7hhRa+Q== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a81:9a05:0:b0:608:2ad5:cd28 with SMTP id r5-20020a819a05000000b006082ad5cd28mr464292ywg.4.1709319383012; Fri, 01 Mar 2024 10:56:23 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:43 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-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: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 04/20] perf jevents: Add tsx metric group for Intel models From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351365465296648 X-GMAIL-MSGID: 1792351365465296648 Allow duplicated metric to be dropped from json files. Detect when TSX is supported by a model by using the json events, use sysfs events at runtime as hypervisors, etc. may disable TSX. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 52 +++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 81879e68da96..3d80b555fac9 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -1,12 +1,13 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -from metric import (d_ratio, has_event, max, Event, JsonEncodeMetric, +from metric import (d_ratio, has_event, max, CheckPmu, Event, JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, LoadEvents, Metric, MetricGroup, MetricRef, Select) import argparse import json import math import os +from typing import Optional parser = argparse.ArgumentParser(description="Intel perf json generator") parser.add_argument("-metricgroups", help="Generate metricgroups data", action='store_true') @@ -80,10 +81,59 @@ def Smi() -> MetricGroup: ], description = 'System Management Interrupt metrics') +def Tsx() -> Optional[MetricGroup]: + pmu = "cpu_core" if CheckPmu("cpu_core") else "cpu" + cycles = Event('cycles') + cycles_in_tx = Event(f'{pmu}/cycles\-t/') + cycles_in_tx_cp = Event(f'{pmu}/cycles\-ct/') + try: + # Test if the tsx event is present in the json, prefer the + # sysfs version so that we can detect its presence at runtime. + transaction_start = Event("RTM_RETIRED.START") + transaction_start = Event(f'{pmu}/tx\-start/') + except: + return None + + elision_start = None + try: + # Elision start isn't supported by all models, but we'll not + # generate the tsx_cycles_per_elision metric in that + # case. Again, prefer the sysfs encoding of the event. + elision_start = Event("HLE_RETIRED.START") + elision_start = Event(f'{pmu}/el\-start/') + except: + pass + + return MetricGroup('transaction', [ + Metric('tsx_transactional_cycles', + 'Percentage of cycles within a transaction region.', + Select(cycles_in_tx / cycles, has_event(cycles_in_tx), 0), + '100%'), + Metric('tsx_aborted_cycles', 'Percentage of cycles in aborted transactions.', + Select(max(cycles_in_tx - cycles_in_tx_cp, 0) / cycles, + has_event(cycles_in_tx), + 0), + '100%'), + Metric('tsx_cycles_per_transaction', + 'Number of cycles within a transaction divided by the number of transactions.', + Select(cycles_in_tx / transaction_start, + has_event(cycles_in_tx), + 0), + "cycles / transaction"), + Metric('tsx_cycles_per_elision', + 'Number of cycles within a transaction divided by the number of elisions.', + Select(cycles_in_tx / elision_start, + has_event(elision_start), + 0), + "cycles / elision") if elision_start else None, + ], description="Breakdown of transactional memory statistics") + + all_metrics = MetricGroup("", [ Idle(), Rapl(), Smi(), + Tsx(), ]) if args.metricgroups: From patchwork Fri Mar 1 18:55:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209034 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp87582dyc; Fri, 1 Mar 2024 10:57:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUJ2RqwbI1Y/VbKiD8znxkBBv2ZpYasxzQeznjzPg9Hb92YOxMxxuwo8Yu78+LPG0mj+Tl4+p4sgZ1p2MxGlwn+wK6ung== X-Google-Smtp-Source: AGHT+IGD8oICQ/ifIWcu/iFC1xHpezf3EZ3hrpC/UZn5LkrEHzlN+akRPt5Enw7ASsVSYnCKeg0f X-Received: by 2002:a17:90b:188a:b0:29a:ca83:19a1 with SMTP id mn10-20020a17090b188a00b0029aca8319a1mr2341098pjb.33.1709319473899; Fri, 01 Mar 2024 10:57:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319473; cv=pass; d=google.com; s=arc-20160816; b=LC5r1PyaZM+gj9wXKwUbnP7bOvOVnaVXTjisunwpggXsMrabO0PI/s7m3lJm8JR0rQ Cqp33SGdDRgAFdNbgXEWh2Q4WHb9jHVbjbmEDT5B2Lxx5hhI7NXpOTIm4SO6xPZPPd8l W6u6Fz8i9fOEWUy86k2zn0RzoCMrt/EwRBEqh4edhWf9kuE3XHaCXqU7Dio9Y3VzNAYs ypmb6qQyjtEYch2JkCcW0LxhwbsErYo9wVT9cl/K9G+5UnHgvsIDBNrPOY3txCqPCHTl dW85n84lLb5oYiFoTH9nDOrMJ3F/+ce15a6OCLTlAYXIy/yIIEGwoDlbn9schdybV4Q2 2cFA== 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=h/hkLOGxFb+NGL6rpwIzI3DU/bCodQ7sPVZDGihfs7c=; fh=QY7YBLN79Pvkxb+5lABjTfA4pQ5LhYm1DI7sswU9dPY=; b=nIqW/TpkxZeMlXnT3h7MMIjm3/Fruew7Rkagj5IHkKbEQKX4hFtBDyRUXsJ8VOnJaE VNmEEyFv0LbmQGCCLeXyuNWa8o9uhhzqdggbClE0bEhpACu6ZsqoriUW/hZUaPjCWA85 +2X+0NuZsxq1Pcs6TnTrZu239f99SMGxLFXcwBjvSsMUmIHG61Gvje+CA9or2fs7m9nu mAPTKl8rp6maz3zn0Fl24MKpogwK5lJDTeUn1qMtO3oqlvZl6Y29xjcSx0DrRklGsG95 huqZEEB69f5jtsliy7nWCMvaiw3ADFM+zNoR15J6nsT5WZQTZQyZBcfq8Ry/6AT59gmP B0dg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=JtFccn+7; 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-88963-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88963-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 ng11-20020a17090b1a8b00b0029b301cb7d4si471127pjb.28.2024.03.01.10.57.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:57:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88963-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=JtFccn+7; 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-88963-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88963-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 AF8172833CC for ; Fri, 1 Mar 2024 18:57:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B60C3C468; Fri, 1 Mar 2024 18:56:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JtFccn+7" 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 34E2E3BB41 for ; Fri, 1 Mar 2024 18:56:26 +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=1709319387; cv=none; b=Zm4oYMSqp85Wcm4NiMEPmdBa7pl9P5r02kmDWndgIA4jUXBKp4pFObF6ZlQitJG2O7fasasNGwi7qHMR3M/qiGgLLHTBWzgEi9WX51HhTXGzt21lVcuM+Btz1Kvw3Oaa6EhKqa1QAYtr66xlijGq/Myn9gAhhAS49Y894JzId4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319387; c=relaxed/simple; bh=SYzzekKsm56SYljV7D2+Kgk899aiMFZ1uqVugeWMohc=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=tBF5MxUWieyzbtlHGeKKBLrzydKwAxHSwVGeQVN25HscvXGvDp8EjaCFOsAl4s1QL6mosH2HAc/o9dIqk8knUfxdjkAgWCllVOMpRVXXDj8JlrMbhp7TFb6lGcHRXEtUHjstWqGQOLmoB37GWoG+Ll+dyFqOD782EH899ZuqWlI= 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=JtFccn+7; 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-60971264c48so31095957b3.0 for ; Fri, 01 Mar 2024 10:56:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319385; x=1709924185; 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=h/hkLOGxFb+NGL6rpwIzI3DU/bCodQ7sPVZDGihfs7c=; b=JtFccn+7YxCk4qNDXYazHzLXmlV3Z3oh7BOuZZKHn7etAW3CVaXJg1tCGt0cHcJ7cA etYUUdHBtQcUNC8AusKqdipp/GU4vDiGBdIgRpkSSWRZLjng/jpg1MTWDx2lXStUxSyE PbPD9UD1+N0c3Eb2h5/EED5HQUoBTsfGpgW7HoWB5P4E19rBG/kdFWhVTrh38oK3tYWU 7yqfFpJTqNnmW8bubi0IF1O8dg7rIH9UiqB6Vs0gqUdVuADFMZFrwfQXtpg57rj4clYv f2kxrH8SEC4a6dGOPqzERuOpgy744CkHOUJE92EQsE8lO45GcjH7fUue0uFzlpJiiB4T tzow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319385; x=1709924185; 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=h/hkLOGxFb+NGL6rpwIzI3DU/bCodQ7sPVZDGihfs7c=; b=AVwZ7SINsuF1JX/lprL7ZNsQBdzw9upCX7NhKiXmteYB2TigGJnya1GdzMNttOn5SO P0JLoyPEDzNJK9guPigBS6EweVae+lNG0RUKujoaEziVPIK8rYUWPmY3uqq10/YjQ4v+ sDg5z4RoIdAsYEEeBsNWPTP+2OLZ4tEQGDfKR62hP/DAMX241UzrlQ37shOIYcrBEGg6 z6o64k2fYzvda8NiTWAlbBIZqjYxI0lZKlSsaoDHP34+9Hszxls83gArSwOBhWK2s7Sf Kx9JxJo03kuw8NFQb/59sg7xow3jaVxDnbk/2m8gPPh16SaO5O1YQstaRtDdoTlxAN7o stGQ== X-Forwarded-Encrypted: i=1; AJvYcCWEa9crTbHtCJQw/Za7Y/dUzpPJxXfslon6PI5qZLg1Ihs+qP0Ib5ZPx1HdmkBNWgwWkJtZaxL9m/JhdqT1wcKFBUNd/yQx2WYzdpFw X-Gm-Message-State: AOJu0Ywh9fcZHYgZJffOdts4yfKBjV6cMglZB2GJx3zGC87Tk/PkniMo rWYG6w7e4EtdrmkeOT9H3pJUHlTAJ21dzOa3XBDi0WmcN8I2UGOaBbqzWyW3Jc0cbIPLh9NevfE Lry4ofw== 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-20020a056902182100b00dc79218df3bmr100391ybb.10.1709319385391; Fri, 01 Mar 2024 10:56:25 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:44 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-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: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 05/20] perf jevents: Add CheckPmu to see if a PMU is in loaded json events From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351376746102708 X-GMAIL-MSGID: 1792351376746102708 CheckPmu can be used to determine if hybrid events are present, allowing for hybrid conditional metrics/events/pmus to be premised on the json files rather than hard coded tables. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py index 7d445e47ae09..0b84506cf2f7 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -8,10 +8,12 @@ import re from enum import Enum from typing import Dict, List, Optional, Set, Tuple, Union +all_pmus = set() all_events = set() def LoadEvents(directory: str) -> None: """Populate a global set of all known events for the purpose of validating Event names""" + global all_pmus global all_events all_events = { "context\-switches", @@ -24,12 +26,17 @@ def LoadEvents(directory: str) -> None: filename = os.fsdecode(file) if filename.endswith(".json"): for x in json.load(open(f"{directory}/{filename}")): + if "Unit" in x: + all_pmus.add(x["Unit"]) if "EventName" in x: all_events.add(x["EventName"]) elif "ArchStdEvent" in x: all_events.add(x["ArchStdEvent"]) +def CheckPmu(name: str) -> bool: + return name in all_pmus + def CheckEvent(name: str) -> bool: """Check the event name exists in the set of all loaded events""" global all_events From patchwork Fri Mar 1 18:55:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209035 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp87723dyc; Fri, 1 Mar 2024 10:58:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWMCFqkI8UtVRppfDLR+AxkuOllemWX3Sa+WKMWrYUX5Wc4iIxLXHMkNXjIPBnNLMTyTUeXuTYb4O/gnmp5e64XBYizjg== X-Google-Smtp-Source: AGHT+IGtiZgMizMwS611IW3Lqc+UUUn4emDuUmvUQKADVAPGSwY0k0vNmRpm5pOg3tDUM/kTW3xu X-Received: by 2002:a17:906:29c3:b0:a3e:5ebf:345c with SMTP id y3-20020a17090629c300b00a3e5ebf345cmr2221952eje.21.1709319491406; Fri, 01 Mar 2024 10:58:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319491; cv=pass; d=google.com; s=arc-20160816; b=UGma5kEJPdA0oiWd/j3eoOuL2vfWmhfgXvYANy8+Wg6VIaOCAkkU4j6urj7w2utEvM DolJmtmZXN2/qms9pkVhtc6jBhv6wU4ypPmN5q9YuROfuGcmonQBasmwLXY/93BSQnvn Oesdpn21lzr4HoA9+OKz86xm0l5IXIdlVplKO+ELL7X3G4rU6bkQ6fVc+Qg2UpncS9k9 rbgqjftWBm16mttmGB/jAHv2NTrioYsjkFtLCB5oKsto8iAVFcbDyz83x8HpI21FzAt4 kG1uADbvMs7eCybFNLgeXvCYsz8pZjfgDJIogZkp4Hmu5ujDu4jolrWF103Dy6V56yvl BNDA== 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=x6YYq7rNB/18JZA6R+41hP3nh0swy3CSvJmc4i9vc/I=; fh=pAGnh7wmzsubbI67lL5bmicKjiLxU8HuqQoiVj5MNTw=; b=nLz2PlQwFleRgrcpZN7yEiptClErXg9m1C9OHVxNPYxtgwJxOH6th2RwG2A7I2EJ1M GG2SADeTRpIjOlkUFo+v6R7Rdpx1tF8ClR+/d8DRUzY02HAcWcG7l/YLQIAaxAM89IKl NrW++ND+062VFAczyoxTQRluOS4lq9p2gvRt3zxMb80mSqS1UVxcONFcV9grTRpUYJqr iraz24MYghXS+VOQ29P6SyzxdB5KrWyuxoBch09yeA0X6CeAhU69QKw4kxriGBGaYFXc DnkVeLYvpQiDpZHkT5NY8q/8dtpVPYW8e5nMxrGoSR8lC6ZQIx+t1gktAko/g+hEQ1mR 8mDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Te/Hdd6G"; 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-88964-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88964-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 y17-20020aa7c251000000b0056647ec2f67si1749670edo.474.2024.03.01.10.58.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:58:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88964-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="Te/Hdd6G"; 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-88964-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88964-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 D88F11F2627B for ; Fri, 1 Mar 2024 18:58:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E01003CF74; Fri, 1 Mar 2024 18:56:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Te/Hdd6G" 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 969BC3C469 for ; Fri, 1 Mar 2024 18:56:28 +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=1709319390; cv=none; b=ZMYei5VsuFaXxCMRVL3MB/uIApaLMp02KE06m77D8f7i2d3HN3OO+MMrbsRNirUbjujkbKhTjhSFhM7prv18jyC27ZQgV/ztlH2KngIprl/lvrOZ3Vg4I2CAn2CL8WI2/2M7u2ROG6oTl8s0A4QZJ+7fNe+8RR5Tjn2fK5oWKCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319390; c=relaxed/simple; bh=FlRrp5/2ztkczVrYoDn9EIOjChMK8yWEJSgo0hdGptg=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=DJhbK4OmfRirTVmBVNizVDE2/0bbGYglHhUOlVXVNrBO5hrS6eHn1/KCvdlhdllZT66D1Irg2X+96dyV1j+ytso0bXfsoqnh/WI9y3ggGefQcO8B/OJaQMttN1tcZrA7wmnb0XAed8DPGEMtBAGfTGOyjvejgPAty1UI8P7rqYE= 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=Te/Hdd6G; 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-60804b369c7so30759257b3.2 for ; Fri, 01 Mar 2024 10:56:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319388; x=1709924188; 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=x6YYq7rNB/18JZA6R+41hP3nh0swy3CSvJmc4i9vc/I=; b=Te/Hdd6GkTttIGnVb8ne7pbex0pE1TKDXdKlCGkU2SNU9drPIJcZpRs5fWGRAQUvE/ sqjKhdGL5Bm3EJE+hUaizykOsfgN8pAVJkO/kH+Hh1mp2R8elmhyH4QxwR/E4vfv3v1A ClXrGSp4NvAjYhr5QsGzHCTa+XU/IM9sFnESFGTZN5YCe5SbZXCyuxEyq6RI3BnuD/+u jJPNG7HjAsrwD1Y2fI7EK/+N6X0UOXPmAmbjNx8yGFu00/QqltBwuXStihHlCTDmeEa/ atQZ7g7302GxxPQun6rqXf0+Nb9nSmcW0vmsWGTHdrQPQ6oBlL+Jb1ppSo5DRFSHta0C +zew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319388; x=1709924188; 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=x6YYq7rNB/18JZA6R+41hP3nh0swy3CSvJmc4i9vc/I=; b=tXL5OSn+b2rrzhgifdLkenn4F+XDgdGvecEgUNGlc3mA//40cI8GreaaG9B/pTQw64 EL9pshustO9As51CrIk1L8lgo6Uwc3jKYQmU77j07ixgpyb4xvIwHbWpVlTiVaw44EQb 6kc7tvkjfN4OQcuMsztRa9RtM/2of04oHwfbsKDbsNWPojSzYekxgJEBeihHyfKUlZdJ Ta2RWzztpMCQhyQwHY9CEn4H+RPaGpQbs5P1uTekaAt+BmmFfGnHAHYmGAK/Ozd6dnFJ 4OtH5za8KGwVU2U+gXYseVq7aj4+TSGNfbnsGiXq1T3J04+2JcObqvhcUDhGJpP1v0GX 9ktA== X-Forwarded-Encrypted: i=1; AJvYcCUgKIae2GL+qdIWXZj1HRdxCGXIVSTSfoV6aSGwIxFPyPPRESfQKrd1CcFf4JiQKOpDZyRjwvYX+DD8/VfoO5yME8aF62XSaf8GCc+5 X-Gm-Message-State: AOJu0Yz83QOx+uupI6Tz07iRkoWsnJs/bLxwpgYejyrGvUe90vLaPao3 kJCmpR1HJGClUeZR4g2alWy9jZrlgkIwSIDD+DX0amXfTCi6cz3WwoW00jmi/EG9NineB6FZ7nE 0jU2V7g== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a81:9949:0:b0:609:2fba:12a0 with SMTP id q70-20020a819949000000b006092fba12a0mr634883ywg.3.1709319387865; Fri, 01 Mar 2024 10:56:27 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:45 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-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: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 06/20] perf jevents: Add br metric group for branch statistics on Intel From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351394936880626 X-GMAIL-MSGID: 1792351394936880626 The br metric group for branches itself comprises metric groups for total, taken, conditional, fused and far metric groups using json events. Conditional taken and not taken metrics are specific to Icelake and later generations, so the presence of the event is used to determine whether the metric should exist. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 138 +++++++++++++++++++++++++ 1 file changed, 138 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 3d80b555fac9..562db0a1df79 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -129,11 +129,149 @@ def Tsx() -> Optional[MetricGroup]: ], description="Breakdown of transactional memory statistics") +def IntelBr(): + ins = Event("instructions") + + def Total() -> MetricGroup: + br_all = Event ("BR_INST_RETIRED.ALL_BRANCHES", "BR_INST_RETIRED.ANY") + br_m_all = Event("BR_MISP_RETIRED.ALL_BRANCHES", + "BR_INST_RETIRED.MISPRED", + "BR_MISP_EXEC.ANY") + br_clr = None + try: + br_clr = Event("BACLEARS.ANY", "BACLEARS.ALL") + except: + pass + + br_r = d_ratio(br_all, interval_sec) + ins_r = d_ratio(ins, br_all) + misp_r = d_ratio(br_m_all, br_all) + clr_r = d_ratio(br_clr, interval_sec) if br_clr else None + + 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" + ) if clr_r else None + ]) + + def Taken() -> MetricGroup: + br_all = Event("BR_INST_RETIRED.ALL_BRANCHES", "BR_INST_RETIRED.ANY") + br_m_tk = None + try: + br_m_tk = Event("BR_MISP_RETIRED.NEAR_TAKEN", + "BR_MISP_RETIRED.TAKEN_JCC", + "BR_INST_RETIRED.MISPRED_TAKEN") + except: + pass + br_r = d_ratio(br_all, interval_sec) + ins_r = d_ratio(ins, br_all) + misp_r = d_ratio(br_m_tk, br_all) if br_m_tk else None + 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%") if misp_r else None, + Metric( + "br_taken_insn_between_branches", + "The number of instructions divided by the number of taken branches.", + ins_r, "insn"), + ]) + + def Conditional() -> Optional[MetricGroup]: + try: + br_cond = Event("BR_INST_RETIRED.COND", + "BR_INST_RETIRED.CONDITIONAL", + "BR_INST_RETIRED.TAKEN_JCC") + br_m_cond = Event("BR_MISP_RETIRED.COND", + "BR_MISP_RETIRED.CONDITIONAL", + "BR_MISP_RETIRED.TAKEN_JCC") + except: + return None + + br_cond_nt = None + br_m_cond_nt = None + try: + br_cond_nt = Event("BR_INST_RETIRED.COND_NTAKEN") + br_m_cond_nt = Event("BR_MISP_RETIRED.COND_NTAKEN") + except: + pass + br_r = d_ratio(br_cond, interval_sec) + ins_r = d_ratio(ins, br_cond) + misp_r = d_ratio(br_m_cond, br_cond) + taken_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"), + Metric("br_cond_mispred", + "Retired conditional branch instructions mispredicted as a " + "percentage of all conditional branches.", misp_r, "100%"), + ] + if not br_m_cond_nt: + return MetricGroup("br_cond", taken_metrics) + + br_r = d_ratio(br_cond_nt, interval_sec) + ins_r = d_ratio(ins, br_cond_nt) + misp_r = d_ratio(br_m_cond_nt, br_cond_nt) + + not_taken_metrics = [ + Metric("br_cond_retired", "Retired conditional not taken branch instructions.", + br_r, "insn/s"), + Metric("br_cond_insn_between_branches", + "The number of instructions divided by the number of not taken conditional " + "branches.", ins_r, "insn"), + Metric("br_cond_mispred", + "Retired not taken conditional branch instructions mispredicted as a " + "percentage of all not taken conditional branches.", misp_r, "100%"), + ] + return MetricGroup("br_cond", [ + MetricGroup("br_cond_nt", not_taken_metrics), + MetricGroup("br_cond_tkn", taken_metrics), + ]) + + def Far() -> Optional[MetricGroup]: + try: + br_far = Event("BR_INST_RETIRED.FAR_BRANCH") + except: + return None + + br_r = d_ratio(br_far, interval_sec) + ins_r = d_ratio(ins, br_far) + 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(), Far()], + description="breakdown of retired branch instructions") + + all_metrics = MetricGroup("", [ Idle(), Rapl(), Smi(), Tsx(), + IntelBr(), ]) if args.metricgroups: From patchwork Fri Mar 1 18:55:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209056 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp104396dyc; Fri, 1 Mar 2024 11:21:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWsF5kjbBZy3XIsE9jPfposnuTvOxm1Yjh+O8XcNEh547Z7j+bnM0kZhtNF9Mp3gTbYx9SFJgOGCxDf7oAk3tGs+yssCw== X-Google-Smtp-Source: AGHT+IGVa76e2+fU4O52WkwiSjGKK1LysVXwCzT3M3sPT79uXGN1x4p4ejQZnyo3VQmc2zM0BPdC X-Received: by 2002:a17:90a:4087:b0:29b:9e1:2fb0 with SMTP id l7-20020a17090a408700b0029b09e12fb0mr3616361pjg.0.1709320919682; Fri, 01 Mar 2024 11:21:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709320919; cv=pass; d=google.com; s=arc-20160816; b=J2E70XmG2RfEa19rQRSPa2V02OP+rnkjkPijopf5RQO5pA0xROZYNSjcDMglArlTuU N12zC/Aw1/XbviN2PLrEbtEI4H+ul9mqhoCiVPVs0JxMnHio2dkYia5ki0ET9OkA1Ne8 2CBSwrMkx4i0UmlUdi7S3NSLPXkbaP1a5ICulu7mWPctPvfbM2UjvNdz1AfWcapf752i xlg7hiV7L3PV4OF7m4GYZ6g6kdekv8qclZmEXrC1hK4nWG0LbNqwGx0BNoKZgIojxbGa 9S3n5AlXy/Ki70KswcbDpGcBjZfRpUMKy9FDAFNW6iYXXPO0B1bCPgwLhHBiebYM4J0G zfgA== 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=TCqcOkno42A4mj5+uGyBsE4UljIV8p5MIV2GTsxx0/Y=; fh=D9cPVF2QEFaVIPtAK5t0G2qW8IJkazFdukXHBvQySYA=; b=hcS5GijZS1uh9fKQmk0a9P83AdqShFEDJgn7qknNSmAtY4OJqqvpTVvX5HkF4oMhMP 0UWpNfXIb3KniLSGhenimfoMCoR1R4CFVWcY2RZTiByZXvd3HjvSrMgNgfMbPuRSDDsO nQ5OrALnRU7s5W11SpRlbHRpqYj3TJ7cXNRzTgp07RkUVQydoc6Ie4smQWj3eK8Mj1d4 T2Yyf1K+57IOs9u2NUEAMonaZKHjbLRqNP1tQxOH5Sr0TYcVNpXQjxCKfQEGH12sCjzs sO47n5ybG6LLA5u5gDm2F3USEAENtDc8tMNVwvKIlfVmX9xRXsImkXUOqVyLduei2ahg KQTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=gqfI9v9B; 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-88965-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88965-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 v1-20020a17090a088100b00297305f7b3fsi6146101pjc.48.2024.03.01.11.21.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 11:21:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88965-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=gqfI9v9B; 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-88965-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88965-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 A11D3B314C3 for ; Fri, 1 Mar 2024 18:58:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 589003D0D5; Fri, 1 Mar 2024 18:56:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gqfI9v9B" 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 09DB93C684 for ; Fri, 1 Mar 2024 18:56:30 +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=1709319393; cv=none; b=J0FdlX65bNx3ym1ui/XO5wNJBGGKy4tZhdvBH8jQgBu1Pz7hPewksNTcCT038Maopj86RdmjAWMmoohBopf/d0McyoLvbz2A1ey/qGB225PtWyr3ggZmbPKQPyzK6OukNp5gfTzBLcW6vBzE577wuzo1XOxSG21V6JnRFV5pN3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319393; c=relaxed/simple; bh=/54YRscTrPrGaSdpjdXFm+80xMNflZRfzwa7Hsf5/WI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=nZogRHs4bMF/TJDstbGRywuSAwRPiaQi7ZGjQvk43IvAadQuGRoRJXB1Lz9AHkD8JULwKaRSfjxx9Wj+uAAKSpIush6qncvvGpWXSa1DNlit402Garf2xj8hJa/DxGEt2KJBiXdf2noHlf9D8mTgeIGmY+8PZybR7ROHHqbyZC4= 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=gqfI9v9B; 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-dcc4563611cso3956982276.3 for ; Fri, 01 Mar 2024 10:56:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319390; x=1709924190; 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=TCqcOkno42A4mj5+uGyBsE4UljIV8p5MIV2GTsxx0/Y=; b=gqfI9v9BFL/2xmUnHAgMklwRYAkkOxw7WWox+C8ZL5jiWe+qP1OzPDdClw5GDdYe2R BvYtI9mzixLN4Ao5s/T+850s8EyHWZb28uvQFJRM7DSZ0LdfJSLiBhRBvwdsZMft9nj3 qGvyqmgseNt7HebVv/4hKeWKpomSJwj9FAfU07OJj2yLTr305e21jxLxxXAkGqJ3Lbw1 7E8Apl5TzIrNxDjBsIs9g4vei07Q7bq+mqIcikLJFqE2xQmsJhwDXmbD0jrvM2KCiD2t y0n6gfu/FMN1ucMhREvfVC2ri6H0/4GNUjFB3fT1Tfy+AmEWcDw30XzshNabAotKcSW6 Mlqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319390; x=1709924190; 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=TCqcOkno42A4mj5+uGyBsE4UljIV8p5MIV2GTsxx0/Y=; b=tlKytVTJglelYwF4dXKsg+VKKub8hoik21CEszNe/muInNRVRt2P24KCsWp6X2RvE5 UP4kBCkMT+dWuLoeFPNOYk3CoL2cy4QPYOQ6BKCjpHVV/FbEemGDcJAoYf5jJeWXvR6F Y17qun/Aq/RjoKLHqz+AL8O/oA8JskQlTykzmFy6CANRtJBZ4WOdNMAHtMmrLTmtuAYq Dzhrpqzo4VJmy39DAkLfu+Vju/vowppZjE9C9l8rryr1Ro+LHeyN6ETdmSuwQuqHJHQu +3lSOC6Lx+HTnnAl6FmYwOshFVlbclkMBcj42JwMSg+Bn0C4akg7JEM2TUkOHW1dW+6J ANQA== X-Forwarded-Encrypted: i=1; AJvYcCWWGV4DMIVJG2aVegWgNT4kjd4RJgHLd58Bf/HGk0aXHumwOTPN7F9nqPGtHaygpIOzEuDJAZ8HNx3uvAOppuoOmIcPLbksO8TG78Bh X-Gm-Message-State: AOJu0YyWxqo4/xboqxNAa37i+Gu6GWtIPMI4aPfTXxOxQ4wx3Y5isWZy msqC0IT2PnqXBAwZVrWPeGLQ4adhymNZpTccCI4pnLUMLIJviY0UTpPqPmyr/ORxA4pOfgb6UXm oAhsEWg== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a25:aea8:0:b0:dcd:ad52:6932 with SMTP id b40-20020a25aea8000000b00dcdad526932mr551687ybj.5.1709319390095; Fri, 01 Mar 2024 10:56:30 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:46 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-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: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 07/20] perf jevents: Add software prefetch (swpf) metric group for Intel From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792352892999753540 X-GMAIL-MSGID: 1792352892999753540 Add metrics that breakdown software prefetch instruction use. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 65 ++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 562db0a1df79..6c42c8947652 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -266,12 +266,77 @@ def IntelBr(): description="breakdown of retired branch instructions") +def IntelSwpf() -> Optional[MetricGroup]: + ins = Event("instructions") + try: + s_ld = Event("MEM_INST_RETIRED.ALL_LOADS", "MEM_UOPS_RETIRED.ALL_LOADS") + s_nta = Event("SW_PREFETCH_ACCESS.NTA") + s_t0 = Event("SW_PREFETCH_ACCESS.T0") + s_t1 = Event("SW_PREFETCH_ACCESS.T1_T2") + s_w = Event("SW_PREFETCH_ACCESS.PREFETCHW") + except: + return None + + all_sw = s_nta + s_t0 + s_t1 + s_w + swp_r = d_ratio(all_sw, interval_sec) + ins_r = d_ratio(ins, all_sw) + ld_r = d_ratio(s_ld, all_sw) + + return MetricGroup("swpf", [ + MetricGroup("swpf_totals", [ + Metric("swpf_totals_exec", "Software prefetch instructions per second", + swp_r, "swpf/s"), + Metric("swpf_totals_insn_per_pf", + "Average number of instructions between software prefetches", + ins_r, "insn/swpf"), + Metric("swpf_totals_loads_per_pf", + "Average number of loads between software prefetches", + ld_r, "loads/swpf"), + ]), + MetricGroup("swpf_bkdwn", [ + MetricGroup("swpf_bkdwn_nta", [ + Metric("swpf_bkdwn_nta_per_swpf", + "Software prefetch NTA instructions as a percent of all prefetch instructions", + d_ratio(s_nta, all_sw), "100%"), + Metric("swpf_bkdwn_nta_rate", + "Software prefetch NTA instructions per second", + d_ratio(s_nta, interval_sec), "insn/s"), + ]), + MetricGroup("swpf_bkdwn_t0", [ + Metric("swpf_bkdwn_t0_per_swpf", + "Software prefetch T0 instructions as a percent of all prefetch instructions", + d_ratio(s_t0, all_sw), "100%"), + Metric("swpf_bkdwn_t0_rate", + "Software prefetch T0 instructions per second", + d_ratio(s_t0, interval_sec), "insn/s"), + ]), + MetricGroup("swpf_bkdwn_t1_t2", [ + Metric("swpf_bkdwn_t1_t2_per_swpf", + "Software prefetch T1 or T2 instructions as a percent of all prefetch instructions", + d_ratio(s_t1, all_sw), "100%"), + Metric("swpf_bkdwn_t1_t2_rate", + "Software prefetch T1 or T2 instructions per second", + d_ratio(s_t1, interval_sec), "insn/s"), + ]), + MetricGroup("swpf_bkdwn_w", [ + Metric("swpf_bkdwn_w_per_swpf", + "Software prefetch W instructions as a percent of all prefetch instructions", + d_ratio(s_w, all_sw), "100%"), + Metric("swpf_bkdwn_w_rate", + "Software prefetch W instructions per second", + d_ratio(s_w, interval_sec), "insn/s"), + ]), + ]), + ], description="Sofware prefetch instruction breakdown") + + all_metrics = MetricGroup("", [ Idle(), Rapl(), Smi(), Tsx(), IntelBr(), + IntelSwpf(), ]) if args.metricgroups: From patchwork Fri Mar 1 18:55:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209036 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp87982dyc; Fri, 1 Mar 2024 10:58:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUwHrXCQb3J77xRNkeFofOBCn9EZ5hO7LN/RoPAbmfniYJcetkjehVkpcw3PrTfS75f7fqw6Z2vYSl1JSuL4613LN551w== X-Google-Smtp-Source: AGHT+IF/oEjmLzvd7wMsmyMRGpKbt6lehOAlX5FdS6/lNwVl6XfcrBBfSljML4OQVC8IVnrgmCSy X-Received: by 2002:a05:622a:386:b0:42e:bbf5:84e7 with SMTP id j6-20020a05622a038600b0042ebbf584e7mr2341852qtx.16.1709319520643; Fri, 01 Mar 2024 10:58:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319520; cv=pass; d=google.com; s=arc-20160816; b=Zy7VXNtVZOivAUZddNYzAN5y4LdWsK31+yD9fKVe+TkLAM37gsqPY8lMDFPT+9huiM OZ1hHCoOv/i8ES+RsiDXJ8EgSAz8NRHmS1cmfcyzlqBoFliE0ui21B//fsFMbjCMlGNR UZ7h4lkFBVGUt+LaF0F6JSYIBwSMEDEAMU5abKzyIR4ouWvl8FgFdM1v3TLdTwIdNpQj xrVcldmXEGAUhH0p/mcXxGURlQDgN4QfYwn2AZ6ZHTgePE/GRsmgsuDuYF4GP3va7s4/ PVtD+TAq1TLj0XDesZL5cqtYy18JWXKXuXpQCmhFlz43ks/m93XuUgtkWFPAv8FFkm6P lexQ== 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=G7yzNIE0K5lHOvKYMdHiv1H80sWzgzKkY1SnsP+lPB0=; fh=Jynj71PI35oieuGoGM/mGe6x0nDFYovmizNBd2giSVw=; b=Dvc5KGdjIOCvOrPYHPTiRjoIzDWqzDE6JilvF2ChE8DSX+9Vrp5phyF5c3nJ18pfr0 T0BBTjtyJ9UyRqPAelI80jEappOL+ol3beZHTOmqAKYCD4hzOMVxWMgl9pCxGITxYj+R AIJPz3VP/zKa+xePZ45chLTxWvL01PH1NPV3qzOblersfLgCJsE/gWcLOex7EX5WMK+Z lVOqtmWkS4QANBUdx9bICXAWGWGwf1RtV2LrwPozhZ8u1rXnA8Gn9nWFu/1KKTVHIm2X GH39rvU7ouUWWZwXSXXUg3C4aPRUz4QCEoJOGr9uQ7oXh/9jhu+aQ/ems1A1i7HVa0NY Qk3g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=u6kwWqdY; 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-88966-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88966-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 d14-20020ac8544e000000b0042e808c4b11si3813010qtq.784.2024.03.01.10.58.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:58:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88966-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=u6kwWqdY; 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-88966-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88966-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 60D921C23538 for ; Fri, 1 Mar 2024 18:58:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 296BA3D551; Fri, 1 Mar 2024 18:56:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="u6kwWqdY" 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 76F253CF72 for ; Fri, 1 Mar 2024 18:56:33 +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=1709319395; cv=none; b=ol4jY+ARRFoj7u/TLznzvJM6W4/C+zCIZqQSZEq2GEB8IJNU2QLcJf3xUhQhMVaMnNXuNlvcxP6v44FulAAD55e3ZSSPBYBsEMiSEHJyeWH/XVPtwUx/ub1LjFp5utvOv2iYajCwWhk/THHWNXWQ307s+v/P63HwDb2AfEaprIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319395; c=relaxed/simple; bh=r4ihq+erhDIJ96eTIi6uun2xGpgFyBqf/JqZ/4nXlRw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=pzYvgJtKfL+j/DIBvX7UBrqQTYwngtG4i+4yXo4pN94T72tYXn496RAYTnycDTHtKdPZJkUZUh8ThoJkMlsJkTweEMnURvWcpvab+A/ZgsBRKuwkXn0wlg//6/tvfD4CRS7ukp2WRyf7hAvg19smSJwJUNutAhiXsChCPv1J2qo= 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=u6kwWqdY; 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-dc6b269686aso3612614276.1 for ; Fri, 01 Mar 2024 10:56:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319392; x=1709924192; 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=G7yzNIE0K5lHOvKYMdHiv1H80sWzgzKkY1SnsP+lPB0=; b=u6kwWqdYUqf5ggYScGevoedifLvbkx3oW50/pWIIElME6tZ/SNYxTL0fQ4EsufPWqB MfBNXd8KpBg72OSx/Mbzy71b/frPpli2FO02pSdH27A305tTgbMCS5qwS9HphZKF+SWA IeB5domtpNlFof9dKUIM1gqsyMePmlYWI3AEkvu1fzba9vOd4wVeSRpfU9CXy25wFWgX qk6nyjoPKqsvHHZlLgBCnUh8Tkt0aCrDjj+ErcNUVxklBFqbESmIm6h62viLNxzKpZKp eaRkRzDyJofvOd6+tyAmVlFHqHcMoqGmNEiiHR6NReBfT0ThJZ/u7IVErKW5BiLRwjPo uXQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319392; x=1709924192; 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=G7yzNIE0K5lHOvKYMdHiv1H80sWzgzKkY1SnsP+lPB0=; b=lQqdKv9WAVCDuysNrJLzDnzABtvEehW5cjKcHHjZ7h85yeq8cO7s3skzv/GznfqyC2 WwHTw7WLfO2UXCtd4NRrsQ45+zJmdf4Endhj+oC2Jcxnpi9ownYDk59oYUyKtUy9Qulh 5OvvdMX6YQdKtwFdA4Za7f4ojso7VzNQhjvkTXTATrm9yaqtEPoYDZfHQZR2c2mPG24i hZ/fVvyFxAEXuBQ4j/QnWMFfpcIZUGExdjub9w209/vI3MqKPXeoT2BAa2U2C39MTU/M 49cPr5Orl0wjxHtWtxTN7SCIUDx7yJhKRslzhjHRvIGhZAoebiNt0qT/my6MQ2veUpTo vZeg== X-Forwarded-Encrypted: i=1; AJvYcCUwMG+0EGGJcveN/F798PFTOcIZfyhELoYib+8yQGw1U6XGKt46+AUY7els4475AZCAZwq3M5fs1b0PCuCNk3SPAEfodxTYLE6RSRzj X-Gm-Message-State: AOJu0YwSPe3tvgSE6uUBmPfED3J2ANf9JfpocQqKEuyKs1c0KGIJj+mn IXcIvuZHkdGYYcDWwgPUMY2x4Rfyl5DX2AATwfCPGoDgnws+OPmlMwKWpbg8LrAzr/K9pQcF05y VTHiejA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:6902:2206:b0:dc2:26f6:fbc8 with SMTP id dm6-20020a056902220600b00dc226f6fbc8mr101587ybb.7.1709319392696; Fri, 01 Mar 2024 10:56:32 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:47 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-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: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 08/20] perf jevents: Add ports metric group giving utilization on Intel From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351425302580353 X-GMAIL-MSGID: 1792351425302580353 The ports metric group contains a metric for each port giving its utilization as a ratio of cycles. The metrics are created by looking for UOPS_DISPATCHED.PORT events. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 33 ++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 6c42c8947652..49b83bc28891 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -1,12 +1,13 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) from metric import (d_ratio, has_event, max, CheckPmu, Event, JsonEncodeMetric, - JsonEncodeMetricGroupDescriptions, LoadEvents, Metric, - MetricGroup, MetricRef, Select) + JsonEncodeMetricGroupDescriptions, Literal, LoadEvents, + Metric, MetricGroup, MetricRef, Select) import argparse import json import math import os +import re from typing import Optional parser = argparse.ArgumentParser(description="Intel perf json generator") @@ -18,6 +19,11 @@ directory = f"{os.path.dirname(os.path.realpath(__file__))}/arch/x86/{args.model LoadEvents(directory) interval_sec = Event("duration_time") +core_cycles = Event("CPU_CLK_UNHALTED.THREAD_P_ANY", + "CPU_CLK_UNHALTED.DISTRIBUTED", + "cycles") +# Number of CPU cycles scaled for SMT. +smt_cycles = Select(core_cycles / 2, Literal("#smt_on"), core_cycles) def Idle() -> Metric: cyc = Event("msr/mperf/") @@ -266,6 +272,28 @@ def IntelBr(): description="breakdown of retired branch instructions") +def IntelPorts() -> Optional[MetricGroup]: + pipeline_events = json.load(open(f"{os.path.dirname(os.path.realpath(__file__))}" + f"/arch/x86/{args.model}/pipeline.json")) + + metrics = [] + for x in pipeline_events: + if "EventName" in x and re.search("^UOPS_DISPATCHED.PORT", x["EventName"]): + name = x["EventName"] + port = re.search(r"(PORT_[0-9].*)", name).group(0).lower() + if name.endswith("_CORE"): + cyc = core_cycles + else: + cyc = smt_cycles + metrics.append(Metric(port, f"{port} utilization (higher is better)", + d_ratio(Event(name), cyc), "100%")) + if len(metrics) == 0: + return None + + return MetricGroup("ports", metrics, "functional unit (port) utilization -- " + "fraction of cycles each port is utilized (higher is better)") + + def IntelSwpf() -> Optional[MetricGroup]: ins = Event("instructions") try: @@ -336,6 +364,7 @@ all_metrics = MetricGroup("", [ Smi(), Tsx(), IntelBr(), + IntelPorts(), IntelSwpf(), ]) From patchwork Fri Mar 1 18:55:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209037 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp88246dyc; Fri, 1 Mar 2024 10:59:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXrF5F2NvuFbTxM0/QjuUohEMXGLf2ZtsyH8Kia/OIstTIyEKrvCDxGkJ7djlJuM5aDKLzKjLdLIDPI5iH2QQyG+0xarQ== X-Google-Smtp-Source: AGHT+IFxk83to86YfU9YacGw1zn63rpIUNEjeB4uhB9cFVRVndl5sl9pt+09nQPHClkjym/Dq5Ag X-Received: by 2002:a05:6902:2387:b0:dbd:120e:f337 with SMTP id dp7-20020a056902238700b00dbd120ef337mr2816727ybb.30.1709319550745; Fri, 01 Mar 2024 10:59:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319550; cv=pass; d=google.com; s=arc-20160816; b=SDvvgFABUyU6xB/vmOQHgtWbFLE9hukxFJLVHUe9u1foiPJQRm8XxOA/1X4xLQJJnB AbnaalpJiQIFZhwEmSjUHL5P4KM5L5IqEUIwe/gD2HLuhd5nL48x4J2wPH7hhdr9oRYL UgGEAQ+D6HN0mhQWfLskXHaypwDP5yHhNAB+r7d+ArpEUmDjW1qK1ggqdapXu9uCvDZm HILfp/5j4SzW3dadkSbADuuWIwqtolofu1YlxhzLAqnUfSrloTVfQEIlrCgoAqpP+MaL 9Z1fzNaaw8clCcjrMHBgAmQtTaLQuxjHR63YFySNMcmU2BzATwLI1JetLEkESiDLIVDH r9Ew== 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=Ud2dHcNufn6h+i9hsSTaCNWNbOlP8ttf+JMwAMlMIZ4=; fh=KRUNtLQSOhGuiR7X4vV3H/3fq6u6VKvOrzqpj3AxEGc=; b=JN56GK8Xnlqdb6wIOTPSPawdhaFt5UPEzSOk5An8q9BZqGyRWb74C1lDRj5Gvu9w71 j92l7aZDT6Js9QFN6sUm31MCYPLoNQkuD3kUGpM8zoKL4JrRNAxMWUwbhoidiXNhG6fF u5YIpL5iYFHU3WjPZLK8stwgdUpY/G+CAZCvO86P4idv2N6xUiwYW/FSVQVDq6GA4J4C n9CQiwpsNU+X63Db+Lyq2Dtlh+f4/288LdaFNaDwr3aM6FhHxNAj/nAftKdtcyzZuNmo beoBkDPoC7Zpn9fbhz4/jBMiMjcPHTPn+VzosHRNBesRrE+rpJwg9VExf5gOnstGRqmg zrcQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=nQVHdeWd; 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-88968-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88968-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 i22-20020ac84f56000000b0042e7f4cd1acsi3812762qtw.700.2024.03.01.10.59.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:59:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88968-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=nQVHdeWd; 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-88968-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88968-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 6BA791C243B3 for ; Fri, 1 Mar 2024 18:59:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8CE213DB91; Fri, 1 Mar 2024 18:56:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nQVHdeWd" 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 D895039AF3 for ; Fri, 1 Mar 2024 18:56:35 +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=1709319397; cv=none; b=uu3DuKlLrdiucMQtu1PUE+wzZ/hgo4YcQnTz+rHdDfy4H/gVGnVGOZgurEnriovycADDSxbEpJIPp3EhBHI82BT8DkETlSDihQ3h9do7LVxUxW2rtyPW38+x6jHR/wwVeL3Z/ayHE9ahGiGnZV1mzjNFDJJqg43M+X49FLe1kX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319397; c=relaxed/simple; bh=d6bcfgsUUelfZrIFFKTwcyB2obYk56t03Qv/7R3k+U4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=U54oqjYh9RRXpXx0YNvGG0lCxEqTWab33yCnrtczDrypIdA1CjS41oYASXUGZkc+3sB7g7gkJarPskDc6ylKv0L9RZ7NwNnrHwN2BXjj9IlHL/ZXrtXvvCcpeZA4OJurUNkvaNB9fkEmQijprGgtzNGdSQwdrrahRra9Dd8WRts= 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=nQVHdeWd; 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-6047fed0132so40017987b3.1 for ; Fri, 01 Mar 2024 10:56:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319395; x=1709924195; 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=Ud2dHcNufn6h+i9hsSTaCNWNbOlP8ttf+JMwAMlMIZ4=; b=nQVHdeWdSVkcnIUSAD2sP2M2Xcjse6dKZY8AV56Li8fwbx1P0JmnOPVQYCjc1stAW/ +5Zy7yiIeAM70eET/IeDhw+pAkvQEIydEyEStsZsF/8uN5bNFYpTnpFliFkPNX6iiC+d 9vlynXLn9SpeQzikkuHYtbE7G1NlqlkqL6+nd+AFPZ5wOrFPe4A7ocebM8Y0NXqc0TSN Lp654envDzBKVsEwJFQ9MGnpiCwvvDOusfHsxZZy3zjwZyD0wrELkI+0cY2PCKQ7oYDL b9LYuW6LzQAanSPqvJOKUfntI6yUtfognyI9K74XGD6W3HVSDu1McD7ZoYGgWhXq+nhv 3G9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319395; x=1709924195; 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=Ud2dHcNufn6h+i9hsSTaCNWNbOlP8ttf+JMwAMlMIZ4=; b=qS77V8gYCiul+rDMJPwXCa58L7fspaxFTWJWK2LgV7/mnynazeIB5juEEn/E2j9WNr izKA/YmiVA7At5gxgBblhpgSuKQ371zKQIK8lfMU8RYgesMIqqeA4ftPRoeGjKG2Hvvc 28d9UbhfF9UdXU8RPlHeUyKIBbzoJsER8T35rh2o24VEujwh97OgZGqt/ItKM5i7OuEr p6o4OmN5RxxRCorMj649ud3S48qjPTY8RWQL3k/GtfgoWCSEwQQOHuPJOSB+aKEWGhjW KjihQ/Y2nfgXwaDM8DnfhwJM4s6kMjEij8tUBMTBLznFhZiwANDzZ/zzJB+dpoSjhtp9 bz7Q== X-Forwarded-Encrypted: i=1; AJvYcCU/aExCygAMZYj8JH8qaoqF/nhwPq8DXl6E+k7k2CRfGQZrH17j64XmfqnCIk0lml6+A0FlplEiglsVt5u9PsWeLPJc8HfLwLvP/Huf X-Gm-Message-State: AOJu0YwwiC1kq9ybFSerFVtRz+3E7r2DqDhzUkVHzW+3GB9gczQCZI8o f9eW6hlzdIPktcuMZCRQbqSc9Wa0hSSxra4P7dadO+W4bDErEiT9mgNoLo9IgSQgoaceituZT9p Kqp4mnw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a81:57d8:0:b0:609:51a3:b409 with SMTP id l207-20020a8157d8000000b0060951a3b409mr454389ywb.0.1709319395034; Fri, 01 Mar 2024 10:56:35 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:48 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-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: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 09/20] perf jevents: Add L2 metrics for Intel From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351457129571181 X-GMAIL-MSGID: 1792351457129571181 Give a breakdown of various L2 counters as metrics, including totals, reads, hardware prefetcher, RFO, code and evictions. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 158 +++++++++++++++++++++++++ 1 file changed, 158 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 49b83bc28891..9f42b489a81e 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -272,6 +272,163 @@ def IntelBr(): description="breakdown of retired branch instructions") +def IntelL2() -> Optional[MetricGroup]: + try: + DC_HIT = Event("L2_RQSTS.DEMAND_DATA_RD_HIT") + except: + return None + try: + DC_MISS = Event("L2_RQSTS.DEMAND_DATA_RD_MISS") + l2_dmnd_miss = DC_MISS + l2_dmnd_rd_all = DC_MISS + DC_HIT + except: + DC_ALL = Event("L2_RQSTS.ALL_DEMAND_DATA_RD") + l2_dmnd_miss = DC_ALL - DC_HIT + l2_dmnd_rd_all = DC_ALL + l2_dmnd_mrate = d_ratio(l2_dmnd_miss, interval_sec) + l2_dmnd_rrate = d_ratio(l2_dmnd_rd_all, interval_sec) + + DC_PFH = None + DC_PFM = None + l2_pf_all = None + l2_pf_mrate = None + l2_pf_rrate = None + try: + DC_PFH = Event("L2_RQSTS.PF_HIT") + DC_PFM = Event("L2_RQSTS.PF_MISS") + l2_pf_all = DC_PFH + DC_PFM + l2_pf_mrate = d_ratio(DC_PFM, interval_sec) + l2_pf_rrate = d_ratio(l2_pf_all, interval_sec) + except: + pass + + DC_RFOH = Event("L2_RQSTS.RFO_HIT") + DC_RFOM = Event("L2_RQSTS.RFO_MISS") + l2_rfo_all = DC_RFOH + DC_RFOM + l2_rfo_mrate = d_ratio(DC_RFOM, interval_sec) + l2_rfo_rrate = d_ratio(l2_rfo_all, interval_sec) + + DC_CH = Event("L2_RQSTS.CODE_RD_HIT") + DC_CM = Event("L2_RQSTS.CODE_RD_MISS") + DC_IN = Event("L2_LINES_IN.ALL") + DC_OUT_NS = None + DC_OUT_S = None + l2_lines_out = None + l2_out_rate = None + wbn = None + isd = None + try: + DC_OUT_NS = Event("L2_LINES_OUT.NON_SILENT", + "L2_LINES_OUT.DEMAND_DIRTY", + "L2_LINES_IN.S") + DC_OUT_S = Event("L2_LINES_OUT.SILENT", + "L2_LINES_OUT.DEMAND_CLEAN", + "L2_LINES_IN.I") + if DC_OUT_S.name == "L2_LINES_OUT.SILENT" and ( + args.model.startswith("skylake") or + args.model == "cascadelakex"): + DC_OUT_S.name = "L2_LINES_OUT.SILENT/any/" + # bring is back to per-CPU + l2_s = Select(DC_OUT_S / 2, Literal("#smt_on"), DC_OUT_S) + l2_ns = DC_OUT_NS + l2_lines_out = l2_s + l2_ns; + l2_out_rate = d_ratio(l2_lines_out, interval_sec); + nlr = max(l2_ns - DC_WB_U - DC_WB_D, 0) + wbn = d_ratio(nlr, interval_sec) + isd = d_ratio(l2_s, interval_sec) + except: + pass + DC_OUT_U = None + l2_pf_useless = None + l2_useless_rate = None + try: + DC_OUT_U = Event("L2_LINES_OUT.USELESS_HWPF") + l2_pf_useless = DC_OUT_U + l2_useless_rate = d_ratio(l2_pf_useless, interval_sec) + except: + pass + DC_WB_U = None + DC_WB_D = None + wbu = None + wbd = None + try: + DC_WB_U = Event("IDI_MISC.WB_UPGRADE") + DC_WB_D = Event("IDI_MISC.WB_DOWNGRADE") + wbu = d_ratio(DC_WB_U, interval_sec) + wbd = d_ratio(DC_WB_D, interval_sec) + except: + pass + + l2_lines_in = DC_IN + l2_code_all = DC_CH + DC_CM + l2_code_rate = d_ratio(l2_code_all, interval_sec) + l2_code_miss_rate = d_ratio(DC_CM, interval_sec) + l2_in_rate = d_ratio(l2_lines_in, interval_sec) + + return MetricGroup("l2", [ + MetricGroup("l2_totals", [ + Metric("l2_totals_in", "L2 cache total in per second", + l2_in_rate, "In/s"), + Metric("l2_totals_out", "L2 cache total out per second", + l2_out_rate, "Out/s") if l2_out_rate else None, + ]), + MetricGroup("l2_rd", [ + Metric("l2_rd_hits", "L2 cache data read hits", + d_ratio(DC_HIT, l2_dmnd_rd_all), "100%"), + Metric("l2_rd_hits", "L2 cache data read hits", + d_ratio(l2_dmnd_miss, l2_dmnd_rd_all), "100%"), + Metric("l2_rd_requests", "L2 cache data read requests per second", + l2_dmnd_rrate, "requests/s"), + Metric("l2_rd_misses", "L2 cache data read misses per second", + l2_dmnd_mrate, "misses/s"), + ]), + MetricGroup("l2_hwpf", [ + Metric("l2_hwpf_hits", "L2 cache hardware prefetcher hits", + d_ratio(DC_PFH, l2_pf_all), "100%"), + Metric("l2_hwpf_misses", "L2 cache hardware prefetcher misses", + d_ratio(DC_PFM, l2_pf_all), "100%"), + Metric("l2_hwpf_useless", "L2 cache hardware prefetcher useless prefetches per second", + l2_useless_rate, "100%") if l2_useless_rate else None, + Metric("l2_hwpf_requests", "L2 cache hardware prefetcher requests per second", + l2_pf_rrate, "100%"), + Metric("l2_hwpf_misses", "L2 cache hardware prefetcher misses per second", + l2_pf_mrate, "100%"), + ]) if DC_PFH else None, + MetricGroup("l2_rfo", [ + Metric("l2_rfo_hits", "L2 cache request for ownership (RFO) hits", + d_ratio(DC_RFOH, l2_rfo_all), "100%"), + Metric("l2_rfo_misses", "L2 cache request for ownership (RFO) misses", + d_ratio(DC_RFOM, l2_rfo_all), "100%"), + Metric("l2_rfo_requests", "L2 cache request for ownership (RFO) requests per second", + l2_rfo_rrate, "requests/s"), + Metric("l2_rfo_misses", "L2 cache request for ownership (RFO) misses per second", + l2_rfo_mrate, "misses/s"), + ]), + MetricGroup("l2_code", [ + Metric("l2_code_hits", "L2 cache code hits", + d_ratio(DC_CH, l2_code_all), "100%"), + Metric("l2_code_misses", "L2 cache code misses", + d_ratio(DC_CM, l2_code_all), "100%"), + Metric("l2_code_requests", "L2 cache code requests per second", + l2_code_rate, "requests/s"), + Metric("l2_code_misses", "L2 cache code misses per second", + l2_code_miss_rate, "misses/s"), + ]), + MetricGroup("l2_evict", [ + MetricGroup("l2_evict_mef_lines", [ + Metric("l2_evict_mef_lines_l3_hot_lru", "L2 evictions M/E/F lines L3 hot LRU per second", + wbu, "HotLRU/s") if wbu else None, + Metric("l2_evict_mef_lines_l3_norm_lru", "L2 evictions M/E/F lines L3 normal LRU per second", + wbn, "NormLRU/s") if wbn else None, + Metric("l2_evict_mef_lines_dropped", "L2 evictions M/E/F lines dropped per second", + wbd, "dropped/s") if wbd else None, + Metric("l2_evict_is_lines_dropped", "L2 evictions I/S lines dropped per second", + isd, "dropped/s") if isd else None, + ]), + ]), + ], description = "L2 data cache analysis") + + def IntelPorts() -> Optional[MetricGroup]: pipeline_events = json.load(open(f"{os.path.dirname(os.path.realpath(__file__))}" f"/arch/x86/{args.model}/pipeline.json")) @@ -364,6 +521,7 @@ all_metrics = MetricGroup("", [ Smi(), Tsx(), IntelBr(), + IntelL2(), IntelPorts(), IntelSwpf(), ]) From patchwork Fri Mar 1 18:55:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209039 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp88509dyc; Fri, 1 Mar 2024 10:59:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVxkyp17yVVEwClQf2O7XBqmlYkofnOzSG5Pi7mrOUEK7pZKVVUiKTC0bKVlynAnfpD1AxwiZ6Ni7KV5l1y1ulzv8yutA== X-Google-Smtp-Source: AGHT+IFfHDe3JfCD3PNso7t+7o4dv8xu8dmApeb00O2pwr0a65XAQGMozswuUpe1MNDw2ynfUMAk X-Received: by 2002:a05:6402:17db:b0:566:41f4:a0ea with SMTP id s27-20020a05640217db00b0056641f4a0eamr1862895edy.37.1709319585133; Fri, 01 Mar 2024 10:59:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319585; cv=pass; d=google.com; s=arc-20160816; b=pwnD9VfAIBwjT6EHLOw2YsLKwnQP/4LAmdjIq2ZNK+EP75eosInaCP97Gz6/YnB1IC +XHoby8ia/33TFBKAGk3yMl6JdL3amJ2zpvBOEL+ivLbYqqrs9ts/ETDpPFNRkX25aYC W7hp2wSnVoH4JSmy0W4NO3lIgKdLCbO6SZfK9ZEb7o7d0Wjn9wp0CnELUijiQAhMdhFE aoHIHyhMAdZSNDxqEfehci9WrNsf0l3NmwsVKOCShyRG/tOesnPNFpuprLkuZhHya1Rv XEEo1aXeHDi7PMG3XY0zZL5A4yJFPKUPNwPuzbHBE52I/hWhOG3IzyHtptulvVTTcDlQ /HqA== 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=iy3P4uSPJWyjA65jWAIGgY8FhfJd7Bx8GKL8ekkcR6Q=; fh=qMF8dXFQu0Oteqj0I0WVb/Ki0ft+Gvo22h97g1bnoFU=; b=snoiBOB8SU2Z3DaTnLjJCLeXTECY874zYEL7l1zmoGPLyg2pyGEelMNRVTrODDv0ws Q7AJm7OMGwBiJjykZAoTFnbxt89xzaguiLBR3hmpjVGADI16VRHUPGaNDSkfzCMr/E2r MIou9ABGTQFpNUrT/6IZ6YKRdY0K/Oz2YmAKL78P7S28rzh+zmffXktJabEcJeKRomG/ 6U/dEDM10ruFHoETKsJNn0ktkk7x4s8Ws8XucjuUMi02jyb/QfE94oOUzYo3lXyGhXSE MAr0I3E2glwp0dwLDWF365Z4yggNrmokjoNHmDXfNiTC4PWhPTaW88eGjxZyzuGN9eHr HNFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="L4nbwjO/"; 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-88971-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88971-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 a22-20020a05640213d600b00563de7615c5si1635460edx.624.2024.03.01.10.59.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:59:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88971-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="L4nbwjO/"; 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-88971-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88971-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 BB2B31F26D23 for ; Fri, 1 Mar 2024 18:59:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD4A53A268; Fri, 1 Mar 2024 18:56:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="L4nbwjO/" 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 82E303D54C for ; Fri, 1 Mar 2024 18:56:40 +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=1709319402; cv=none; b=LXfNiOhRVdobecCa1UHSGdMvC6dIfAeY1Eujt+N+O3RMoZzUwJHQ8D/eBwxSr+ZCHELeOnfUwBZFpegtp+Ui89oOieLKukWJQFyBDZXwr7nsBBPvkL5hHytJlvU359iqLqHkJ3lio45ggjtsTwtn13d/zGR50CVCIV4suFZ2VDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319402; c=relaxed/simple; bh=ReQNa++yN3cks/OeqEJawBQb3bmDZtEAQZ6F6yRpdYg=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Vak3ruZdSLpwXX02AFhpXyHDCkZy9i5anmi5Otc9BA5TCNVCKd/6yY9l18odW5QZorGARxQ0E+TEOv+ZMMz+I6G/V6A9Quv/1Wnil5grjNQDYBpUDO6okTbgaNzKu1y0ZtGJ82SH+fz6rS7F1NbaAGvOK41lv7a1HL5tOphz9Ww= 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=L4nbwjO/; 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-5ee22efe5eeso42109697b3.3 for ; Fri, 01 Mar 2024 10:56:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319400; x=1709924200; 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=iy3P4uSPJWyjA65jWAIGgY8FhfJd7Bx8GKL8ekkcR6Q=; b=L4nbwjO/VhKmqGrtuMZOWgx/BX9nDeeT5vnXBovLI/TryzoT5hPLRoYL22lKsArbyn nmgI5GZWOqK2eAxs1Dxtssz7Af5fg8xBhbhNe7KG5wCgQqiRDfBqI1VzyobhjdAkbSSj 11rjv0YBc5ROdX/+SX5LscEGAD/Oxus2KlV2+Nrk4GSEcgOEhNRYAyYtPPBgvgtMluVl Y/BlRCJbTVDGlxadWyfI+ENzuBaGnqZFBxZQgCGOrTZXP2Wb/dYhKKQVmWINfwBML7zj DJD1i0w3i2nxg5RqZTV+/ZkUcjXBfNqLAt8e/1/xgtzp8YABZyvtsRNn4Dyqr3/ifOiY LgZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319400; x=1709924200; 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=iy3P4uSPJWyjA65jWAIGgY8FhfJd7Bx8GKL8ekkcR6Q=; b=r9XY7Mm/Ecefuv0F7rLhM+R6sRr5Z5Vnd6BxsMNLBFA3d94O5GYS50JgPgL8IkIsN3 p43ttrRx6cg983K7wogeRbShU/7T2Wp1AjI0KposzOCZdyWRTeBUYQ8Urb1G+O6VqFiU y7Z4oJk+Zgy+NCtPhcrxKiMJox/ufI8mEMyoPwS9piG3h/GG9SoolrbJO2Knj4d08BvN sHu+uR0wLPM8809aFQhW/U7gPrk56e7M0kA8+sApVfXXjNZy9PWGibrfp8NO+vx7yuUC pG/kUwvO95C2eeQhgqvMdlNc8atEYa7qHybrf8syYLcEZfqjb32ULpT9uFIMWrrQ1ezs +fMA== X-Forwarded-Encrypted: i=1; AJvYcCWeqMQd3wthCGhRZe2VbYJtS83fowPHPaFqOLEi9iP9yFuuPCakptAJc52dDON9iEJQRdsCbKa/uNm/tcCUqeyj2JipOzWeSFHFfRmD X-Gm-Message-State: AOJu0YxGd34pbIc8mYSBSHrlh0AVD14BEo+OsnuMhda3eAcBx7P7j8su kGsM//4om/y7ESPLK60ohY2BtUI2o3U8q9wI+dFMi9s7mn18XO8D5Z33JI+jnv+m/WpF3ql0xat xIJ/xMQ== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:690c:3387:b0:608:d499:3439 with SMTP id fl7-20020a05690c338700b00608d4993439mr467407ywb.7.1709319399748; Fri, 01 Mar 2024 10:56:39 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:50 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-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: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 11/20] perf jevents: Add ILP metrics for Intel From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351493326098448 X-GMAIL-MSGID: 1792351493326098448 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/intel_metrics.py | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 061914834cff..6f6d1cdf6649 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -272,6 +272,35 @@ def IntelBr(): description="breakdown of retired branch instructions") +def IntelIlp() -> MetricGroup: + tsc = Event("msr/tsc/") + c0 = Event("msr/mperf/") + low = tsc - c0 + inst_ret = Event("INST_RETIRED.ANY_P") + 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), core_cycles) for x in range(0, 4)] + ilp.append(d_ratio(inst_ret_c[4], core_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 IntelL2() -> Optional[MetricGroup]: try: DC_HIT = Event("L2_RQSTS.DEMAND_DATA_RD_HIT") @@ -604,6 +633,7 @@ all_metrics = MetricGroup("", [ Smi(), Tsx(), IntelBr(), + IntelIlp(), IntelL2(), IntelLdSt(), IntelPorts(), From patchwork Fri Mar 1 18:55:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209040 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp88742dyc; Fri, 1 Mar 2024 11:00:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV74yhyeVOrPr0OlPxVfXUWeq0qYw5xaWpcCyVDX0CW8X+T4X3l0S6Ounk/3c7lXdkMulEeBQ7pqVhoZTiUAON7t9nWBg== X-Google-Smtp-Source: AGHT+IFWvSJGdqv39dkQ6yElyzDy7hhL1XxQTHUCi8F98DaPLsYarfcPxSpUEGUgnMLaWc5bYnsW X-Received: by 2002:a17:906:a2cf:b0:a3d:9ed3:dd1f with SMTP id by15-20020a170906a2cf00b00a3d9ed3dd1fmr2224675ejb.18.1709319608323; Fri, 01 Mar 2024 11:00:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319608; cv=pass; d=google.com; s=arc-20160816; b=WpgzUbOXe/ddCclWUaYgPcDoFzaDaLELrWovjKVzxMoX5dU5iEGwdlJsGsGiv+F18c CfLRiMqgyzBgDFjGCNP2aEKd3tA5o8UGVqwQdxhlyXUTFYeG/7pDC7RrUFCPdF/ZQUYk 4DuE5QWoysc1ITJv5luiZHh4OpwWtCFHWJT0oTxH+L22qCCK1ek1Lji8pUZSlICB8xyS rw87uo7ttITg4bCNOsnBYaGai3JP/YIeSQSjIMGnw1s2zJHSa5dDvrVaHcv91A6CMBcd 2xzV9ONkMPv+gnrvpD0j0VZVuKBIADxwj391bxQZ52Y1xbayMZAx1lVFu7fAuKVOnHQO 0emw== 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=z8m41PXVl/EgCm4ozUPka7O+Ter4HT44OkTHNVK9970=; fh=3dylU9Occ0S2dlI4Vu4VreDvaQoJ8/eroqtjRRQr6Pw=; b=QunUzm7neG8vHULOKQ/RcFn158TcV+Vd9IbQbJgH205dyQCMOKXfokr6syjxAbCiEf G0u9p2CS+YESnM+jtwgKeyuSNUMhcjm3NuSTTAgYBIhNpw2qxoNaaz0xwMPgXMxk2J/n svqi6Auw01FEL2H/hw5xyydOxoNWmKxRAJJHbHeDjgGOK4LVbkotQcnuaJBtes03gOcW yz0gupO0NMYuiwtu0suloBzYuM9YHs+dRlXH6muc/+co3C5gh17dS8ZkTC3ebs6MylkA qHPe60XkPQ7SBmgTUEDh1Q6qPwmx3EzWswurOidmfDdBrd33bX+UWWHeZnuNa89YMAAy HVkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pwl7JyU6; 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-88972-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88972-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 i12-20020a1709061ccc00b00a4428be9907si1584473ejh.817.2024.03.01.11.00.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 11:00:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88972-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=pwl7JyU6; 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-88972-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88972-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 C14EC1F26E23 for ; Fri, 1 Mar 2024 19:00:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C1B2C3FB10; Fri, 1 Mar 2024 18:56:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pwl7JyU6" 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 1C3473EA8E for ; Fri, 1 Mar 2024 18:56:43 +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=1709319404; cv=none; b=SpPGWbQXaKfI8CpAdLgvOQ858qV0DqcWUWSGPBYW4R3LeVfDgWNkCUhZ9lRwC4HYQDkPPqWkYk0dqBsx6oDnqn6tdbpunPMIkhzI4swMIowlXPTougg2z7//f9woLc5UAGAiySTvM/XuyFXQr3M51Wg/0OVHBaKeRMtOsx+C2s8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319404; c=relaxed/simple; bh=g1aUKyrw7DvdgN01eaAjL5EDa8+hBV/p20E6Ldm6SxI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=A4ceDh66dSbku4oNGXhmw7OzMrT1aCs1tCdGglJplk/+6og5Z+r/GqRpu9lKaXgw8PMFXleFDG3Ik2BJSP5Y7V7vwEERM2RrwI9JkZnCajblM5XKN5kzsDIBFioSFm1CUXPYp9jAPXbIKITczYKUgTBTQrhwpFbBjktTvPOZSuo= 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=pwl7JyU6; 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-d9a541b720aso4374174276.0 for ; Fri, 01 Mar 2024 10:56:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319402; x=1709924202; 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=z8m41PXVl/EgCm4ozUPka7O+Ter4HT44OkTHNVK9970=; b=pwl7JyU6cGI+yxVc+r5x4UlyezDJq+503nQIbufqWvxoyj2cWEFhJSmTGpU5lLWTqz rmL9a9GCBLdLBhrX+90X1Vx+O/dNigkM2QmOdSQ9e3+ygqENydZwtRq79oqz9Ustoph7 gzl9SZYJKvZDaLFzBDjJV4ujoPtV+yqTFAam2yKZGtwvLX4ga9tv+b+hG8UUeeapoyCh 5JUv4BQcJMjrkigKANFPZb4WlxddY9tlxSZ6n34n8vHceHhUCvk9I20S103bxUu5tjUZ dCm5pAyaBGZQJRtsYML7L2MRmTRdml6pbFH2jIrR+ofz9rV5X4eLnuiJyr3lq1x7fl2Z lxbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319402; x=1709924202; 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=z8m41PXVl/EgCm4ozUPka7O+Ter4HT44OkTHNVK9970=; b=xTVWbSLUmELt+178WyEiZAJiurgucM06N8sRhNjE4pjMscYPz3tldU+qZJg9/P5I97 t0zOxAFsaFhK1s+D+1C+I8A0by+DR4HyoQ0lBJAX4Uwr7PgbcHnVRIcCZ8eMygwuTxmp gZ+99BG4SvNyUHcTlXw/s/ViOuK3m5TkuSiyo61lBskN1BYcjRmCJ48UY7RniG4VLmO4 8oqxDRtv1m04G3KK3s/1+/BkWnJfIOl6a6BrdLVFenVq0Mv49Ib8kxXma0fI0TAiTnoT UGc9fxFixc6DKplRRq7c2PJ7c3dFCWlSWgjrigTkW6g+YF/c19NmK/ZT8ek0e4bt5gwf ur3w== X-Forwarded-Encrypted: i=1; AJvYcCVBgh+mlMgyOmMPZt9h29Vds3Ep/sHXtxeDPqVXhI7TPi8jDOnxt8E5yln4IRz11aQBAkg868TyH8naBr8xgWdKFChmX6/vxiG9qwWj X-Gm-Message-State: AOJu0Yx0kACT8zrVA4mZWICpAjsDPXWqqymJRre3aKj/CLIg7UjD5Ent ytWRa+tYnSdnVrVxjMydinANbt/d777ongrxInMGaoyBOG/2DoifeAEG9hf1EgoEma2vxbNu6OW pEuHleA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:6902:120a:b0:dc6:f877:ea7b with SMTP id s10-20020a056902120a00b00dc6f877ea7bmr540903ybu.9.1709319402300; Fri, 01 Mar 2024 10:56:42 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:51 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-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: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 12/20] perf jevents: Add context switch metrics for Intel From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351517280356620 X-GMAIL-MSGID: 1792351517280356620 Metrics break down context switches for different kinds of instruction. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 55 ++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 6f6d1cdf6649..49e51c33c0f7 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -272,6 +272,60 @@ def IntelBr(): description="breakdown of retired branch instructions") +def IntelCtxSw() -> 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")) + + try: + ev = Event("MEM_INST_RETIRED.ALL_LOADS", "MEM_UOPS_RETIRED.ALL_LOADS") + metrics.append(Metric("cs_loads", "Loads per context switch", + d_ratio(ev, cs), "loads/cs")) + except: + pass + + try: + ev = Event("MEM_INST_RETIRED.ALL_STORES", "MEM_UOPS_RETIRED.ALL_STORES") + metrics.append(Metric("cs_stores", "Stores per context switch", + d_ratio(ev, cs), "stores/cs")) + except: + pass + + try: + ev = Event("BR_INST_RETIRED.NEAR_TAKEN", "BR_INST_RETIRED.TAKEN_JCC") + metrics.append(Metric("cs_br_taken", "Branches taken per context switch", + d_ratio(ev, cs), "br_taken/cs")) + except: + pass + + try: + l2_misses = (Event("L2_RQSTS.DEMAND_DATA_RD_MISS") + + Event("L2_RQSTS.RFO_MISS") + + Event("L2_RQSTS.CODE_RD_MISS")) + try: + l2_misses += Event("L2_RQSTS.HWPF_MISS", "L2_RQSTS.L2_PF_MISS", "L2_RQSTS.PF_MISS") + except: + pass + + metrics.append(Metric("cs_l2_misses", "L2 misses per context switch", + d_ratio(l2_misses, cs), "l2_misses/cs")) + except: + pass + + return MetricGroup("cs", metrics, + description = ("Number of context switches per second, instructions " + "retired & core cycles between context switches")) + + def IntelIlp() -> MetricGroup: tsc = Event("msr/tsc/") c0 = Event("msr/mperf/") @@ -633,6 +687,7 @@ all_metrics = MetricGroup("", [ Smi(), Tsx(), IntelBr(), + IntelCtxSw(), IntelIlp(), IntelL2(), IntelLdSt(), From patchwork Fri Mar 1 18:55:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209042 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp89135dyc; Fri, 1 Mar 2024 11:00:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXNL/xghMac/DXNK0gckacIoHIowu5NvXxrYgeS1bLIH2qg2l0K887YqgkBnTY0o0aqCzDToqJyRaAN6ndPigz2y9mZVg== X-Google-Smtp-Source: AGHT+IEqOD0BeVZX2QpHDhzyKimWmf6TKtV64Ry0iIS1xDBb3hnTsrev4gP0lEyYcjA6duReg7c6 X-Received: by 2002:aa7:88c5:0:b0:6e4:f4b4:9ea2 with SMTP id k5-20020aa788c5000000b006e4f4b49ea2mr3149180pff.32.1709319636553; Fri, 01 Mar 2024 11:00:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319636; cv=pass; d=google.com; s=arc-20160816; b=qvNg3MQbURczA5DAq2NraeM4qXVwtZfBQtWg/iiz4edHVaK2Jy2QrdA5r/PDv+GECC d/Bvu80sHfTLw3ra7z8WluJZU5lYG227uYktDOebsa2T4LofnXXIvAtiQMcqwZ4S11yc NB966SnCY1abpxm/Rs4YcXlHjHjOfw7ATan4bC1A6eDzrZhiq2qsXnYfUdrSuuzVsEA5 Oljzq28p55bn5XQS++odAHBFdZ7ySlfQpFfwXvpXu82L2Kj8MXtxraT59sAnlufOpXS7 6SkVNdd+Iuu0CSSiyDKz0g83l9RNkpTHdf1jGmHlYzmsUpoPdtIA2bEFaUkewTrfymZQ 0ytw== 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=j29r0+uRis6oMNX35QsnEUIN73H3JiunuyPnByIi9hc=; fh=4KK8RPeI4pL/TzSp18+RSCLAVPsYiKgdwWkcuZ3CAAM=; b=f53AqyF7i9tQP0C+8AvB1PX6C9aOeVUHrFHvF70x2fllsDlwErlyxVNgzAre25CNY4 cTEqqkg9kNGliFmfGQ8L/J3HVisp+Be0IBfVVEb3kOWesHYTrOLBMmxz9rRj9AZZ74qx aHg7DRgY+0wyUqOgjZaR0+FS5HmmsmJNDC5ETYO3kKu3PQQsxg4w2r69VYMtkGrMIn+n vWVOnyNesp3Dqc+WEfiJG9mXJrQIsXYaNp9H+/PkRbnOItXP51r/c/MN7u3n4bAui3Bw K0z4Pe/3C5P12ARpVnR1cEWuIMPPNSi4CifNV12lHTRr9eTjrjfOt16eZMev7JuZZHNR AF5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ytYvK3rB; 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-88975-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88975-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 v10-20020a056a00148a00b006e5a2456e80si3323472pfu.127.2024.03.01.11.00.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 11:00:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88975-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=ytYvK3rB; 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-88975-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88975-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 5980A285C09 for ; Fri, 1 Mar 2024 19:00:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F827482D0; Fri, 1 Mar 2024 18:56:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ytYvK3rB" 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 EE85A3AC19 for ; Fri, 1 Mar 2024 18:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319410; cv=none; b=vBd20cUiwdE3LkXrNby7k+4FG3wcj/ENxtD87BZgfmdacJbH7/C39yxiRgTIN9YENM/1Es5qR05+oth59XV0JiAC4H0iFgbbSyVu0SpUX4hlSNylsWlbCBsbIBpIk3+46ptNVcNEjPQ2pytCZ/fLj0ts/oeN0WdDHlJsIcGgpG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319410; c=relaxed/simple; bh=ioqKuJWewNQmhIwOmTO7CGCh23AwMW0/VlYh24IVFkw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=GmCGVc6toxoyjqmtZAQtptH4j3/gsYaa9nRtj4M+0n+LkCiwgEMP1NSMD9YEBDkr4zg4eF52gb5O47KOIziZZncZ4DI+rvtfcFaOUASDcPwhZ88DY2p8hVmhdd6TZWbXMao+Ry1v3KeqEA8FGH7xzHASl7PM5psh2QcI9eUVkGk= 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=ytYvK3rB; 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-607e56f7200so24206407b3.2 for ; Fri, 01 Mar 2024 10:56:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319408; x=1709924208; 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=j29r0+uRis6oMNX35QsnEUIN73H3JiunuyPnByIi9hc=; b=ytYvK3rBsX0Y2xqWdG6ypjs6MFmehN1zGOP61V9132ZQxdSB+NqJWqzQ9MquNI40cJ 43EFc0wrRcvUy591bRGSYM//rGz6O81MeEea8sTehq67xfZo83qac3ISFzCYlDO/6BNm mKlYjzWUxrav2GqG7eaMf+mrwv9Sk5VYxfrw5nDGmEa0TQD0ahJkYLFtSshMjB2JcNkF 3Cv+G0IgNKYv4gMILjDoyPv+VantE5Bp2YGu/SnBRWW+HYz1Ho2fSwpWC9grALa7sBsx oEBv8ODNAp84NlTflDKLW+zh0bpsbjvMEM4eBSkL8iitjtE+B8B04x8e54/kDzFIzISH S7Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319408; x=1709924208; 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=j29r0+uRis6oMNX35QsnEUIN73H3JiunuyPnByIi9hc=; b=KI81BH5iXXASEaO4Vvi0RTBtljYro5VcDA/Zz5f5ofS2vXUL15jQhANFlSJcaPywqU GYZXScQENLh0fRJ2ArSm878DocQJiGPE3WQmr/PI/wCKhvjxeNTSOx0LFnZQLr8UGIHV Wk1ztytaQYtgek4ULTPwBl8FbK+2wzznCgcWuGTe4ZaQ6aIUV/mGQCPKirierXT0FbiS HIO1oqK3pOoZM4JvfRjoFln3glW1W96y+RnTW2vsqClNPRTs3p+ITSjQqvf1ZRo6m94P niSGr8ODVVLKtNDcLaIR13qZar+Qz1CDbm9I2kR94A4Z+Pl6HXoSKpZJz1a5Cq43HJ5p fiog== X-Forwarded-Encrypted: i=1; AJvYcCUQyZKa8ixd47H7htkwbPxpjZrgVfJy3XyBWjRfknEvuLk0Hn6R+nXbrXMMrsVVrIpP7YiedNyZp0EY7mGnA7rvJdvH8/M0xBTk3Ugl X-Gm-Message-State: AOJu0Yxr4Py+jyU4lqOLME27lbfORkF3ofqTxnnpx9TT1pRglJS8uDQb G+LORIic8xO9yIoUFpyw+ViEKaOersXfJvzdyz1j7F4iPGoK9h9sO+2Fp3K+GKe6vM+uKfWIpJV /C36S5g== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a81:9950:0:b0:609:4d6f:7c0b with SMTP id q77-20020a819950000000b006094d6f7c0bmr473405ywg.4.1709319408201; Fri, 01 Mar 2024 10:56:48 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:53 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-15-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 14/20] perf jevents: Add Miss Level Parallelism (MLP) metric for Intel From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351547429142852 X-GMAIL-MSGID: 1792351547429142852 Number of outstanding load misses per cycle. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 6f18d5fd9f95..2cd30c557a59 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -601,6 +601,20 @@ def IntelL2() -> Optional[MetricGroup]: ], description = "L2 data cache analysis") +def IntelMlp() -> Optional[Metric]: + try: + l1d = Event("L1D_PEND_MISS.PENDING") + l1dc = Event("L1D_PEND_MISS.PENDING_CYCLES") + except: + return None + + l1dc = Select(l1dc / 2, Literal("#smt_on"), l1dc) + ml = d_ratio(l1d, l1dc) + return Metric("mlp", + "Miss level parallelism - number of outstanding load misses per cycle (higher is better)", + ml, "load_miss_pending/cycle") + + def IntelPorts() -> Optional[MetricGroup]: pipeline_events = json.load(open(f"{os.path.dirname(os.path.realpath(__file__))}" f"/arch/x86/{args.model}/pipeline.json")) @@ -781,6 +795,7 @@ all_metrics = MetricGroup("", [ IntelIlp(), IntelL2(), IntelLdSt(), + IntelMlp(), IntelPorts(), IntelSwpf(), ]) From patchwork Fri Mar 1 18:55:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209043 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp89642dyc; Fri, 1 Mar 2024 11:01:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWo1kS5HmAoeg6taNKakaaDzcytdgvGgyVC+oV0yoq6qTUAvpIWEFU65KxxfhhfwzDHZ2YOYntZReKyDgozGzhONlbJBw== X-Google-Smtp-Source: AGHT+IHhD+QJJoJdsEwLh4tCXS/zburWd4I07tJq6O+THCMccM8GvKyJG5MM8Qpt/FVXoTDAyI0Q X-Received: by 2002:a0c:e80d:0:b0:690:3c85:c5c with SMTP id y13-20020a0ce80d000000b006903c850c5cmr2925006qvn.46.1709319669790; Fri, 01 Mar 2024 11:01:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319669; cv=pass; d=google.com; s=arc-20160816; b=R03CZfcmVkG+ilJf4y/7kOgJFiuCAkRwSNy8Ie9Lhc+6Zkpa7H45d2pXjsp5S824kP dCezRYDunJ4rLmX9OfLStLHZmdrDzupHXWcYcB4yz8kaO8KwB3oYxGrtjl5IoAf667+z Q+zIr/TeTUil2qHQ2y9kPBUOLV4uNU4726SHDAdsRiQ3fkwKrXbIaQ/3iTruX03pE7ys GcCzmNwP5e9ATHi12ObOMdQUaOUn716Mjpmb0DNnMM/Kur1O+sgml3/65m/6lbzIr5Ps Ivp+kiZHYfWbh+IrOu5zOrlvtvIr1LwWWMS4Iy7s63xeuQchhozUP1mLyjHewM0FkIfH 9luA== 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=K9VN6M4iHhNGfXDgUsA95lPgDC+51/4VBbMVT4/EKng=; fh=sQ2Hr89PrL81ZCiIvfyLMVpXIE1+KwDIB85PHxkbXD8=; b=IysxV6kfh2UOS/zzc8XwsXlUXLkwfVh4OuXThXFi9/IDt57dF60FWlB3O229eoIdDv 4NIzUPoZIJNlqQ3G0GAaWsCNiXDkje2mwz2YnJ8iYgqDX0nukrBXyKW/uQIvjQZzAnYE 8fmYuPq6j3bex5oMETgx0SXf9KXF4FwWAD6HBuXVFrVJU3Co824t89c5CSV8Mr2nk8J6 2+6xu02ym+jjj9YKfTBdjMQNdq11E5a1U6lvD7sijH6j4Z42ofoQC31E4axE4FqO3np7 gvq9dEBpgktkZ5KKQIUoUlYTrtedBZ6qoxU+JapOe0+eqfmOCC/KOHZRi96c4C3A58Mw QmKw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=05HGQoF1; 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-88976-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88976-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. [147.75.199.223]) by mx.google.com with ESMTPS id 4-20020a0562140d0400b0068f59455cf3si4071391qvh.606.2024.03.01.11.01.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 11:01:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88976-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=05HGQoF1; 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-88976-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88976-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 7834E1C252A5 for ; Fri, 1 Mar 2024 19:00:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08C004DA10; Fri, 1 Mar 2024 18:56:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="05HGQoF1" 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 6CFE345018 for ; Fri, 1 Mar 2024 18:56:51 +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=1709319412; cv=none; b=Zu55y0KLuoUBFCpDxYfivm7Bt2kviAaReikLMJ+6cwUOqfmtrRkqDBIfCD4XE7Ug6eCli/5cQ+0eaGAIgI9BujvUp4CyWuY2dzv7Rfypu5I91cHaWOHC1uMLgCi/JAF2QjgQIRiT2QK0cTpcCuCDkrj4rQ2pCuIeK0XZg6pqW6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319412; c=relaxed/simple; bh=panIrCvcM8hwmTL6w73OOIwaBmO4XEVl+dEJoBh+wK8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=jT5MeZULZhb/jI2/bvzX3uSj2HB+KaO/qZ9gHT4poHvPKERR0UjuN2tBFiIEqhParhVrGNL3A/xmQPRgf7xRbsssjc+vk/ac3LNPu0VFMXLJM1sNgmCBeyShFg1FvRd9j5HcII6tx1wtak8ZtaGMRW138gn4Ow2ksNNeGyQSxsQ= 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=05HGQoF1; 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-608ac8c5781so43335857b3.3 for ; Fri, 01 Mar 2024 10:56:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319410; x=1709924210; 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=K9VN6M4iHhNGfXDgUsA95lPgDC+51/4VBbMVT4/EKng=; b=05HGQoF1lQ+Rph0uRkJXdPfSSIX43pdvwKamXL16jErTuwF0wTiu5xSjQV1VLdiDBG u/W2kw1B3MoLa7XDrKC1dVQoYxFcgQhURbqVcn40wBzDuBV6eeGqndPxmaRA4Mfkgx6J yoCiWp+DlM5SEYhpjAD7lUyUNrY3ioliFtGhWs0Ka6PCI4Pji6OLeaXo+9vCJxEADgoc vPF0ybl3XqmLUBtOJaf/rneqVl4xTNEb3eEHYIjHfIGfZULfuMdq7iwYCh27F7Ne5rt4 1/2Z+mZ+8JgMww/1zhZzP5OLa+y007lTDu9XAHfijFMslBEt3L8Iegr+16/pCbzIDSgF MJ7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319410; x=1709924210; 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=K9VN6M4iHhNGfXDgUsA95lPgDC+51/4VBbMVT4/EKng=; b=a8tHpfpBxr/dVxtx1Up1/2zCUz+yPffUw1s1fIT5DqD1ShtqH5dIK/DidHa0fdDJbN DVT6ESjOu5aHjJ84/4iB4uv0Q7X65HA5vDa3i2blRQy+hcL4VLFITqUN63UoQUjmTHVP UaWqfQ+CTQrftIVvxfB+/DgKvVpANcbBWz9i0yCXksC2Xcckc5V/s6JGjoTRo0SbFRCZ eEEpU8VaKtsNSH3lRRlUOjj5Vj2xPHRv2VH1AuiKmkx44tpx5gDjmWnkcx5/Xr7YV3mE jGMApPr/kY+MD/X3UkqGKc5QiNb81jfepWP6w4CV891n4jjf3h9a9LyNR82ZqdlO7YTY 6M/g== X-Forwarded-Encrypted: i=1; AJvYcCVHI7z+mqJ+n+6PDf0tJWnRm5UUBwHBxfKSUvTpOW/fDb3IQR10Zt+ijUaQTRP2YhPMgqs9OdDIZh+CepAq/Rq95NfahUCA6p0O4rlj X-Gm-Message-State: AOJu0YznDy7R7MsF/4t/qTchwwOAw6+zZuUNgulIu4MnxsYZGxSMXwDL Bj6JQk2AhZlvDD6AE/MbIMIIYR3tvLrJI/Ldfy+vfLama2T9sy2bXE+bYfxT4iIQCV5xYt0eRFr 07OO7Fw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:690c:85:b0:609:3cdf:c737 with SMTP id be5-20020a05690c008500b006093cdfc737mr528497ywb.10.1709319410636; Fri, 01 Mar 2024 10:56:50 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:54 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-16-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 15/20] perf jevents: Add mem_bw metric for Intel From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351582539665256 X-GMAIL-MSGID: 1792351582539665256 Break down memory bandwidth using uncore counters. For many models this matches the memory_bandwidth_* metrics, but these metrics aren't made available on all models. Add support for free running counters. Query the event json when determining which what events/counters are available. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 62 ++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 2cd30c557a59..a5d68b7deab3 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -784,6 +784,67 @@ def IntelLdSt() -> Optional[MetricGroup]: ], description = "Breakdown of load/store instructions") +def UncoreMemBw() -> Optional[MetricGroup]: + mem_events = [] + try: + mem_events = json.load(open(f"{os.path.dirname(os.path.realpath(__file__))}" + f"/arch/x86/{args.model}/uncore-memory.json")) + except: + pass + + ddr_rds = 0 + ddr_wrs = 0 + ddr_total = 0 + for x in mem_events: + if "EventName" in x: + name = x["EventName"] + if re.search("^UNC_MC[0-9]+_RDCAS_COUNT_FREERUN", name): + ddr_rds += Event(name) + elif re.search("^UNC_MC[0-9]+_WRCAS_COUNT_FREERUN", name): + ddr_wrs += Event(name) + #elif re.search("^UNC_MC[0-9]+_TOTAL_REQCOUNT_FREERUN", name): + # ddr_total += Event(name) + + if ddr_rds == 0: + try: + ddr_rds = Event("UNC_M_CAS_COUNT.RD") + ddr_wrs = Event("UNC_M_CAS_COUNT.WR") + except: + return None + + ddr_total = ddr_rds + ddr_wrs + + pmm_rds = 0 + pmm_wrs = 0 + try: + pmm_rds = Event("UNC_M_PMM_RPQ_INSERTS") + pmm_wrs = Event("UNC_M_PMM_WPQ_INSERTS") + except: + pass + + pmm_total = pmm_rds + pmm_wrs + + scale = 64 / 1_000_000 + return MetricGroup("mem_bw", [ + MetricGroup("mem_bw_ddr", [ + Metric("mem_bw_ddr_read", "DDR memory read bandwidth", + d_ratio(ddr_rds, interval_sec), f"{scale}MB/s"), + Metric("mem_bw_ddr_write", "DDR memory write bandwidth", + d_ratio(ddr_wrs, interval_sec), f"{scale}MB/s"), + Metric("mem_bw_ddr_total", "DDR memory write bandwidth", + d_ratio(ddr_total, interval_sec), f"{scale}MB/s"), + ], description = "DDR Memory Bandwidth"), + MetricGroup("mem_bw_pmm", [ + Metric("mem_bw_pmm_read", "PMM memory read bandwidth", + d_ratio(pmm_rds, interval_sec), f"{scale}MB/s"), + Metric("mem_bw_pmm_write", "PMM memory write bandwidth", + d_ratio(pmm_wrs, interval_sec), f"{scale}MB/s"), + Metric("mem_bw_pmm_total", "PMM memory write bandwidth", + d_ratio(pmm_total, interval_sec), f"{scale}MB/s"), + ], description = "PMM Memory Bandwidth") if pmm_rds != 0 else None, + ], description = "Memory Bandwidth") + + all_metrics = MetricGroup("", [ Idle(), Rapl(), @@ -798,6 +859,7 @@ all_metrics = MetricGroup("", [ IntelMlp(), IntelPorts(), IntelSwpf(), + UncoreMemBw(), ]) if args.metricgroups: From patchwork Fri Mar 1 18:55:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209046 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp90574dyc; Fri, 1 Mar 2024 11:02:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUULiuFs357aI9tc8RcsSAk3r6UWn55bm36/d4G4I/K8Hg4FpeC6O7tbh/E1xVjkUksllvAgMl59XNSxH4HdO/J1r90Dw== X-Google-Smtp-Source: AGHT+IFqWcvVZ1lQdwB4LB6suGY3o/6U30Igs16j666nmL0vTdlA4uXmPvwnB5S3e1FAl2bXBsUw X-Received: by 2002:a17:903:2282:b0:1db:faa6:d4b3 with SMTP id b2-20020a170903228200b001dbfaa6d4b3mr3183353plh.11.1709319730773; Fri, 01 Mar 2024 11:02:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319730; cv=pass; d=google.com; s=arc-20160816; b=pUOVTmcBL7JnW1eTOjAvCPi7L2wY24HeBeWlsSKqvMjFxDRdrElcm/T9y8r55VU0Ri 4lV79R/0BpbfgaiDaVxjOpZWAaKCSoHq5TdKpFi0+WbCaXN2gh4THQkRrmbwzT8LQECn lVRfQntskRZlKijDV7z0tkqJ5zzkr+TZQy698HQcGRPeN6ZHU8rtnW8WdGsxvhy1tQ07 RfVyzzJNY6u8HojSk3WiHiR9kyO68IR6B6rRLo4PnBRXh/Hs8+Es6OFBT0dvZC+hgAUA lK8u6FrrSAxt2sJamHUvm/waOgzZa3mq46Mkyg8Uibn39HEDFWoJz27XjdUzxokTjs3F dLdQ== 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=wDxjwfTbKIrn1N686Z4rZ9XKDC8dsWniG1Tg4NyRgEw=; fh=8zX9Rno4LX0rmEjxSh9eRX8eYXjpZbAYqkafnXwcolQ=; b=llLDVM2H+QVJzYucbIgQlF4uhNTipINwo3jPeI1GY2VOvFIUkiO+bjUQWz84xDmRne 5G0A2xRr7rnDZQxzBw2s0yDt/O+OZa1yrGT3govixppUWIjZ7iTJjCkLC2P1Xqh9b7wV wb6Jod//SkgACm+rvlcnczmqeO/LxOzoHjhiL6HPN2lKDAqxmZr/QUxruCsv4wlzbNmP rbsrI57YtAMRUgodaATw79EeUpkBv+vbz0wro9O9qf3RmU4itsyyMWScxTjcCdSEbf67 wVHMBE7hmPq6YNtwXfh468vCA5O08QPx7nfG/j66jYPme+OEUurZZlPn/gbkSmq4+SCu n/xA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=a+yRUIUF; 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-88977-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88977-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 q8-20020a170902a3c800b001dbfaa6d4absi3910561plb.596.2024.03.01.11.02.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 11:02:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88977-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=a+yRUIUF; 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-88977-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88977-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 9B075284141 for ; Fri, 1 Mar 2024 19:01:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A0353B1B7; Fri, 1 Mar 2024 18:56:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="a+yRUIUF" 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 465574CB4E for ; Fri, 1 Mar 2024 18:56:53 +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=1709319415; cv=none; b=NMKIIuii+ajmDi7Rq9zk2iBIDuxFhBB4PqBdgqZsrX3eJkuFsA323I8+ReNXtR5h+vPCfCYdq8rCmY+YEwlDjo1pZaNcvfXZcq+BG2fpolNMIsxfetq3TkT0MFOFiDlSZS1lZPKZEQnLSVLBIJ1Ul6HXTu4w8SUYtUKqwZJNeFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319415; c=relaxed/simple; bh=zsfAdzqNvQWvzalFsOpTfd82DF9L2jXbTJgB7wNHPc8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=M6IuXzAOTiHp72q10cm7qIZ385ElXbrB677psIkHU2rL65tgtgtLA+q2Y4TSCTf0PBcPg+duCcuCp6QaEvO5fXBhdg8aKEGnr9br5xWuvREuUm+UdM38T/wf+3aXoXutrfxoYx3PY8Rd5Q0jb0YUptSRZ1aHx0cJfs3EwYCM4zA= 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=a+yRUIUF; 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-6097409275bso30731897b3.0 for ; Fri, 01 Mar 2024 10:56:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319413; x=1709924213; 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=wDxjwfTbKIrn1N686Z4rZ9XKDC8dsWniG1Tg4NyRgEw=; b=a+yRUIUFKsAJv/B0w7AxZau5Xx1UytXkK3u0j2iJROfZs1+V3G+S10phf/n8yUEwr3 n2b0hUq5oOZ7Zs+63zWKb4yDHlEq5VfCtvh+8tYh5DeD+0OBVPDckcfzh2eXIIAUEzGx +apCXwgzOwPjSJjWBva0cHRi1Xa/aJfO7kQ2rlp+uKgZep+RQZUOtXZVlaygx3pKF9p7 oLZ6TUoVukkNBsQ2g3LTcYJQeE4I7B42INvCUaCNtUrAZ0y+l1EiV6zYlgdCx1nLnqmL FT52innv/qBw6UuIfj5ViVtl6Lc8m4iaI4A3dvgFoP3SSR19XauY/+MYos9oOPcW1gdg Orag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319413; x=1709924213; 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=wDxjwfTbKIrn1N686Z4rZ9XKDC8dsWniG1Tg4NyRgEw=; b=CpDpMIOq1PjT/XWm0ZZsqmHeQy3K4vtoY7v+Cjehgyx2Zt3RewZIrRC1roRZlh9kEe N9k/hH5BYOD+/3uI88/ntIr6YN6OdUr49G2EjrxxVFxLBn0+ixR8eiYG/JDnbP2BvzIC ncZUAA7nOxYbMx3jEYYe4urkqjtJq26udfdz9NeaNy9yZI0wtrsW8nArqi3s1Zl0BIZl li/Iebe5k32C3Pa3FM1tThkZD4K9sZXlEBEKz8V5Izg4rYxZ0kGSjmtqrwrCqr03ddVL pciTwV60ifGJuz4dTbB9bMQ8oHLXNiIZU8q3uolfoJKOZqFOgV1i7RaSIRi609jjGe0r CbCg== X-Forwarded-Encrypted: i=1; AJvYcCU6s/RBD/k5bNNzrmYVyRA3C9wmCIBRYS4VQCPQHmesvqj6aa2SaW9gl5TGf51AfBSDLPZzT8vE0onNKHieXz4O5UeM5JCefgPrEu/s X-Gm-Message-State: AOJu0YyX6TypmT6MESh86QGzhBod25WJZ3dxLBwPXFmFYZ9sgiiJ74VE Vih2e6d5yBcOF2L6VkWOa0lXEWnjnXBaQZMbeJgRxVYRGi96X25yNzjGTE1J4VzN3cQjmlWRHDK wjmf3/w== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a81:9a05:0:b0:608:2ad5:cd28 with SMTP id r5-20020a819a05000000b006082ad5cd28mr464509ywg.4.1709319413260; Fri, 01 Mar 2024 10:56:53 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:55 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-17-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 16/20] perf jevents: Add local/remote "mem" breakdown metrics for Intel From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351645970496701 X-GMAIL-MSGID: 1792351645970496701 Breakdown local and remote memory bandwidth, read and writes. The implementation uses the HA and CHA PMUs present in server models broadwellde, broadwellx cascadelakex, emeraldrapids, haswellx, icelakex, ivytown, sapphirerapids and skylakex. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index a5d68b7deab3..76e71f11a579 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -784,6 +784,32 @@ def IntelLdSt() -> Optional[MetricGroup]: ], description = "Breakdown of load/store instructions") +def UncoreMem() -> Optional[MetricGroup]: + try: + loc_rds = Event("UNC_CHA_REQUESTS.READS_LOCAL", "UNC_H_REQUESTS.READS_LOCAL") + rem_rds = Event("UNC_CHA_REQUESTS.READS_REMOTE", "UNC_H_REQUESTS.READS_REMOTE") + loc_wrs = Event("UNC_CHA_REQUESTS.WRITES_LOCAL", "UNC_H_REQUESTS.WRITES_LOCAL") + rem_wrs = Event("UNC_CHA_REQUESTS.WRITES_REMOTE", "UNC_H_REQUESTS.WRITES_REMOTE") + except: + return None + + scale = 64 / 1_000_000 + return MetricGroup("mem", [ + MetricGroup("mem_local", [ + Metric("mem_local_read", "Local memory read bandwidth not including directory updates", + d_ratio(loc_rds, interval_sec), f"{scale}MB/s"), + Metric("mem_local_write", "Local memory write bandwidth not including directory updates", + d_ratio(loc_wrs, interval_sec), f"{scale}MB/s"), + ]), + MetricGroup("mem_remote", [ + Metric("mem_remote_read", "Remote memory read bandwidth not including directory updates", + d_ratio(rem_rds, interval_sec), f"{scale}MB/s"), + Metric("mem_remote_write", "Remote memory write bandwidth not including directory updates", + d_ratio(rem_wrs, interval_sec), f"{scale}MB/s"), + ]), + ], description = "Memory Bandwidth breakdown local vs. remote (remote requests in). directory updates not included") + + def UncoreMemBw() -> Optional[MetricGroup]: mem_events = [] try: @@ -859,6 +885,7 @@ all_metrics = MetricGroup("", [ IntelMlp(), IntelPorts(), IntelSwpf(), + UncoreMem(), UncoreMemBw(), ]) From patchwork Fri Mar 1 18:55:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209044 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp90063dyc; Fri, 1 Mar 2024 11:01:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVs9z87edZ0pAJFAFl+E+ojjbwWLCDVSPDil7f/LfpUwJ3ONkz+Y9Ic1BmsUOi9vRvwBAWTkRusAkq+MaTmWTjkYcEL3g== X-Google-Smtp-Source: AGHT+IG8P/kk/q9tg2WXnOsQM6jRr+DihZzQQGFAjS4+ts7DHgEhDgnQbajFJICnZvp6XbyFfl5I X-Received: by 2002:ac2:5196:0:b0:513:26e7:6c0d with SMTP id u22-20020ac25196000000b0051326e76c0dmr1657694lfi.67.1709319695174; Fri, 01 Mar 2024 11:01:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319695; cv=pass; d=google.com; s=arc-20160816; b=ZoK5nMsLreIhq7utqeUpcDrzsU+5LSO38Q4pWjtRxhnKCFBS5M/S2thyg2pQSVSZGo wNF+Brq+kkqfRPJks60hsu1J+7F0aK7EEE5v+rFPjSaJBPoeeL6pHrED+Lq33znu1zjc mbJ44aKFYiDCUK1rD/mVAJ4AUWI78rOKLUKxOIBs7y98ktD+TsG6Bxi5d22P0x8l+Xmi UmD8xZ+LqgVqVBAZVV6HgZWzU9EPOrPes7D+4xOqd2sqrYirVwlXzAApM0kkyPdTvHg0 12DD9FcuE3DoM+ob9Qs7S4HikKFlr3Qqd6jN4yib+gx3dWgx/ptxS9POW4DsXE/NXALJ d/Ag== 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=zbLHB0Wrr0NrYcqmEePKnNB9gjFn+6QmEJrv+HDup90=; fh=/iWkkOeCseNa7ETBDwi1mXNq1lnwl3S30BtF7yeYTmM=; b=JEdGXwhTVcK7Od5w4YUrEi8jRQfJ23lGY0CTVlTCyAR0RWcgl9etA94LWdm5VhG76j uWr2RGLpcjSkg+LXrc+WDIzWp/MtSS+J+Anab//BZZTt+NMC+7RRRUCZDR3Jmnvn7wJp pN5G38vZCw/p2XJdy9seKOBze5LWMmeINAF/teoaNitm8RFJzryhXxAZJgeq9DDEGMlk /aPQGOlsDOqlOc4+ZISmLoRpjx33MHjN+dB1h0G2pPF0nYZ/JRhfA/qvYcalX59VZZLr fqPXz5+ty57VrevNBUsoRgkfrZjWcNdJnnxuGnLp9PTMTRwmtF7cJgLlV8WoiO2yo4iL Yfmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=t6G6qI99; 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-88979-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88979-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 jt20-20020a170906ca1400b00a3ed86dc13bsi1656668ejb.265.2024.03.01.11.01.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 11:01:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88979-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=t6G6qI99; 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-88979-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88979-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 C0B4C1F2764C for ; Fri, 1 Mar 2024 19:01:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F7413D972; Fri, 1 Mar 2024 18:57:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="t6G6qI99" 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 E190469E09 for ; Fri, 1 Mar 2024 18:56:58 +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=1709319420; cv=none; b=Je+7opidnwTcBLMRBcoDPAFP9wVzo9nyfVllJg5cAZ7CE14MRXXRrYnAHVdxyAE87lpweeEDSyb9uJhB1e8+kLS3wlvDd5lOlA+jNIACCN2l8+BV8iZucjMGebJNeuN3T1HVqkiBIItI5c4RG40L3BGWPKeOQYQ2350+U3HmLcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319420; c=relaxed/simple; bh=smAVN/GCgA5/MmqiHaxq1BP/CFOoXWsEkiW9uPTpG1E=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=pyOnxjy1tpNJXNxLyqQuRV+o4J1mMPLWoceMbU697pKUu45/OHfWrba4PMTJnb4RZorgI/L/TQtyoX9Rru3bhg3Gao0eUrVoStLmKABEWhg9VWmAHuadYqBWO+jaW6IuKnB7iTpajfKasMSPgjMDuAoR96F9Gb4DR0n+zUyzgWc= 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=t6G6qI99; 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-6093f75fc81so43608237b3.1 for ; Fri, 01 Mar 2024 10:56:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319418; x=1709924218; 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=zbLHB0Wrr0NrYcqmEePKnNB9gjFn+6QmEJrv+HDup90=; b=t6G6qI99RwYDk8lLd8c+8YQSOw4EvEtnlkSUvumWBJf6eWsWySUW7gl2IylYg5P625 UfxOxxIPjYv3ViXMhVv5xaw/q9DQ1QNyKz1s9xpGj6lHCATlIJjdd75Cr6d1rxTWaGs1 r6Xaq9T2JIz3OOit3nDL8KI9z0Q2vPo3XlFRzZ3ilvFW9IxSwrICBFOBjKf3xMhbjx9w Fp8k9ARuT+IZi5qENBMRNSKtWNIyRxEdxqCGZvyKUXl99hn0dqmZXDyIFhfAgKZ/SG/b 0wieEVfPAJ+/R6iRuqgVQEqOdtzuo5T5VfIKkAsnvTOF2y7Ozm/NGPHpNlR3ma6qFxZx ZzrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319418; x=1709924218; 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=zbLHB0Wrr0NrYcqmEePKnNB9gjFn+6QmEJrv+HDup90=; b=xU4fEaWBc4ipQ0cFYOYeaNMRb+zdBt2cnfinxNnIlM7vnh09HJIlY0162I+HMP9Gtu eC6bTKluJCDGX+MtKnqSRlvqXCImge1RNEBlijR9bjznmL0NL/LFPXAz5ukkf8Z+Opw5 lDoDkMFP4zIsERltI1C5LssPmDvJSvm2+2iKgq2pKpq0q+W3cdwr3IQgsnhIXt7NG8qr qIet1qTpTz15pnupNetp142Hy08mQ/nMGFCihiaoFWfpZ8u16bOmD3CEgL9brnGLjQe/ 2RHLHNUg4TR3D/z9SpPDNtCphF8h+TSEoM/uCsQF+nPgS2+WQb+ajxhUmyN31R31l/HI iJfQ== X-Forwarded-Encrypted: i=1; AJvYcCWKkroTKCxqAla1vvsVuSxJFASKHpPNF7VatvoK7hzyrZkJBCslxdNId3FuGt6whkHDO4B059UPQVX98WIYnG/4UhtZOq8V/JiPdof2 X-Gm-Message-State: AOJu0Yx7fZ7Ov1/HDwHvVsXR51Q7tTXuCay15pjz2vRl2iKKHlMqY7IK EfBhLXoq5dn5n/U/MwQTLMmzL7R7yBT5bz77pcxb4nSspg6Q0lsqUzQYRwEGInQs3Gr3nGIx0MU jegvyLA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a81:7908:0:b0:609:2cab:1bd7 with SMTP id u8-20020a817908000000b006092cab1bd7mr635579ywc.1.1709319418022; Fri, 01 Mar 2024 10:56:58 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:57 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-19-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 18/20] perf jevents: Add C-State metrics from the PCU PMU for Intel From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351608848860389 X-GMAIL-MSGID: 1792351608848860389 Use occupancy events fixed in: https://lore.kernel.org/lkml/20240226201517.3540187-1-irogers@google.com/ Metrics are at the socket level referring to cores, not hyperthreads. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 8086aef3557a..2e076f695292 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -784,6 +784,32 @@ def IntelLdSt() -> Optional[MetricGroup]: ], description = "Breakdown of load/store instructions") +def UncoreCState() -> Optional[MetricGroup]: + try: + pcu_ticks = Event("UNC_P_CLOCKTICKS") + c0 = Event("UNC_P_POWER_STATE_OCCUPANCY.CORES_C0") + c3 = Event("UNC_P_POWER_STATE_OCCUPANCY.CORES_C3") + c6 = Event("UNC_P_POWER_STATE_OCCUPANCY.CORES_C6") + except: + return None + + num_cores = Literal("#num_cores") / Literal("#num_packages") + + max_cycles = pcu_ticks * num_cores; + total_cycles = c0 + c3 + c6 + + # remove fused-off cores which show up in C6/C7. + c6 = Select(max(c6 - (total_cycles - max_cycles), 0), + total_cycles > max_cycles, + c6) + + return MetricGroup("cstate", [ + Metric("cstate_c0", "C-State cores in C0/C1", d_ratio(c0, pcu_ticks), "cores"), + Metric("cstate_c3", "C-State cores in C3", d_ratio(c3, pcu_ticks), "cores"), + Metric("cstate_c6", "C-State cores in C6/C7", d_ratio(c6, pcu_ticks), "cores"), + ]) + + def UncoreDir() -> Optional[MetricGroup]: try: m2m_upd = Event("UNC_M2M_DIRECTORY_UPDATE.ANY") @@ -920,6 +946,7 @@ all_metrics = MetricGroup("", [ IntelMlp(), IntelPorts(), IntelSwpf(), + UncoreCState(), UncoreDir(), UncoreMem(), UncoreMemBw(), From patchwork Fri Mar 1 18:55:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209048 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp91009dyc; Fri, 1 Mar 2024 11:02:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVW9e37DWypQoFiE5LbKXHmZq8zS9avoqGAWKR3VCJ/WjsHOAnfQnoXgSJR8lqZFMQcilwwZEWwY0YhsSUaOVgiJ/F+eA== X-Google-Smtp-Source: AGHT+IEI23nvtcmuVDiLiKtWS/MW9IRUoRS8LPinNPhcgFo0V67bc+BNUWLdLnw/WikK82/iDUeE X-Received: by 2002:a05:6a00:1955:b0:6e4:eb29:357 with SMTP id s21-20020a056a00195500b006e4eb290357mr3075136pfk.12.1709319761186; Fri, 01 Mar 2024 11:02:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319761; cv=pass; d=google.com; s=arc-20160816; b=tu5O4ssiC7oCCRqgF3QSGAGW1d3y4FxB1xNyP1uTQKQpZonDUN+nSkw70VD+QmRclh fGAIpS3cSPX+Mvnc8q4WQbG6FzjM+E+Pe/4Gp5DYgA3m7/oxkMG3r13LZ7jZJeVCRrUm WXuaqcyJJ/MRJ0iKxmQWwfNFYaPv7xkcCPZc0zLNe5sVQ8kz73NYAv/CxVfpU/ep9rYo PbbpWDmQvz6M/7gUtQbQNqfn27d+qWaOxuMGHdSYl1E18nGzBQQioRLr9PS5EC1/+sq7 XpNXziV9Tawk1Z9gyJzjglPhmmtwk6ta06+gwxsVcI55S6bc9tapZ2WKhK4jH9fFyWtY 5cPw== 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=C0LitAivSVkSNkxIQWgisNIRh3jWm5LVjR7Wq74t4Ec=; fh=Rao1Lfbgk/oGNpydZvujn8Pb1i63wC/o2/3PrbdjEII=; b=i0ucHRyPmpMzMOmc0ylnjeoXj7Y/T+EQK59iUa2GBfqwRtIKMAZlaGbDO4pHcfNYgU 2SRibtt7GodTnGypt9mOQgq3bCljAIAHLXZVi8tr3FclT6jAxY3rPuEq2D7wnNbL+mz3 6/slgVhLWr3gj6NtUi7diDtx4s1MMDKfWztzlJLVZ7s7AcgS1gmBvooofYeTNKfqdSTQ kp3gOtVtgy3B+0VU2sItPXHjARVtYGwe98zVCW6kRKLQiteWs0w0jvYCejXPksMDRhW5 gF0VofGecvdDhvWNDR/2Vo7O0MqQAsf7hZmNZoC7QZs+Oommvk2IjO/RY7lgEmpGtnkR ALIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=VMQwDk3t; 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-88980-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88980-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 f11-20020a63f10b000000b005d8b6fe2b5dsi4195164pgi.569.2024.03.01.11.02.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 11:02:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88980-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=VMQwDk3t; 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-88980-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88980-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 6D30F289AB3 for ; Fri, 1 Mar 2024 19:01:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3A0723B29A; Fri, 1 Mar 2024 18:57:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VMQwDk3t" 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 5A6416FB80 for ; Fri, 1 Mar 2024 18:57:01 +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=1709319422; cv=none; b=dZNSdwn/rtLHovr0POsJO6aDfX0k+balhIfXWeDfJXEoQu88UvKslgjZ1VAdN0UZechyQuESKyrF3YYa60E7lQT2tp2WVoOSs5yNaQwWqW4/IARzExxdhvxFxIRezAN577xU+B5055oX62Nng51RbXDSme+jqDrodkyAoh8OhY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319422; c=relaxed/simple; bh=JNlhdQ95scJS1Q2EhZ10SIKN+JTQT447NTNMbhZM01Q=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=RBxM4++zy2uEjsJKA4DAE09S3O/E4QQuVr8s0PvCnEiNpKYSUT/t6lTb+DB+dASiZRvMIuszckO6VhCj16DVoWCO4W681hBFpXhGuGJi0k+Q/Vw/0Mfgo1FhgwGb3J9Af6HU02f9uVuerh5wle7SzgWbn65J1MB2I2S0DZCRVu8= 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=VMQwDk3t; 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-dcc0bcf9256so3564353276.3 for ; Fri, 01 Mar 2024 10:57:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319420; x=1709924220; 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=C0LitAivSVkSNkxIQWgisNIRh3jWm5LVjR7Wq74t4Ec=; b=VMQwDk3trzRDd9c3xdSoNQui1Az+eXf51DIaOPpI1ONuWdAXqNfUmiqjicHfmfDruO XB2srp3cAVn5cX26mGXbDVVhub00Td5RGCAXhS9jDnsVRG6hrUJ09uW8D1OyW94GXivi Mdy9mbMn0ynhVomEzUB2JQAwLYq2qJpk0HdpCfpwWvI1syhkdwsTiJ+qNFmYkSfM3NY5 xBvBil+ZN51w1CmtVPg63Fj1DQp8l3hbwe7lRMsaYnnMvenlTY32AmQEaVVErYNJMT0q bl6ApRD5qO+E+F3EM/AIq7Xa6LDYGb6U/e6BP5lzebMbZ4Chu068XYPokAeRmscFUAqI tXdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319420; x=1709924220; 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=C0LitAivSVkSNkxIQWgisNIRh3jWm5LVjR7Wq74t4Ec=; b=Q+hL15yyuxGmFu5H1SF26TfRWN4XfSLsZzjE4rf+zdihMhI0bv3Enk76EdOIHegBdS jZEH1KEBpD8TaVhbRoSSitxmSnVzh2ZIa+K4s1V2AZkgk1xDMbQ5FMfAyzx+Q14a8klH H0cXM+a/yv+WrKyGGpPUB1sVQZPqEB/0Tf02te8rBSbyXqHZLc8gckCYtkzev0kTPB+N ZR75S8egjJSRMp+HseJ8m3zkVcpLs0vuIdez+mUbIUjYfJzxb26Bdh7Y6b5fcuBSaS+g F76+omvUUSYlAfEzzYPIQiFWb+Ms3d98C7B14jyf7HOnkSLQo4Rh4VflMiepiRrYrS+W X0tQ== X-Forwarded-Encrypted: i=1; AJvYcCV5WIAWIxPTfoL1ITruokjA0ppBWsKnTHcL2wImqEN+QQOTnaG89w4N1n6ApaJsLqnbvhYXVZY9PrwX9T8puAg/IxFi6eHVNVi9idVN X-Gm-Message-State: AOJu0YxgEKR7tDJ6hQJuA0hikWTl1R+IkeLHnECT/I/gwYI1DcAm4WfG Bzb5naYby5ZJBXWr0M5RFal3br3FRe9nnt+LWtT7Qrlx5+rbTaxAnmvybuCHuiFBhYcwSK1PDD3 7PK8vqQ== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a25:a009:0:b0:dc6:b982:cfa2 with SMTP id x9-20020a25a009000000b00dc6b982cfa2mr89928ybh.8.1709319420327; Fri, 01 Mar 2024 10:57:00 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:58 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-20-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 19/20] perf jevents: Add local/remote miss latency metrics for Intel From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351677798943601 X-GMAIL-MSGID: 1792351677798943601 Derive from CBOX/CHA occupancy and inserts the average latency as is provided in Intel's uncore performance monitoring reference. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 59 ++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 2e076f695292..fec8dc23f475 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -601,6 +601,64 @@ def IntelL2() -> Optional[MetricGroup]: ], description = "L2 data cache analysis") +def IntelMissLat() -> Optional[MetricGroup]: + try: + ticks = Event("UNC_CHA_CLOCKTICKS", "UNC_C_CLOCKTICKS") + data_rd_loc_occ = Event("UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_LOCAL", + "UNC_CHA_TOR_OCCUPANCY.IA_MISS", + "UNC_C_TOR_OCCUPANCY.MISS_LOCAL_OPCODE", + "UNC_C_TOR_OCCUPANCY.MISS_OPCODE") + data_rd_loc_ins = Event("UNC_CHA_TOR_INSERTS.IA_MISS_DRD_LOCAL", + "UNC_CHA_TOR_INSERTS.IA_MISS", + "UNC_C_TOR_INSERTS.MISS_LOCAL_OPCODE", + "UNC_C_TOR_INSERTS.MISS_OPCODE") + data_rd_rem_occ = Event("UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE", + "UNC_CHA_TOR_OCCUPANCY.IA_MISS", + "UNC_C_TOR_OCCUPANCY.MISS_REMOTE_OPCODE", + "UNC_C_TOR_OCCUPANCY.NID_MISS_OPCODE") + data_rd_rem_ins = Event("UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE", + "UNC_CHA_TOR_INSERTS.IA_MISS", + "UNC_C_TOR_INSERTS.MISS_REMOTE_OPCODE", + "UNC_C_TOR_INSERTS.NID_MISS_OPCODE") + except: + return None + + if (data_rd_loc_occ.name == "UNC_C_TOR_OCCUPANCY.MISS_LOCAL_OPCODE" or + data_rd_loc_occ.name == "UNC_C_TOR_OCCUPANCY.MISS_OPCODE"): + data_rd = 0x182 + for e in [data_rd_loc_occ, data_rd_loc_ins, data_rd_rem_occ, data_rd_rem_ins]: + e.name += f"/filter_opc={hex(data_rd)}/" + elif data_rd_loc_occ.name == "UNC_CHA_TOR_OCCUPANCY.IA_MISS": + # Demand Data Read - Full cache-line read requests from core for + # lines to be cached in S or E, typically for data + demand_data_rd = 0x202 + # LLC Prefetch Data - Uncore will first look up the line in the + # LLC; for a cache hit, the LRU will be updated, on a miss, the + # DRd will be initiated + llc_prefetch_data = 0x25a + local_filter = (f"/filter_opc0={hex(demand_data_rd)}," + f"filter_opc1={hex(llc_prefetch_data)}," + "filter_loc,filter_nm,filter_not_nm/") + remote_filter = (f"/filter_opc0={hex(demand_data_rd)}," + f"filter_opc1={hex(llc_prefetch_data)}," + "filter_rem,filter_nm,filter_not_nm/") + for e in [data_rd_loc_occ, data_rd_loc_ins]: + e.name += local_filter + for e in [data_rd_rem_occ, data_rd_rem_ins]: + e.name += remote_filter + else: + assert data_rd_loc_occ.name == "UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_LOCAL", data_rd_loc_occ + + loc_lat = interval_sec * 1e9 * data_rd_loc_occ / (ticks * data_rd_loc_ins) + rem_lat = interval_sec * 1e9 * data_rd_rem_occ / (ticks * data_rd_rem_ins) + return MetricGroup("miss_lat", [ + Metric("miss_lat_loc", "Local to a socket miss latency in nanoseconds", + loc_lat, "ns"), + Metric("miss_lat_rem", "Remote to a socket miss latency in nanoseconds", + rem_lat, "ns"), + ]) + + def IntelMlp() -> Optional[Metric]: try: l1d = Event("L1D_PEND_MISS.PENDING") @@ -943,6 +1001,7 @@ all_metrics = MetricGroup("", [ IntelIlp(), IntelL2(), IntelLdSt(), + IntelMissLat(), IntelMlp(), IntelPorts(), IntelSwpf(), From patchwork Fri Mar 1 18:55:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209045 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp90420dyc; Fri, 1 Mar 2024 11:01:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXvdYaYHQ0XWL31nDQN+CQMkFVXOv/2J1lBR/bhhHNkKdJC+CfMOnz47uDlq5sTgcgMSgnMlNe2/kjE6hiL2MKxY4D7TQ== X-Google-Smtp-Source: AGHT+IFTXZa5oD1Q88Quogjs/XDuIKZI4zTYMO6cLMwbfReH7zwmLHHCXVAsvCBhpANAT9EXgMrx X-Received: by 2002:a05:6102:19d0:b0:472:a1db:f17a with SMTP id jn16-20020a05610219d000b00472a1dbf17amr1405951vsb.31.1709319719517; Fri, 01 Mar 2024 11:01:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319719; cv=pass; d=google.com; s=arc-20160816; b=KTMYSmmAV7SUb5A4j5tQ2Bgv9ld9dWgF53L67RVzuCcbMHqCGJsrR/K+cI24+IPi+a DVBXUGAdEnHmBoh5HGxeQt4gWRujT3ZKj6w92aS94dSqy7191kaMZ3tr2uKhJSSRztzR fZrSyJi2CbJzPj4D0eOnPcWaXDS3Tenw9wmkfLurFnzPEwA1CcKyKPvnv+9cN8tc7edD VsB5JP9T7RB+JJprfZ3Vr4a2gBcXuSyCLL646iqLQjB1l7GAiZIIMyYV/u6ANfXiJ9kZ fegPrWPPCxTDuTvK4MEehHEe4zjovXySQyhSxckEKZo0DALQ3ifx4c8Weimc8yh4o7oy bwOQ== 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=fo96hrchgf3LWlHf7KBd8+uynqShNfYHYZPYMJSMK2s=; fh=MAgb3ES1vt10AuPevfnrmzbeUSJqLAs3snJ1ximGwSI=; b=i3f46sdyCfBx4KdFUXM1dpcYluWHK8xcmK9UbLXFDuvR+1XiBgT5AwpXPQd6Ppmc1K qpacQZXjkKqWBxGWGj3wc/jPvdsejH/iqJIuvNT6b29Tt9gpYpm6cjkKRhg0VfkomGQv n6BfSFQDi7Pi99pKKKyJHfosIrGppPzRqshUXKtlLZD+QW7uDtddTyVGxm6aQsSkUKMD tFVDmdyBP2aqnvJJ6KEQ+E31GodMIwFNHIKWuepkyeCW/Ye2+0kejzV17Yum5xcYQY3m 3XQxYewsUypxbEsbzuNv83PxXIVXp5U3JIDdZdi+o76Ky8somKZJMEw0nx1Gr6jK8wAo OJ3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="T0jujN/A"; 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-88981-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88981-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 e4-20020a67c504000000b004729bc5b239si235718vsk.318.2024.03.01.11.01.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 11:01:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88981-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="T0jujN/A"; 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-88981-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88981-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 74CFB1C22D24 for ; Fri, 1 Mar 2024 19:01:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA78771B3D; Fri, 1 Mar 2024 18:57:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="T0jujN/A" 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 00A343B293 for ; Fri, 1 Mar 2024 18:57:03 +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=1709319426; cv=none; b=hbxESSp9dtWwkDPQP/yx9mCSIJTChw1kPeiaGPsR/ZDSFi35CQGZF8qHWRflDldkggKb28xGg04esj+dK208kd/IQQmYXofVgfdpIQfbYml+Z5RwIIOKbkgcjNvJDN6ZsqRx5neyJyBXChYkuXUs8aLq6I5XLFVlF0L+mBsf/BQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319426; c=relaxed/simple; bh=0GwxMF9zq0iQE2g/LR7Nppd8iDmEHy9zf2CgiW+kRNg=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=GTdFKKT+cTmDSh6dTOmGdUmWObMIO9Xzxzdlfwap3IgyAYMRumjiKLKONC4/CCoXzrXmTuCuNYRhgxRyXgoe0w/S1VmWWPmem3C6P/KJsefGbLAUfMHoDDCBFH4hp/4CKQwvz6x56MRm+j7lWPWPJ2xPWlHpZnKyko9chmJgc/A= 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=T0jujN/A; 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-60832a48684so34393067b3.1 for ; Fri, 01 Mar 2024 10:57:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319423; x=1709924223; 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=fo96hrchgf3LWlHf7KBd8+uynqShNfYHYZPYMJSMK2s=; b=T0jujN/AZQjr3lOqDNc7kcB7fE8SKc3QUXTo2yQmFyshdEcJ8k7wE+qyanMnVDN/Ar WN+070FwOMK4N5wAGTT2u9TkdR65G+UCXtulSqqtSdkyfJce+fL0hLtprbJzhJuPPdu+ WcnjUgGq1j7k9oisfn3/YFaRMnSYaoVvh/RerFNIJbcZz+Ra763j/A4suKR90P93JfG3 aGvi/B2i+fxr4N5+Hx/Pbij4ncOCd4KJ6eXjIwzc83PRz39SwCjhFXgkbVVLPAF7/O2w LJ1XbaUEiWhpOMzE6EUf0HxvP51ih0lef7scS5z7S9IpCA7h4S0dws/G2OZ30rhIBJye LtGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319423; x=1709924223; 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=fo96hrchgf3LWlHf7KBd8+uynqShNfYHYZPYMJSMK2s=; b=Dj0u7JYwAtC8I/fga/lboNyior4ZkPphaCV3si5u0MW+I/ZPLcbRcrh0f+uUie/XqQ thcL1HikDKd7UfebG1h7gPVC3A32VKwtUnIh9u+Mq0IluDb5qEP6R/jL+YrzpIoJogxD VUQUrVl6wTixzjn6is0nUljvI4w5U9H4S77sEPAMoxIWD91t6Dkb7mYOhjoAX4ZQ3KNF jI6lPhPZuYUbaJ1rNbSPFiI+aMqYHKwjJ+R35hQDDtjoHVaDk/dB3+aGdyNzj19Vs3J3 RQ3eIpkyHbIWxsh+jY/NjjNq4cOaO20IdJ5f29EAsOKQFjtNH506xzm6sBvMeJIbkABV noKw== X-Forwarded-Encrypted: i=1; AJvYcCXYaI1CVoHMnk3xF4HFyRLYsxuSPeCyuBXhboHjJz8quO334PO8gRMVGN5hi+D4SVsiEgdTKCVKqGjArGCPRfFqpEIfOp29Dx2lB3CD X-Gm-Message-State: AOJu0YzV02Qx7LvRUb4w1cwt95zrHXkXSMAsJJI9W87yz4ieKOR5s/vU zRFHfcRfhV9vNrxLE2MZsPN5jmmsLBIuCKLcWjFUbpV55K4pIV8fc+zjDb21X8K9S0Nzdm62fhp qyw/nug== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a81:9950:0:b0:609:4d6f:7c0b with SMTP id q77-20020a819950000000b006094d6f7c0bmr473516ywg.4.1709319422982; Fri, 01 Mar 2024 10:57:02 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:59 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-21-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 20/20] perf jevents: Add upi_bw metric for Intel From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351634334539815 X-GMAIL-MSGID: 1792351634334539815 Break down UPI read and write bandwidth using uncore_upi counters. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index fec8dc23f475..859447d558ff 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -990,6 +990,27 @@ def UncoreMemBw() -> Optional[MetricGroup]: ], description = "Memory Bandwidth") +def UncoreUpiBw() -> Optional[MetricGroup]: + try: + upi_rds = Event("UNC_UPI_RxL_FLITS.ALL_DATA") + upi_wrs = Event("UNC_UPI_TxL_FLITS.ALL_DATA") + except: + return None + + upi_total = upi_rds + upi_wrs + + # From "Uncore Performance Monitoring": When measuring the amount of + # bandwidth consumed by transmission of the data (i.e. NOT including + # the header), it should be .ALL_DATA / 9 * 64B. + scale = (64 / 9) / 1_000_000 + return MetricGroup("upi_bw", [ + Metric("upi_bw_read", "UPI read bandwidth", + d_ratio(upi_rds, interval_sec), f"{scale}MB/s"), + Metric("upi_bw_write", "DDR memory write bandwidth", + d_ratio(upi_wrs, interval_sec), f"{scale}MB/s"), + ], description = "UPI Bandwidth") + + all_metrics = MetricGroup("", [ Idle(), Rapl(), @@ -1009,6 +1030,7 @@ all_metrics = MetricGroup("", [ UncoreDir(), UncoreMem(), UncoreMemBw(), + UncoreUpiBw(), ]) if args.metricgroups: