Skip to content

Commit 595ccc4

Browse files
committed
libpmc: Fix the L3 counters for AMD Zen 1-4
On AMD processors libpmc was using the topic field (based on filename) to determine the counter's subclass. Unfortunately, the JSON definitions for AMD Zen 1-4 have the L3 counters in files shared with other counters. This change has libpmc to use the pmu field (which is derived from the Unit field in JSON) to determine the correct counter subclass. Sponsored by: Netflix
1 parent 8352e24 commit 595ccc4

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

lib/libpmc/libpmc_pmu_util.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -498,18 +498,7 @@ pmc_pmu_amd_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm,
498498
pm->pm_class = PMC_CLASS_K8;
499499
pe = pmu_event_get(NULL, event_name, &idx);
500500

501-
if (strcmp("l3cache", pe->topic) == 0){
502-
amd->pm_amd_config |= AMD_PMC_TO_EVENTMASK(ped->ped_event);
503-
amd->pm_amd_sub_class = PMC_AMD_SUB_CLASS_L3_CACHE;
504-
amd->pm_amd_config |= AMD_PMC_TO_L3SLICE(ped->ped_l3_slice);
505-
amd->pm_amd_config |= AMD_PMC_TO_L3CORE(ped->ped_l3_thread);
506-
}
507-
else if (strcmp("data fabric", pe->topic) == 0){
508-
509-
amd->pm_amd_config |= AMD_PMC_TO_EVENTMASK_DF(ped->ped_event);
510-
amd->pm_amd_sub_class = PMC_AMD_SUB_CLASS_DATA_FABRIC;
511-
}
512-
else{
501+
if (pe->pmu == NULL) {
513502
amd->pm_amd_config |= AMD_PMC_TO_EVENTMASK(ped->ped_event);
514503
amd->pm_amd_sub_class = PMC_AMD_SUB_CLASS_CORE;
515504
if ((pm->pm_caps & (PMC_CAP_USER|PMC_CAP_SYSTEM)) == 0 ||
@@ -526,7 +515,19 @@ pmc_pmu_amd_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm,
526515
amd->pm_amd_config |= AMD_PMC_INVERT;
527516
if (pm->pm_caps & PMC_CAP_INTERRUPT)
528517
amd->pm_amd_config |= AMD_PMC_INT;
518+
} else if (strcmp("amd_l3", pe->pmu) == 0) {
519+
amd->pm_amd_config |= AMD_PMC_TO_EVENTMASK(ped->ped_event);
520+
amd->pm_amd_sub_class = PMC_AMD_SUB_CLASS_L3_CACHE;
521+
amd->pm_amd_config |= AMD_PMC_TO_L3SLICE(ped->ped_l3_slice);
522+
amd->pm_amd_config |= AMD_PMC_TO_L3CORE(ped->ped_l3_thread);
523+
} else if (strcmp("amd_df", pe->pmu) == 0) {
524+
amd->pm_amd_config |= AMD_PMC_TO_EVENTMASK_DF(ped->ped_event);
525+
amd->pm_amd_sub_class = PMC_AMD_SUB_CLASS_DATA_FABRIC;
526+
} else {
527+
printf("PMC pmu '%s' is not supported!\n", pe->pmu);
528+
return (ENODEV);
529529
}
530+
530531
return (0);
531532
}
532533

0 commit comments

Comments
 (0)