From nobody Thu Dec 11 19:20:37 2025 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.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 E39DB2D0C9F for ; Tue, 2 Dec 2025 17:52:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764697977; cv=none; b=r7GNCrO10hDiRiKRuTyaNyvGu1jXxYQeeGrRD2Sph0uyJQ/NfgV/TEeQGiFHzmFhLobuCf0V1+FVUmV2DAy8JuFHHyIbt+7oFpJfV7YYBMwWSk5y0B177ZLflnZ6ODqre1H5p3TCoQl+/qWaBeqEBGWsnKdWZGTfHKak+mIyq7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764697977; c=relaxed/simple; bh=kTkOlBIJKFVpgDZYQVXbOsVlRCh+YA44NAPEapYMCdE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=tl08FxzhJqLNqj/wbDJCcNGUZL3pZnNJWhK7Gm0ZvDqSWx+/Lx5+kSChxOt5qVgkys6fae2LWxhELue7bw6urTKGb74nAG5qRhOt7BoBw/77ldmOpmXzIaoJbhKcURbXbhH5ZX72/OsGJvF2ecWP1f0L3YUrkyLZ9uU6xiUB9mc= 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=zycqXALp; arc=none smtp.client-ip=209.85.214.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zycqXALp" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2956a694b47so76176445ad.1 for ; Tue, 02 Dec 2025 09:52:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764697975; x=1765302775; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=TS+Q5DB4gJiG0aFc7TcLfBzsroYZtgDDk57R7SBmbvE=; b=zycqXALpcuQ+haMc0F/rq7tiEXxmzzxJVj/2nN1cqlJkdySQJIhiaM2QYc1AAmP4wv /3oLbbabNcR5MRhMic4DPvMTiqrJY2ImS5hTg9FUh2wJ/lx6q/Vp/W/YepO6+mcygEEK F7b3Foh1PdKj5+uyUdpNhYqxL0uVTBdrA3FpoKpNmCEGf2TdAIAr5eNggxpIfqPJu7IM dKf5G5I2XxoN5rO767FXiwoL3dLiA4J+VHWAqcYz+lOzTEHKI4taziSuWfOcuB1OkSmB Stwsz2zRsLOFFzvewi2J41N2ztUItsc3AOsMcSBw9jZ7DD4UG/plj1QERPNcHLJ6UXRS MM6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764697975; x=1765302775; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TS+Q5DB4gJiG0aFc7TcLfBzsroYZtgDDk57R7SBmbvE=; b=UMECQj5O3pGzpUVl064PWZPYYMMXU4RbIQyWYwwm7JHS2Xi5sphfQcUZH/0WBjlDaU qIUArFSIsxIF7QCpHGxAl6LKzEy9JVrpGZkDYs47UKin1pMan+oN1o+YjFhYN5xeZPpU XnPRenFjIC2CF8ySBjpGSNMSikriXDISzruX5GIIb1GdpjX+xiK0MWWQyrczm6PFMdPR AbFSRkZci/X1FHRC6V4jm27z9rEo6wvwcA5ODus5CiBGn9+caKea44ek3iJS/iMcNGf7 ekx5WAwYxm2bD6UAh1H8qg9qwJIRhSNMJXRF6NpP1Q2uC6anLXu1asEmk8IRA+zZiqeG Q4hA== X-Forwarded-Encrypted: i=1; AJvYcCW6NVbjIDvxPomrnjKZ8LrywDChCT4LO+m9HL6rmHgBvh2pqmgQ1GKar/EbhfJzJGzd10u1GFoCWic6FTo=@vger.kernel.org X-Gm-Message-State: AOJu0YxOVRbYPMjZ4cIY53/y+K8rGjUx0BTuRhjmTxrpMkOu6Y7BZ7u2 YZC7fs/Vj43+O9qiymG6b+jGgt0fu7sLEvRNCwofwGyqxUkP6W3IjeQ4/kEwGq1QcbZjQFDIc/L 7yBB2wHDZCw== X-Google-Smtp-Source: AGHT+IEkHQDnLBjyBIwheHxosvhCSI7hPRmIVCaH15lVvbze6EciB3E3gboKpRgG+yWoAuWtIahfLrpODLo/ X-Received: from plme20.prod.google.com ([2002:a17:903:4914:b0:296:18d:ea19]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:11cc:b0:295:223b:cdee with SMTP id d9443c01a7336-29baaf9a98dmr325125165ad.14.1764697974923; Tue, 02 Dec 2025 09:52:54 -0800 (PST) Date: Tue, 2 Dec 2025 09:50:17 -0800 In-Reply-To: <20251202175043.623597-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251202175043.623597-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.158.g65b55ccf14-goog Message-ID: <20251202175043.623597-23-irogers@google.com> Subject: [PATCH v9 22/48] perf jevents: Add load store breakdown metrics ldst for AMD From: Ian Rogers To: Adrian Hunter , Alexander Shishkin , Arnaldo Carvalho de Melo , Benjamin Gray , Caleb Biggers , Edward Baker , Ian Rogers , Ingo Molnar , James Clark , Jing Zhang , Jiri Olsa , John Garry , Leo Yan , Namhyung Kim , Perry Taylor , Peter Zijlstra , Samantha Alt , Sandipan Das , Thomas Falcon , Weilin Wang , Xu Yang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Sandipan Das --- 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/a= md_metrics.py index 6542c334a82b..1611d0e50d03 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -279,6 +279,80 @@ def AmdItlb(): ], description=3D"Instruction TLB breakdown") =20 =20 +def AmdLdSt() -> MetricGroup: + ldst_ld =3D Event("ls_dispatch.ld_dispatch") + ldst_st =3D Event("ls_dispatch.store_dispatch") + ldst_ldc1 =3D Event(f"{ldst_ld}/cmask=3D1/") + ldst_stc1 =3D Event(f"{ldst_st}/cmask=3D1/") + ldst_ldc2 =3D Event(f"{ldst_ld}/cmask=3D2/") + ldst_stc2 =3D Event(f"{ldst_st}/cmask=3D2/") + ldst_ldc3 =3D Event(f"{ldst_ld}/cmask=3D3/") + ldst_stc3 =3D Event(f"{ldst_st}/cmask=3D3/") + ldst_cyc =3D Event("ls_not_halted_cyc") + + ld_rate =3D d_ratio(ldst_ld, interval_sec) + st_rate =3D d_ratio(ldst_st, interval_sec) + + ld_v1 =3D max(ldst_ldc1 - ldst_ldc2, 0) + ld_v2 =3D max(ldst_ldc2 - ldst_ldc3, 0) + ld_v3 =3D ldst_ldc3 + + st_v1 =3D max(ldst_stc1 - ldst_stc2, 0) + st_v2 =3D max(ldst_stc2 - ldst_stc3, 0) + st_v3 =3D ldst_stc3 + + return MetricGroup("lpm_ldst", [ + MetricGroup("lpm_ldst_total", [ + Metric("lpm_ldst_total_ld", "Number of loads dispatched per se= cond.", + ld_rate, "insns/sec"), + Metric("lpm_ldst_total_st", "Number of stores dispatched per s= econd.", + st_rate, "insns/sec"), + ]), + MetricGroup("lpm_ldst_percent_insn", [ + Metric("lpm_ldst_percent_insn_ld", + "Load instructions as a percentage of all instructions.= ", + d_ratio(ldst_ld, ins), "100%"), + Metric("lpm_ldst_percent_insn_st", + "Store instructions as a percentage of all instructions= .", + d_ratio(ldst_st, ins), "100%"), + ]), + MetricGroup("lpm_ldst_ret_loads_per_cycle", [ + Metric( + "lpm_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( + "lpm_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( + "lpm_ldst_ret_loads_per_cycle_3", + "Load instructions retiring in 3 or more cycles as a perce= ntage" + "of all unhalted cycles.", d_ratio(ld_v3, ldst_cyc), "100%= "), + ]), + MetricGroup("lpm_ldst_ret_stores_per_cycle", [ + Metric( + "lpm_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( + "lpm_ldst_ret_stores_per_cycle_2", + "Store instructions retiring in 2 cycles as a percentage o= f all " + "unhalted cycles.", d_ratio(st_v2, ldst_cyc), "100%"), + Metric( + "lpm_ldst_ret_stores_per_cycle_3", + "Store instructions retiring in 3 or more cycles as a perc= entage" + "of all unhalted cycles.", d_ratio(st_v3, ldst_cyc), "100%= "), + ]), + MetricGroup("lpm_ldst_insn_bt", [ + Metric("lpm_ldst_insn_bt_ld", "Number of instructions between = loads.", + d_ratio(ins, ldst_ld), "insns"), + Metric("lpm_ldst_insn_bt_st", "Number of instructions between = stores.", + d_ratio(ins, ldst_st), "insns"), + ]) + ], description=3D"Breakdown of load/store instructions") + + def AmdUpc() -> Metric: ops =3D Event("ex_ret_ops", "ex_ret_cops") upc =3D d_ratio(ops, smt_cycles) @@ -365,6 +439,7 @@ def main() -> None: AmdBr(), AmdDtlb(), AmdItlb(), + AmdLdSt(), AmdUpc(), Idle(), Rapl(), --=20 2.52.0.158.g65b55ccf14-goog