Skip to content

Commit

Permalink
perf vendor events amd: Fix Zen 4 cache latency events
Browse files Browse the repository at this point in the history
L3PMCx0AC and L3PMCx0AD, used in l3_xi_sampled_latency* events, have a
quirk that requires them to be programmed with SliceId set to 0x3.
Without this, the events do not count at all and affects dependent
metrics such as l3_read_miss_latency.

If ThreadMask is not specified, the amd-uncore driver internally sets
ThreadMask to 0x3, EnAllCores to 0x1 and EnAllSlices to 0x1 but does
not set SliceId. Since SliceId must also be set to 0x3 in this case,
specify all the other fields explicitly.

E.g.

  $ sudo perf stat -e l3_xi_sampled_latency.all,l3_xi_sampled_latency_requests.all -a sleep 1

Before:

   Performance counter stats for 'system wide':

                   0      l3_xi_sampled_latency.all
                   0      l3_xi_sampled_latency_requests.all

         1.005155399 seconds time elapsed

After:

   Performance counter stats for 'system wide':

             921,446      l3_xi_sampled_latency.all
              54,210      l3_xi_sampled_latency_requests.all

         1.005664472 seconds time elapsed

Fixes: 5b2ca34 ("perf vendor events amd: Add Zen 4 uncore events")
Signed-off-by: Sandipan Das <sandipan.das@amd.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Cc: ananth.narayan@amd.com
Cc: ravi.bangoria@amd.com
Cc: eranian@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240301084431.646221-1-sandipan.das@amd.com
  • Loading branch information
Sandipan Das authored and Namhyung Kim committed Mar 4, 2024
1 parent 507ad2b commit 498d348
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tools/perf/pmu-events/arch/x86/amdzen4/cache.json
Original file line number Diff line number Diff line change
Expand Up @@ -676,97 +676,153 @@
"EventCode": "0xac",
"BriefDescription": "Average sampled latency when data is sourced from DRAM in the same NUMA node.",
"UMask": "0x01",
"EnAllCores": "0x1",
"EnAllSlices": "0x1",
"SliceId": "0x3",
"ThreadMask": "0x3",
"Unit": "L3PMC"
},
{
"EventName": "l3_xi_sampled_latency.dram_far",
"EventCode": "0xac",
"BriefDescription": "Average sampled latency when data is sourced from DRAM in a different NUMA node.",
"UMask": "0x02",
"EnAllCores": "0x1",
"EnAllSlices": "0x1",
"SliceId": "0x3",
"ThreadMask": "0x3",
"Unit": "L3PMC"
},
{
"EventName": "l3_xi_sampled_latency.near_cache",
"EventCode": "0xac",
"BriefDescription": "Average sampled latency when data is sourced from another CCX's cache when the address was in the same NUMA node.",
"UMask": "0x04",
"EnAllCores": "0x1",
"EnAllSlices": "0x1",
"SliceId": "0x3",
"ThreadMask": "0x3",
"Unit": "L3PMC"
},
{
"EventName": "l3_xi_sampled_latency.far_cache",
"EventCode": "0xac",
"BriefDescription": "Average sampled latency when data is sourced from another CCX's cache when the address was in a different NUMA node.",
"UMask": "0x08",
"EnAllCores": "0x1",
"EnAllSlices": "0x1",
"SliceId": "0x3",
"ThreadMask": "0x3",
"Unit": "L3PMC"
},
{
"EventName": "l3_xi_sampled_latency.ext_near",
"EventCode": "0xac",
"BriefDescription": "Average sampled latency when data is sourced from extension memory (CXL) in the same NUMA node.",
"UMask": "0x10",
"EnAllCores": "0x1",
"EnAllSlices": "0x1",
"SliceId": "0x3",
"ThreadMask": "0x3",
"Unit": "L3PMC"
},
{
"EventName": "l3_xi_sampled_latency.ext_far",
"EventCode": "0xac",
"BriefDescription": "Average sampled latency when data is sourced from extension memory (CXL) in a different NUMA node.",
"UMask": "0x20",
"EnAllCores": "0x1",
"EnAllSlices": "0x1",
"SliceId": "0x3",
"ThreadMask": "0x3",
"Unit": "L3PMC"
},
{
"EventName": "l3_xi_sampled_latency.all",
"EventCode": "0xac",
"BriefDescription": "Average sampled latency from all data sources.",
"UMask": "0x3f",
"EnAllCores": "0x1",
"EnAllSlices": "0x1",
"SliceId": "0x3",
"ThreadMask": "0x3",
"Unit": "L3PMC"
},
{
"EventName": "l3_xi_sampled_latency_requests.dram_near",
"EventCode": "0xad",
"BriefDescription": "L3 cache fill requests sourced from DRAM in the same NUMA node.",
"UMask": "0x01",
"EnAllCores": "0x1",
"EnAllSlices": "0x1",
"SliceId": "0x3",
"ThreadMask": "0x3",
"Unit": "L3PMC"
},
{
"EventName": "l3_xi_sampled_latency_requests.dram_far",
"EventCode": "0xad",
"BriefDescription": "L3 cache fill requests sourced from DRAM in a different NUMA node.",
"UMask": "0x02",
"EnAllCores": "0x1",
"EnAllSlices": "0x1",
"SliceId": "0x3",
"ThreadMask": "0x3",
"Unit": "L3PMC"
},
{
"EventName": "l3_xi_sampled_latency_requests.near_cache",
"EventCode": "0xad",
"BriefDescription": "L3 cache fill requests sourced from another CCX's cache when the address was in the same NUMA node.",
"UMask": "0x04",
"EnAllCores": "0x1",
"EnAllSlices": "0x1",
"SliceId": "0x3",
"ThreadMask": "0x3",
"Unit": "L3PMC"
},
{
"EventName": "l3_xi_sampled_latency_requests.far_cache",
"EventCode": "0xad",
"BriefDescription": "L3 cache fill requests sourced from another CCX's cache when the address was in a different NUMA node.",
"UMask": "0x08",
"EnAllCores": "0x1",
"EnAllSlices": "0x1",
"SliceId": "0x3",
"ThreadMask": "0x3",
"Unit": "L3PMC"
},
{
"EventName": "l3_xi_sampled_latency_requests.ext_near",
"EventCode": "0xad",
"BriefDescription": "L3 cache fill requests sourced from extension memory (CXL) in the same NUMA node.",
"UMask": "0x10",
"EnAllCores": "0x1",
"EnAllSlices": "0x1",
"SliceId": "0x3",
"ThreadMask": "0x3",
"Unit": "L3PMC"
},
{
"EventName": "l3_xi_sampled_latency_requests.ext_far",
"EventCode": "0xad",
"BriefDescription": "L3 cache fill requests sourced from extension memory (CXL) in a different NUMA node.",
"UMask": "0x20",
"EnAllCores": "0x1",
"EnAllSlices": "0x1",
"SliceId": "0x3",
"ThreadMask": "0x3",
"Unit": "L3PMC"
},
{
"EventName": "l3_xi_sampled_latency_requests.all",
"EventCode": "0xad",
"BriefDescription": "L3 cache fill requests sourced from all data sources.",
"UMask": "0x3f",
"EnAllCores": "0x1",
"EnAllSlices": "0x1",
"SliceId": "0x3",
"ThreadMask": "0x3",
"Unit": "L3PMC"
}
]
4 changes: 4 additions & 0 deletions tools/perf/pmu-events/jevents.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ def canonicalize_value(val: str) -> str:
('UMask', 'umask='),
('NodeType', 'type='),
('RdWrMask', 'rdwrmask='),
('EnAllCores', 'enallcores='),
('EnAllSlices', 'enallslices='),
('SliceId', 'sliceid='),
('ThreadMask', 'threadmask='),
]
for key, value in event_fields:
if key in jd and not is_zero(jd[key]):
Expand Down

0 comments on commit 498d348

Please sign in to comment.