Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf jevents: Add local/remote miss latency metrics for Intel

Derive from CBOX/CHA occupancy and inserts the average latency as is
provided in Intel's uncore performance monitoring reference.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Thomas Falcon <thomas.falcon@intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Benjamin Gray <bgray@linux.ibm.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Edward Baker <edward.baker@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Leo Yan <leo.yan@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Weilin Wang <weilin.wang@intel.com>
Cc: Xu Yang <xu.yang_2@nxp.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
6ec3058e 1fee2701

+67 -3
+67 -3
tools/perf/pmu-events/intel_metrics.py
··· 6 6 import os 7 7 import re 8 8 from typing import Optional 9 - from metric import (d_ratio, has_event, max, CheckPmu, Event, JsonEncodeMetric, 10 - JsonEncodeMetricGroupDescriptions, Literal, LoadEvents, 11 - Metric, MetricConstraint, MetricGroup, MetricRef, Select) 9 + from metric import (d_ratio, has_event, max, source_count, CheckPmu, Event, 10 + JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, 11 + Literal, LoadEvents, Metric, MetricConstraint, MetricGroup, 12 + MetricRef, Select) 12 13 13 14 # Global command line arguments. 14 15 _args = None ··· 625 624 ], description="L2 data cache analysis") 626 625 627 626 627 + def IntelMissLat() -> Optional[MetricGroup]: 628 + try: 629 + ticks = Event("UNC_CHA_CLOCKTICKS", "UNC_C_CLOCKTICKS") 630 + data_rd_loc_occ = Event("UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_LOCAL", 631 + "UNC_CHA_TOR_OCCUPANCY.IA_MISS", 632 + "UNC_C_TOR_OCCUPANCY.MISS_LOCAL_OPCODE", 633 + "UNC_C_TOR_OCCUPANCY.MISS_OPCODE") 634 + data_rd_loc_ins = Event("UNC_CHA_TOR_INSERTS.IA_MISS_DRD_LOCAL", 635 + "UNC_CHA_TOR_INSERTS.IA_MISS", 636 + "UNC_C_TOR_INSERTS.MISS_LOCAL_OPCODE", 637 + "UNC_C_TOR_INSERTS.MISS_OPCODE") 638 + data_rd_rem_occ = Event("UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE", 639 + "UNC_CHA_TOR_OCCUPANCY.IA_MISS", 640 + "UNC_C_TOR_OCCUPANCY.MISS_REMOTE_OPCODE", 641 + "UNC_C_TOR_OCCUPANCY.NID_MISS_OPCODE") 642 + data_rd_rem_ins = Event("UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE", 643 + "UNC_CHA_TOR_INSERTS.IA_MISS", 644 + "UNC_C_TOR_INSERTS.MISS_REMOTE_OPCODE", 645 + "UNC_C_TOR_INSERTS.NID_MISS_OPCODE") 646 + except: 647 + return None 648 + 649 + if (data_rd_loc_occ.name == "UNC_C_TOR_OCCUPANCY.MISS_LOCAL_OPCODE" or 650 + data_rd_loc_occ.name == "UNC_C_TOR_OCCUPANCY.MISS_OPCODE"): 651 + data_rd = 0x182 652 + for e in [data_rd_loc_occ, data_rd_loc_ins, data_rd_rem_occ, data_rd_rem_ins]: 653 + e.name += f"/filter_opc={hex(data_rd)}/" 654 + elif data_rd_loc_occ.name == "UNC_CHA_TOR_OCCUPANCY.IA_MISS": 655 + # Demand Data Read - Full cache-line read requests from core for 656 + # lines to be cached in S or E, typically for data 657 + demand_data_rd = 0x202 658 + # LLC Prefetch Data - Uncore will first look up the line in the 659 + # LLC; for a cache hit, the LRU will be updated, on a miss, the 660 + # DRd will be initiated 661 + llc_prefetch_data = 0x25a 662 + local_filter = (f"/filter_opc0={hex(demand_data_rd)}," 663 + f"filter_opc1={hex(llc_prefetch_data)}," 664 + "filter_loc,filter_nm,filter_not_nm/") 665 + remote_filter = (f"/filter_opc0={hex(demand_data_rd)}," 666 + f"filter_opc1={hex(llc_prefetch_data)}," 667 + "filter_rem,filter_nm,filter_not_nm/") 668 + for e in [data_rd_loc_occ, data_rd_loc_ins]: 669 + e.name += local_filter 670 + for e in [data_rd_rem_occ, data_rd_rem_ins]: 671 + e.name += remote_filter 672 + else: 673 + assert data_rd_loc_occ.name == "UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_LOCAL", data_rd_loc_occ 674 + 675 + ticks_per_cha = ticks / source_count(data_rd_loc_ins) 676 + loc_lat = interval_sec * 1e9 * data_rd_loc_occ / \ 677 + (ticks_per_cha * data_rd_loc_ins) 678 + ticks_per_cha = ticks / source_count(data_rd_rem_ins) 679 + rem_lat = interval_sec * 1e9 * data_rd_rem_occ / \ 680 + (ticks_per_cha * data_rd_rem_ins) 681 + return MetricGroup("lpm_miss_lat", [ 682 + Metric("lpm_miss_lat_loc", "Local to a socket miss latency in nanoseconds", 683 + loc_lat, "ns"), 684 + Metric("lpm_miss_lat_rem", "Remote to a socket miss latency in nanoseconds", 685 + rem_lat, "ns"), 686 + ]) 687 + 688 + 628 689 def IntelMlp() -> Optional[Metric]: 629 690 try: 630 691 l1d = Event("L1D_PEND_MISS.PENDING") ··· 1068 1005 IntelIlp(), 1069 1006 IntelL2(), 1070 1007 IntelLdSt(), 1008 + IntelMissLat(), 1071 1009 IntelMlp(), 1072 1010 IntelPorts(), 1073 1011 IntelSwpf(),