From patchwork Fri Mar 1 18:47:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209023 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp83932dyc; Fri, 1 Mar 2024 10:50:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVYnJWx/q/VgQFzUPcs56SvzyKw6uooDm2iu0XcwTABkAQc7TCvlc0oNjepnPRYJeIVV+EafgWOacaOUOAW5OAUX6WaFg== X-Google-Smtp-Source: AGHT+IEE0yKQNbZ+72gPjjGAB5wzOd8XUvGNPyO5DiLgy+l0bCuVvm+NEVUDBKrBnAMWVBQg07VG X-Received: by 2002:a05:6808:2027:b0:3c1:d91f:d9aa with SMTP id q39-20020a056808202700b003c1d91fd9aamr1080741oiw.0.1709319039646; Fri, 01 Mar 2024 10:50:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319039; cv=pass; d=google.com; s=arc-20160816; b=ahtst8qMUYKOjvKlBpwADYAw/0u21tMcoLvtoybDjygukID8c8cqbEgLEEbZgQvt8E sZaavnYosoPxMxGFXsQXFse1R/a5ggWtPHYzdeZwr8/uq20pbqFs96xXhumTo3BrcTb/ RsxAYGKCuTGUrexQRvEyYoKfAs8LccOmy+oj9n1vUXhcixKNBpADVkOzk+ywamtBjChp oKLUyxlP5Bc6OEyojY+MtFPo1cPGHgKbAirT8XgP+aPJwD/IRSNXp7JSJ4Axst9drInp 0IsHbQxDCTqgy2JWj1h4gn81FCnXAfEo2ke09ojGpMFDpDrF60d21B5k1pcfXFgAfl0t C0mA== 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=riQkIrg8TOM4HvcpMUBBinltQ/7KCgNPQM/xCcL0170=; fh=LkApuQUH/L0R2pbhiLWd1yOt2VyLgVO082+kt9yCT+E=; b=Ccx8DXqwdnrWzZDw8vhWvR/Z9fvdgs5iWmBqKuTRXd7198ik7XXvSYsqGH/fm/Eie9 17MD7ND8YCHKVhBOP7tc+zlKdJ3X5oReWAh7HQNzDxQkOKDT1FAgjIfZ+dTFFfD1uaBP OGIbNksxJY8iTmAF4woKDnU8O44/C4Zff9oYXQSKlvs9swNMo+xWJYk+blh4ocdOq3jT U38Ll/z44cQbwYpnufft/lIhKQFpBy5GxnUAH1I4Skp2YYDfVgf3R8YGn0hBGvP0JjtG ckU+XHL3ZKLY5CPR+5awLetMDpVKVn3q2KDCkoPHX0W0yhbzJ738LSc79FnZjZw4oWmQ GFAw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MClWlq8y; 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-88947-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88947-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 c16-20020a63ef50000000b005e2c2fc5125si4137927pgk.249.2024.03.01.10.50.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:50:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88947-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=MClWlq8y; 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-88947-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88947-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 6CE85288495 for ; Fri, 1 Mar 2024 18:50:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2485F3D569; Fri, 1 Mar 2024 18:48:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MClWlq8y" 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 6C2A93D0C2 for ; Fri, 1 Mar 2024 18:48:10 +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=1709318892; cv=none; b=T+b5Z3yhJyxH6BfXhes/4Tg9kbzhF8iOyn7JZ1CS3dHanFAgI8ptZIpCHfhWyyP+yGonASJxlpgEBsmS+maL0IvV1Lo1xES379xpZVCDqePgbffLuynGsZTnOKL+g6jSVH9B2ZQ0jHMhiub+Qo/6E/o90FmCScUv2mbk8rodPCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318892; c=relaxed/simple; bh=D/pwwQ6dXV1q6dCmwwHAP89kxtCQNH4Hvs09U28fH3I=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=PgearrSSBXhGNJLQCRgSAHKZ4oUU++YUxIsmC4HCaE5eU87pwQM/8a+Q6zvo8QCKxjQDmo6lzFuEvxGCxA+A+5hnDlVsnPmu0cuXvvL3cMDZL6/RkgK9ook0QGCFWFtxzjmrLW9a9KzN8sbEH+w+r60V/8WZNp3W8j2iTbL+I98= 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=MClWlq8y; 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-dc6b269686aso3600771276.1 for ; Fri, 01 Mar 2024 10:48:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709318889; x=1709923689; 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=riQkIrg8TOM4HvcpMUBBinltQ/7KCgNPQM/xCcL0170=; b=MClWlq8y/bQU6H1OOaWHyivNZhpJWu4W3rSpyHfIwhAkmT8lh1FUBHAKU4vaybXo1/ tKFkCLq65yFP0YRkyf1pPiYsE8hJD7aGOykAiFwQPPI5qsvmEUqvDgJvrQLrgJAathVJ DUNR3LaMMEvtLetZUkjCzol7Padal//yzJZrIba/jgxmhoj8raLKMpo225lUGsdVaQSL fOARpAfXiy9M4ZdI6bSfERHisEp7ulOQzO+IeA39AnpKlnnllerDk5GInJuiu3XOYYlv 1XxGv/9wg3vfh/HjklDQhH4yzRdk2gDQ2NBloeprx9js/ZND6GrcqftNtw7SNqAHdil4 7tgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709318889; x=1709923689; 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=riQkIrg8TOM4HvcpMUBBinltQ/7KCgNPQM/xCcL0170=; b=pmI4mJWXur6aqOrBfRYu16qAXYLHuo7WkQ1D24kzxdNegeHjxvbtxEjxrwh+i+jL26 BFU2rJ9i049HxEOAv7xBiCLL15zQoLnmWmHTFJbg5OvHw+J7Uyx8NXB/M9IrchrWi/QY 8Syju+cU5hCl1tYKpOZ7S70TAfneEJYD9IoYGqwTajmgV61aSM7XuTSMDN8Xfjhpg7LP 3quSjeh/bjFG+SyJdxAvSS4bAE1WYEsJlvL5LcpCFsheh5lnPBSEuNHkaUXVmzJZH1cU y5bxjZkfsBOmkbMZw5P3uUTxSbvUNoPuqwgYifXNCL0JbudSTlmzLOzFLiNPtWXAUtYD ZuFQ== X-Forwarded-Encrypted: i=1; AJvYcCWKLznCd+7m4ojT0AjsWBcurXwK0T9xhZ8/Db1aa0QvGeGTKO3OrrhlGS9V47SfxZ96uC7QoqhJ/cSmboWuxqhLeGrNSERncUleB0nG X-Gm-Message-State: AOJu0YyOvPzeiZ8WH3PEbpa6hLGASi+nI+dAGUa/6mYytL/AMftgz2Br YzTtJA+o9T/EitsRx9emGOXttr/cr+UnVfoZGcBGuyLfOjNQqUCAh+rL5/VSjEf5xHN8jafehsf ZR9YQBA== 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-20020a056902182100b00dc79218df3bmr100318ybb.10.1709318889581; Fri, 01 Mar 2024 10:48:09 -0800 (PST) Date: Fri, 1 Mar 2024 10:47:35 -0800 In-Reply-To: <20240301184737.2660108-1-irogers@google.com> Message-Id: <20240301184737.2660108-11-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 10/12] perf jevents: Add load store breakdown metrics ldst 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: 1792350921635322699 X-GMAIL-MSGID: 1792350921635322699 Give breakdown of number of instructions. Use the counter mask (cmask) to show the number of cycles taken to retire the instructions. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 75 ++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index f4a4ece551ef..6b182a9bbfe5 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -278,6 +278,80 @@ def AmdItlb(): ], description="Instruction TLB breakdown") +def AmdLdSt() -> MetricGroup: + ldst_ld = Event("ls_dispatch.ld_dispatch") + ldst_st = Event("ls_dispatch.store_dispatch") + ldst_ldc1 = Event(f"{ldst_ld}/cmask=1/") + ldst_stc1 = Event(f"{ldst_st}/cmask=1/") + ldst_ldc2 = Event(f"{ldst_ld}/cmask=2/") + ldst_stc2 = Event(f"{ldst_st}/cmask=2/") + ldst_ldc3 = Event(f"{ldst_ld}/cmask=3/") + ldst_stc3 = Event(f"{ldst_st}/cmask=3/") + ldst_cyc = Event("ls_not_halted_cyc") + + ld_rate = d_ratio(ldst_ld, interval_sec) + st_rate = d_ratio(ldst_st, interval_sec) + + ld_v1 = max(ldst_ldc1 - ldst_ldc2, 0) + ld_v2 = max(ldst_ldc2 - ldst_ldc3, 0) + ld_v3 = ldst_ldc3 + + st_v1 = max(ldst_stc1 - ldst_stc2, 0) + st_v2 = max(ldst_stc2 - ldst_stc3, 0) + st_v3 = ldst_stc3 + + return MetricGroup("ldst", [ + MetricGroup("ldst_total", [ + Metric("ldst_total_ld", "Number of loads dispatched per second.", + ld_rate, "insns/sec"), + Metric("ldst_total_st", "Number of stores dispatched per second.", + st_rate, "insns/sec"), + ]), + MetricGroup("ldst_percent_insn", [ + Metric("ldst_percent_insn_ld", + "Load instructions as a percentage of all instructions.", + d_ratio(ldst_ld, ins), "100%"), + Metric("ldst_percent_insn_st", + "Store instructions as a percentage of all instructions.", + d_ratio(ldst_st, ins), "100%"), + ]), + MetricGroup("ldst_ret_loads_per_cycle", [ + Metric( + "ldst_ret_loads_per_cycle_1", + "Load instructions retiring in 1 cycle as a percentage of all " + "unhalted cycles.", d_ratio(ld_v1, ldst_cyc), "100%"), + Metric( + "ldst_ret_loads_per_cycle_2", + "Load instructions retiring in 2 cycles as a percentage of all " + "unhalted cycles.", d_ratio(ld_v2, ldst_cyc), "100%"), + Metric( + "ldst_ret_loads_per_cycle_3", + "Load instructions retiring in 3 or more cycles as a percentage" + "of all unhalted cycles.", d_ratio(ld_v3, ldst_cyc), "100%"), + ]), + MetricGroup("ldst_ret_stores_per_cycle", [ + Metric( + "ldst_ret_stores_per_cycle_1", + "Store instructions retiring in 1 cycle as a percentage of all " + "unhalted cycles.", d_ratio(st_v1, ldst_cyc), "100%"), + Metric( + "ldst_ret_stores_per_cycle_2", + "Store instructions retiring in 2 cycles as a percentage of all " + "unhalted cycles.", d_ratio(st_v2, ldst_cyc), "100%"), + Metric( + "ldst_ret_stores_per_cycle_3", + "Store instructions retiring in 3 or more cycles as a percentage" + "of all unhalted cycles.", d_ratio(st_v3, ldst_cyc), "100%"), + ]), + MetricGroup("ldst_insn_bt", [ + Metric("ldst_insn_bt_ld", "Number of instructions between loads.", + d_ratio(ins, ldst_ld), "insns"), + Metric("ldst_insn_bt_st", "Number of instructions between stores.", + d_ratio(ins, ldst_st), "insns"), + ]) + ], description="Breakdown of load/store instructions") + + def AmdHwpf(): """Returns a MetricGroup representing AMD hardware prefetch metrics.""" if zen_model <= 1: @@ -488,6 +562,7 @@ all_metrics = MetricGroup("", [ AmdBr(), AmdDtlb(), AmdItlb(), + AmdLdSt(), AmdHwpf(), AmdSwpf(), AmdUpc(),