From nobody Mon Feb 9 04:03:47 2026 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (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 7B81F3644C5 for ; Tue, 27 Jan 2026 18:45:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769539548; cv=none; b=DVp3vJpa4eimVQ6nAFuJAxpfxSyboKR29nkbjxqG2H/k6JxePEDGy5kwyzi8Cnsy7sdRIPoNOF38KYgqDx4DVi1u7HJ/jQIxF3nDAdC/uZNchRbMrw5YcElu1hKfT1RLEAyFDzr/NUMIUd7ntgggAtJXJE9zPFY0jXD7ca/lKUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769539548; c=relaxed/simple; bh=cIu6eR1sR5Z5vTDJWp5UW5V0wvKX6WEDplqiXQUSFGQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=VxEqHXz/KxISODVufw3bjqCOgzy9Q2DOzz0PqWRHN/kIB3C+SIofldVTxut71xKkwB3A3eJ0KPbQcwItvUhWu9uLghcSEFRs1HZjOtRhAqz1VhJkOqKDeRAbYMe5ayZ5MCNi6wg1QtjwSWKkIJliwrPDzgey5Idvhq0GVw+Hxj4= 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=t4Yh2tFw; arc=none smtp.client-ip=74.125.82.73 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="t4Yh2tFw" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-12339e20a86so6764515c88.0 for ; Tue, 27 Jan 2026 10:45:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769539546; x=1770144346; 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=79FcYdK/0zuRLjptxWds6JuhoHGCloD1d2+DIKaDNX0=; b=t4Yh2tFwL0D8IMN78XHMfmXSvzMN8r14YeEcFYyuBY56XQleyoYEobqrHVt/ClZMFM huEnTTjruCyVVuEOr4Rrd6FuZwxNvDyyhKFBM9WN0ruBfdR+IjMyHULZf6miyJum8Q++ 2ZDjIQsGURGG1GR34W1xAzXcwmNMw4gyZ/q4N+TxCLsna0qMOhP58+xoMW8cWrdo6ZWw kL76VCrKdhb4UiA4iTCNzxQ9nY0hFuUX3MCa8RxY1THAWpDoK3Os2XvMgDymuPIfXRHb PpLuwHFU4qjlLJxKUo8k0dJoYrn8nqJEcqPGolLd0BEgtF47b18vizzJ3G2wYdcb7+TO YJvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769539546; x=1770144346; 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=79FcYdK/0zuRLjptxWds6JuhoHGCloD1d2+DIKaDNX0=; b=KOdqRp5sTs8kasY6tzNemA26j23MwPMGwJsEQpmbrk7eVeqXO5+QLf+Xy4oK/V/syg dHUAE9xh3I4RS1qt2enawxYG5gB5bSyrUpnxl5YlPE1PKcTVYfMJ5EKa+5/eI4Dun5Xn 1YJuaGXL0adP2lqEIpVrlQ+ALACv9bghoQedf7KoDIM3UUe5mBDoXxcd3qyVHYhR1xbr 7OY9paguOB/6Zzj1MOiVqdHSY2PyXK8oLr5pI7u7dDYjW5uFHN0RyZyHHMFcROsryetb 5vuK6u27UJc3DiX50QMz6BpHp2PYRc+JPqNO0SlfwPmP7r9MtRQk0CMl7Co2cWIyOLX4 fppQ== X-Forwarded-Encrypted: i=1; AJvYcCXOJLKtZy3eyU7b4NWCmNTCZurqjOghJiVPR3O7EleNqPuy0cyn5xUQ6V0DWP/YI6SYlH5A9LVsTor5NI4=@vger.kernel.org X-Gm-Message-State: AOJu0Yw2y3MbYmuag9zUqf+X4AlI9PMFZMFWJXr+4PWuFExrwNQzA1To rue1uLx230Fte9PM5BKMoJjfz1tyblmSZooRaD95hTnuLATkKhoOCGwlV3VY3f7N9yx4XGH8lot SRKv+6H2YHw== X-Received: from dlbpy18.prod.google.com ([2002:a05:7022:e992:b0:11f:42e8:ad40]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:6a0:b0:11b:9386:826c with SMTP id a92af1059eb24-124a00d64dbmr1945062c88.41.1769539545636; Tue, 27 Jan 2026 10:45:45 -0800 (PST) Date: Tue, 27 Jan 2026 10:44:41 -0800 In-Reply-To: <20260127184506.3059493-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: <20260127184506.3059493-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260127184506.3059493-11-irogers@google.com> Subject: [PATCH v11 10/35] 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 , 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. Reviewed-by: Sandipan Das 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/a= md_metrics.py index d71997177239..b3de74babe40 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -280,6 +280,80 @@ def AmdItlb(): ], description=3D"Instruction TLB breakdown") =20 =20 +def AmdLdSt() -> MetricGroup: + ldst_ld =3D Event("ls_dispatch.pure_ld", "ls_dispatch.ld_dispatch") + ldst_st =3D Event("ls_dispatch.pure_st", "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) @@ -366,6 +440,7 @@ def main() -> None: AmdBr(), AmdDtlb(), AmdItlb(), + AmdLdSt(), AmdUpc(), Idle(), Rapl(), --=20 2.52.0.457.g6b5491de43-goog