From nobody Fri Nov 29 00:45:17 2024 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 493F617DE16 for ; Thu, 26 Sep 2024 17:41:28 +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=1727372490; cv=none; b=PvYeATGI3QD5lba/Ovdoo5GD8uphC2q7XL4JjpBs8h4O6u1jrsp3ijNroF6NHxN8BPdoOMHTdONXvoncyYb2el83cEm+JZq2CLZxuR1+Sdxi5i1A5dMzdA9oMuJmWxQPvgtU4PMS77Wo/1lB/0Vlr7PuDICCSsdls8ATjwQIhX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372490; c=relaxed/simple; bh=cIMaKODlIQfWjwdaOl/2X3SzVdBENS/xWTEUuvLVAWU=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=NBr9IWfnrwdtVKXaeF5Y76sanw9Pj56iOZP3vsySUrBfoTJ9ayXdbitwaV0EJJlupFLVbXhhgfB83KsJldcGNu2hWyqQra/V6xoWAD9P/6v/uLusJT9wlqaFNQU+sNZzlqru6zOFgoaK2qoFUzlbTZchzo6i+04JxsJubxyeR9Q= 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=nICtZ4kV; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nICtZ4kV" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e25d494faa4so726891276.0 for ; Thu, 26 Sep 2024 10:41:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727372487; x=1727977287; 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=yqA0HwjkEMRfn4rBqXVohYotQoaEYwt24VeEOBZhY4I=; b=nICtZ4kV6qVWOHrdab8ZTbePovqofzVsxtq9tckpUW7xUs4Dcz3EMT5y2eoUF5mYzW eQMRPYeOEqfd6vkr3/OQlTfDjKJ9cToZzkdpFHiugVGtd/CbDBkFsPtwL6l2YZCPBi8f uIscwwmkkOIeRlA0+CCoxfN6GLp6EobASSexLJodAHe6m/WON4QnmUXNqvj8wxgcH/hC y2LcpQYIzMleRoMJwoLELu/QLr8ZfmCj7sAPbbfpwgO/yEMqPs/iX5UP4LAH9DDfDKQC ddiACon9iAR78KjfCZ3W6M1cWZX8ygtbSb1lH8ny4AE2M5wLhIlvLNcIEJRKKQEfsfjn ZfAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727372487; x=1727977287; 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=yqA0HwjkEMRfn4rBqXVohYotQoaEYwt24VeEOBZhY4I=; b=tcrBezjc+7sKzCpU9Jh4/aXPl7ZxSYabq6Y1xYGHCJ3Tngi4woBXgnI9M5MArQwCgs GZ9AKpWxqRyRNWF8Nd5EuHewezT/bv22rsPbYTGPrbBW+PPCGYclBOJDxPxFPHCpkQej XW/N5EupmCKqzdmxmk790M/leVZ8OoNqBPbLUhxI192ef1RBBenLnM/g3SmeuHaBP4kO Lnq+ORb9dpghaeZjBToaU9diWgv5LouZTQ+f/sOd42iBW6jzDJO/EOLHXa2tnPirskLW Clq7uj5z3ZjF+0go1kFnmJfiMmWsOHaoT3297a39eAakIV+aJ51YUprHLkG5zbkdlTlJ ltyg== X-Forwarded-Encrypted: i=1; AJvYcCV/i7hhtrYy/pT1MxlhzHRmTtGpupaXjfz724nj2ZPEaUBkpa7f9p0jjAHLuiEpotI8Ms19HrT9FFDUE7w=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3JdJ9KvIsUGN+M1O/t/VggvgItCeS6CfVUsJeIXvEK/6QRcCj n8YGw1vBR/nMB87tifDZd1lHYhaUu2WURtKctfr4uDyQs39RbSgdzdzKqA/imUH31TcNObq3TTW HyV9d8w== X-Google-Smtp-Source: AGHT+IE94klXmp+qn3GvZ2PkmtcS2BcW6kckGIotFl44MsJdIBQMTTpB8//026BOk6pIF0SoTYBVL0xXejCI X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8872:3585:18ed:a056]) (user=irogers job=sendgmr) by 2002:a05:6902:3d2:b0:e1a:6bf9:aa83 with SMTP id 3f1490d57ef6-e2604b33cc4mr234276.3.1727372487216; Thu, 26 Sep 2024 10:41:27 -0700 (PDT) Date: Thu, 26 Sep 2024 10:40:57 -0700 In-Reply-To: <20240926174101.406874-1-irogers@google.com> Message-Id: <20240926174101.406874-9-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240926174101.406874-1-irogers@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Subject: [PATCH v4 08/12] perf jevents: Add dtlb metric group for AMD From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Jing Zhang , Sandipan Das , Benjamin Gray , 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" Add metrics that give an overview and details of the dtlb (zen1, zen2, zen3). Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 109 +++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/a= md_metrics.py index bfed478f508b..7fd2139766f9 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -120,6 +120,114 @@ def AmdBr(): description=3D"breakdown of retired branch instructio= ns") =20 =20 +def AmdDtlb() -> Optional[MetricGroup]: + global _zen_model + if _zen_model >=3D 4: + return None + + d_dat =3D Event("ls_dc_accesses") if _zen_model <=3D 3 else None + d_h4k =3D Event("ls_l1_d_tlb_miss.tlb_reload_4k_l2_hit") + d_hcoal =3D Event("ls_l1_d_tlb_miss.tlb_reload_coalesced_page_hit") if _= zen_model >=3D 2 else 0 + d_h2m =3D Event("ls_l1_d_tlb_miss.tlb_reload_2m_l2_hit") + d_h1g =3D Event("ls_l1_d_tlb_miss.tlb_reload_1g_l2_hit") + + d_m4k =3D Event("ls_l1_d_tlb_miss.tlb_reload_4k_l2_miss") + d_mcoal =3D Event("ls_l1_d_tlb_miss.tlb_reload_coalesced_page_miss") if = _zen_model >=3D 2 else 0 + d_m2m =3D Event("ls_l1_d_tlb_miss.tlb_reload_2m_l2_miss") + d_m1g =3D Event("ls_l1_d_tlb_miss.tlb_reload_1g_l2_miss") + + d_w0 =3D Event("ls_tablewalker.dc_type0") if _zen_model <=3D 3 else None + d_w1 =3D Event("ls_tablewalker.dc_type1") if _zen_model <=3D 3 else None + walks =3D d_w0 + d_w1 + walks_r =3D d_ratio(walks, interval_sec) + ins_w =3D d_ratio(ins, walks) + l1 =3D d_dat + l1_r =3D d_ratio(l1, interval_sec) + l2_hits =3D d_h4k + d_hcoal + d_h2m + d_h1g + l2_miss =3D d_m4k + d_mcoal + d_m2m + d_m1g + l2_r =3D d_ratio(l2_hits + l2_miss, interval_sec) + l1_miss =3D l2_hits + l2_miss + walks + l1_hits =3D max(l1 - l1_miss, 0) + ins_l =3D d_ratio(ins, l1_miss) + + return MetricGroup("dtlb", [ + MetricGroup("dtlb_ov", [ + Metric("dtlb_ov_insn_bt_l1_miss", + "DTLB overview: instructions between l1 misses.", ins_l, + "insns"), + Metric("dtlb_ov_insn_bt_walks", + "DTLB overview: instructions between dtlb page table walk= s.", + ins_w, "insns"), + ]), + MetricGroup("dtlb_l1", [ + Metric("dtlb_l1_hits", + "DTLB L1 hits as percentage of all DTLB L1 accesses.", + d_ratio(l1_hits, l1), "100%"), + Metric("dtlb_l1_miss", + "DTLB L1 misses as percentage of all DTLB L1 accesses.", + d_ratio(l1_miss, l1), "100%"), + Metric("dtlb_l1_reqs", "DTLB L1 accesses per second.", l1_r, + "insns/s"), + ]), + MetricGroup("dtlb_l2", [ + Metric("dtlb_l2_hits", + "DTLB L2 hits as percentage of all DTLB L2 accesses.", + d_ratio(l2_hits, l2_hits + l2_miss), "100%"), + Metric("dtlb_l2_miss", + "DTLB L2 misses as percentage of all DTLB L2 accesses.", + d_ratio(l2_miss, l2_hits + l2_miss), "100%"), + Metric("dtlb_l2_reqs", "DTLB L2 accesses per second.", l2_r, + "insns/s"), + MetricGroup("dtlb_l2_4kb", [ + Metric( + "dtlb_l2_4kb_hits", + "DTLB L2 4kb page size hits as percentage of all DTLB L2= 4kb " + "accesses.", d_ratio(d_h4k, d_h4k + d_m4k), "100%"), + Metric( + "dtlb_l2_4kb_miss", + "DTLB L2 4kb page size misses as percentage of all DTLB = L2 4kb" + "accesses.", d_ratio(d_m4k, d_h4k + d_m4k), "100%") + ]), + MetricGroup("dtlb_l2_coalesced", [ + Metric( + "dtlb_l2_coal_hits", + "DTLB L2 coalesced page (16kb) hits as percentage of all= DTLB " + "L2 coalesced accesses.", d_ratio(d_hcoal, + d_hcoal + d_mcoal), "1= 00%"), + Metric( + "dtlb_l2_coal_miss", + "DTLB L2 coalesced page (16kb) misses as percentage of a= ll " + "DTLB L2 coalesced accesses.", + d_ratio(d_mcoal, d_hcoal + d_mcoal), "100%") + ]), + MetricGroup("dtlb_l2_2mb", [ + Metric( + "dtlb_l2_2mb_hits", + "DTLB L2 2mb page size hits as percentage of all DTLB L2= 2mb " + "accesses.", d_ratio(d_h2m, d_h2m + d_m2m), "100%"), + Metric( + "dtlb_l2_2mb_miss", + "DTLB L2 2mb page size misses as percentage of all DTLB = L2 " + "accesses.", d_ratio(d_m2m, d_h2m + d_m2m), "100%") + ]), + MetricGroup("dtlb_l2_1g", [ + Metric( + "dtlb_l2_1g_hits", + "DTLB L2 1gb page size hits as percentage of all DTLB L2= 1gb " + "accesses.", d_ratio(d_h1g, d_h1g + d_m1g), "100%"), + Metric( + "dtlb_l2_1g_miss", + "DTLB L2 1gb page size misses as percentage of all DTLB = L2 " + "1gb accesses.", d_ratio(d_m1g, d_h1g + d_m1g), "100%") + ]), + ]), + MetricGroup("dtlb_walks", [ + Metric("dtlb_walks_reqs", "DTLB page table walks per second.", + walks_r, "walks/s"), + ]), + ], description=3D"Data TLB metrics") + + def AmdItlb(): global _zen_model l2h =3D Event("bp_l1_tlb_miss_l2_tlb_hit", "bp_l1_tlb_miss_l2_hit") @@ -386,6 +494,7 @@ def main() -> None: =20 all_metrics =3D MetricGroup("", [ AmdBr(), + AmdDtlb(), AmdItlb(), AmdHwpf(), AmdSwpf(), --=20 2.46.1.824.gd892dcdcdd-goog