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(),