From patchwork Fri Mar 1 18:47:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209055 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp104074dyc; Fri, 1 Mar 2024 11:21:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXwtuilT9aHW/RkztzJ8M8ri6yuZOjMIHD2MKgHle52vQNb4Y7GbYTEE5RlPP7CWqLIwS0iTufJeVY/SKBYEMDvqgQwvw== X-Google-Smtp-Source: AGHT+IGmaui3D3PB94cjOT0XdFtllq+GROrjp+mMY9c7y/qmPyVPcodod+zwHhxecVAQxGH+/fYw X-Received: by 2002:a92:ca46:0:b0:365:1a59:dd6f with SMTP id q6-20020a92ca46000000b003651a59dd6fmr2959599ilo.21.1709320887917; Fri, 01 Mar 2024 11:21:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709320887; cv=pass; d=google.com; s=arc-20160816; b=bwuOyMlgFr6Y/eFzXk3YB+t1soqbapoI2B4XeZhCEZx6r+9+g7oIZScXkFrv3rmqX5 Gne8VTb9Wm57GvLpMLoWKn2nou5XjvwdwlFjhmI1icl0+5zJz3Q7MQlsiTCVYHpha7VG WlGeCfxEAwZqtaD/HHF3tpTNh/6Mj3oo07vEzkf36Au78HEtr5hLyjwRtQmooz+7IpeM wM2vv40Y9lp5FZ7+Nnj5raACyadT+JVX0e44TKpHLTjtKogAJ8L1pT6+01eFX+S3Z2/M Ctk+86R91x7rrt+FrNQyYt4C+U5yK/ouc7T2T1JiFEmL3eVHDArnf5Dm/qYdfchn2tJA EZdg== 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=VbbMwVexzgBT1fsV6th5WqgIzFECec7b7GQZlOqA780=; fh=OIBiXJpVEkmzE1Ohw998Q5PiBNaEsMY9hz1RfGrlfA8=; b=Y3Q6uoXPWeW4PweOFCxGXIBnwSlzRXbeyQYWdHt2pw4BBcp+8tHZOeukmAQDnMQ1vE rG13RNFAql6X217FkU27eOYkzbbnZb2K76icTCTF9PqDk0gCINoGblMVbh2XY47S55fC O3Sf54zLi00Thix8Lcg2gNakflfjMLd1JiaJpBsYRMtEi0wDUqoyTyFZ9KA0iNim1Gt4 /FFLRxIO+C1D/0LHZte13C4anogdQNMhVID8Ect/Tj8r5SWQQD/mDpVU/EIlxG+GEpYr xFcYbpdGLj0VW2H5DvzkF+Rex7s50sNILkSEshCApCUVY2vlBVq1uZGUseO4RcGVP8TV UdEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Evknf8o/"; 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-88943-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88943-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 s12-20020a63770c000000b005dbd5035dcdsi4120716pgc.192.2024.03.01.11.21.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 11:21:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88943-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="Evknf8o/"; 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-88943-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88943-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 6A2FAB2E611 for ; Fri, 1 Mar 2024 18:49:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0093F3C684; Fri, 1 Mar 2024 18:48:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Evknf8o/" 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 E86E43BB33 for ; Fri, 1 Mar 2024 18:48:00 +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=1709318882; cv=none; b=ug/IvV4Bbw7sFS5/qMPm6pL/OMIyrSf9FUuOKhRAdGSH3dsR/rCa79DKZ+05EXSQC3fprpJvstOc+zpKV3FpnQ8jw4gARY/mq8ZgNmk/75d2H/VIDgLDAgE4pQ+5Foz459yVaOqh+Cgy7oYZ0cKC9XV3HxUT5atSKe1DLz7gv+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318882; c=relaxed/simple; bh=5rPQbQbgB4a9rwpPs3GZO8lIicUTIgfjGCJZshFzKwg=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=LUXP6cjrZ2a4RCHFqT9QZ7gAuplYw7RBj4fW/aWZ44MZL0efseP/f24ujmwjrDsWLRUHNTa/4Fp896AeYoETFE3G2xH1MtUD1fju6vgHW1XQdOu8ubpNqCphc2/+3sW9D7koPtAZXjPkoKaf44fEabflCZMCVAFz42Vo3MrAXwc= 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=Evknf8o/; 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-dcc58cddb50so4185367276.0 for ; Fri, 01 Mar 2024 10:48:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709318880; x=1709923680; 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=VbbMwVexzgBT1fsV6th5WqgIzFECec7b7GQZlOqA780=; b=Evknf8o/nqyk2JNM7kr8uuxwOFw4tsN3TnEF97Pj2+ODXPRwmBoLjZamMZMiHf3PYH NjRFBk3MX6vxd4leLLxZbPtOeK3IirKAMrabqjyW5o4ModALpsKeVZgn185X8MGoLLtF skXqSdFkccJba7WT8hB1miExbblFcdsveUSex3ELF5Kk5668f+0j7P8oHsnrwInBpPDa LpCr7HL7adFf+D/Bqd+YsBdBySpsShHXVUkdM4Zyy49ZE0DejcL8+1/EYekTxZiK56C1 X5Q5dd59py0hE7z3Vck84w5Y3te8Mhp4Fxw4mpux+oyDF/A7Rxv+aB3RTq9anvNnb/+H msQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709318880; x=1709923680; 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=VbbMwVexzgBT1fsV6th5WqgIzFECec7b7GQZlOqA780=; b=Hmxd4/AjmlM3dliTMCdslY7Y2VZXDMuxhNBSLjpWyUqfhUbk1hWHX54RhFDLLaE3J9 wnuP/eeytOL/qcDQucpeIm+ZiFekVMqAMN3So3viYQywRqUotBsTLimwGop1MZanm1SH QFXW78dWpALdIZI3Kgx+W+hJ0AhnzhkryVMHHddih36RnWpOGzo3lVi//RFrGFvQUI0i MJoj5uFsUrrH1Me+qFEuJXBlIHOfFcKku+PZ/PKxBIYUmQaVvyn2at/tqQiicfgNLgyt mFnfImASuG52RbCyAJsx2nzqfHT/ZOEnHizAK4Qcy6+BMGL/zKj+CD56vg7rVGDfKSLi aWhQ== X-Forwarded-Encrypted: i=1; AJvYcCWTYbbIC+xu6W4uU/APWAZQjnMEro+vWgAhtGGaYt9qKQpKijL6ffH1pbKP+KfcdFnPtuKUg3KgfUq9fMUI6I1hzyn4MIeRjbSoHPqr X-Gm-Message-State: AOJu0Yz0UTOIhmCIjdabcb8/3Gj6qsU/pRHiaAGTSSKyf8l0h7RMDOp1 aq9LVNRKqMjEjFuKqFBrjV6deA8H6Aqq9pMuAYAG1PN0DhrmBYWVRb0dOmrpxKEUqwrm+35JpE+ oTUdunQ== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a25:dbc9:0:b0:dc6:dfc6:4207 with SMTP id g192-20020a25dbc9000000b00dc6dfc64207mr528160ybf.10.1709318880106; Fri, 01 Mar 2024 10:48:00 -0800 (PST) Date: Fri, 1 Mar 2024 10:47:31 -0800 In-Reply-To: <20240301184737.2660108-1-irogers@google.com> Message-Id: <20240301184737.2660108-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: <20240301184737.2660108-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 06/12] perf jevents: Add hardware prefetch (hwpf) metric group for AMD From: Ian Rogers To: Sandipan Das , Ravi Bangoria , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792352859666793747 X-GMAIL-MSGID: 1792352859666793747 Add metrics that give the utility of hardware prefetches on zen2, zen3 and zen4. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 61 ++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index 52451bcb4bbf..dda904998269 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -125,6 +125,66 @@ def AmdBr(): description="breakdown of retired branch instructions") +def AmdHwpf(): + """Returns a MetricGroup representing AMD hardware prefetch metrics.""" + if zen_model <= 1: + return None + + hwp_ld = Event("ls_dispatch.ld_dispatch") + hwp_l2 = Event("ls_hw_pf_dc_fills.local_l2", + "ls_hw_pf_dc_fills.lcl_l2", + "ls_hw_pf_dc_fill.ls_mabresp_lcl_l2") + hwp_lc = Event("ls_hw_pf_dc_fills.local_ccx", + "ls_hw_pf_dc_fills.int_cache", + "ls_hw_pf_dc_fill.ls_mabresp_lcl_cache") + hwp_lm = Event("ls_hw_pf_dc_fills.dram_io_near", + "ls_hw_pf_dc_fills.mem_io_local", + "ls_hw_pf_dc_fill.ls_mabresp_lcl_dram") + hwp_rc = Event("ls_hw_pf_dc_fills.far_cache", + "ls_hw_pf_dc_fills.ext_cache_remote", + "ls_hw_pf_dc_fill.ls_mabresp_rmt_cache") + hwp_rm = Event("ls_hw_pf_dc_fills.dram_io_far", + "ls_hw_pf_dc_fills.mem_io_remote", + "ls_hw_pf_dc_fill.ls_mabresp_rmt_dram") + + loc_pf = hwp_l2 + hwp_lc + hwp_lm + rem_pf = hwp_rc + hwp_rm + all_pf = loc_pf + rem_pf + + r1 = d_ratio(ins, all_pf) + r2 = d_ratio(hwp_ld, all_pf) + r3 = d_ratio(all_pf, interval_sec) + + overview = MetricGroup("hwpf_overview", [ + Metric("hwpf_ov_insn_bt_hwpf", "Insn between HWPF", r1, "insns"), + Metric("hwpf_ov_loads_bt_hwpf", "Loads between HWPF", r2, "loads"), + Metric("hwpf_ov_rate", "HWPF per second", r3, "hwpf/s"), + ]) + r1 = d_ratio(hwp_l2, all_pf) + r2 = d_ratio(hwp_lc, all_pf) + r3 = d_ratio(hwp_lm, all_pf) + data_src_local = MetricGroup("hwpf_data_src_local", [ + Metric("hwpf_data_src_local_l2", "Data source local l2", r1, "100%"), + Metric("hwpf_data_src_local_ccx_l3_loc_ccx", + "Data source local ccx l3 loc ccx", r2, "100%"), + Metric("hwpf_data_src_local_memory_or_io", + "Data source local memory or IO", r3, "100%"), + ]) + + r1 = d_ratio(hwp_rc, all_pf) + r2 = d_ratio(hwp_rm, all_pf) + data_src_remote = MetricGroup("hwpf_data_src_remote", [ + Metric("hwpf_data_src_remote_cache", "Data source remote cache", r1, + "100%"), + Metric("hwpf_data_src_remote_memory_or_io", + "Data source remote memory or IO", r2, "100%"), + ]) + + data_src = MetricGroup("hwpf_data_src", [data_src_local, data_src_remote]) + return MetricGroup("hwpf", [overview, data_src], + description="Hardware prefetch breakdown (CCX L3 = L3 of current thread, Loc CCX = CCX cache on some socket)") + + def AmdSwpf() -> Optional[MetricGroup]: """Returns a MetricGroup representing AMD software prefetch metrics.""" if zen_model <= 1: @@ -256,6 +316,7 @@ def Rapl() -> MetricGroup: all_metrics = MetricGroup("", [ AmdBr(), + AmdHwpf(), AmdSwpf(), AmdUpc(), Idle(),