aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAli Mashtizadeh <ali@mashtizadeh.com>2026-08-13 23:08:20 +0000
committerMitchell Horne <mhorne@FreeBSD.org>2026-09-03 16:04:06 +0000
commitf19f44634afd859e445c7b13bbdf715a493b499b (patch)
tree191d82c4de4904112b6dc89811ae320f9e1afd13 /lib
parent125ec0e30785bb0cbca7aa6c0b1a34b75e53078d (diff)
pmc: Add support for AMD UMC counters
This change adds support for AMD's UMC performance counters. It is a bit more complicated than existing counters because the enable bit has moved. This supports Zen 4 through most Zen 6 chips as UMC counters are per-node, where a node does not necessarily translate to a NUMA domain. A few follow up changes to PMC will address this limitation. Reviewed by: mhorne Sponsored by: Netflix Pull Request: https://github.com/freebsd/freebsd-src/pull/2368
Diffstat (limited to 'lib')
-rw-r--r--lib/libpmc/libpmc_pmu_util.c7
-rw-r--r--lib/libpmc/pmu-events/jevents.c4
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/libpmc/libpmc_pmu_util.c b/lib/libpmc/libpmc_pmu_util.c
index 050cbc120cd8..647fceabb05d 100644
--- a/lib/libpmc/libpmc_pmu_util.c
+++ b/lib/libpmc/libpmc_pmu_util.c
@@ -230,6 +230,7 @@ struct pmu_event_desc {
uint32_t ped_coreid;
uint32_t ped_allsources;
uint32_t ped_allcores;
+ uint32_t ped_rdwrmask;
uint32_t ped_event;
uint32_t ped_frontend;
uint32_t ped_ldlat;
@@ -378,6 +379,8 @@ pmu_parse_event(struct pmu_event_desc *ped, const char *eventin)
ped->ped_allcores = strtol(value, NULL, 0);
else if (strcmp(key, "allsources") == 0)
ped->ped_allsources = strtol(value, NULL, 0);
+ else if (strcmp(key, "rdwrmask") == 0)
+ ped->ped_rdwrmask = strtol(value, NULL, 0);
else if (strcmp(key, "pebs") == 0)
ped->ped_pebs = strtol(value, NULL, 10);
else {
@@ -589,6 +592,10 @@ pmc_pmu_amd_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm,
amd->pm_amd_config |=
AMD_PMC_DF2_TO_UNITMASK(ped->ped_umask);
}
+ } else if (strcmp("amd_umc", pe->pmu) == 0) {
+ amd->pm_amd_sub_class = PMC_AMD_SUB_CLASS_UMC;
+ amd->pm_amd_config |= AMD_PMC_UMC_TO_EVENTMASK(ped->ped_event);
+ amd->pm_amd_config |= AMD_PMC_UMC_TO_RDWRMASK(ped->ped_rdwrmask);
} else {
printf("PMC pmu '%s' is not supported!\n", pe->pmu);
return (EOPNOTSUPP);
diff --git a/lib/libpmc/pmu-events/jevents.c b/lib/libpmc/pmu-events/jevents.c
index b4d073f13708..7e6b19c1b30b 100644
--- a/lib/libpmc/pmu-events/jevents.c
+++ b/lib/libpmc/pmu-events/jevents.c
@@ -265,6 +265,7 @@ static struct map {
/* AMD */
{ "L3PMC", "amd_l3" },
{ "DFPMC", "amd_df" },
+ { "UMCPMC", "amd_umc" },
/* ARM HiSilicon */
{ "hisi_sicl,cpa", "hisi_sicl,cpa"},
{ "hisi_sccl,ddrc", "hisi_sccl,ddrc" },
@@ -648,7 +649,8 @@ static int json_events(const char *fn,
if (nz)
addfield(map, &cmask, "", "cmask=", val);
} else if (json_streq(map, field, "RdWrMask")) {
- /* AMD UMC */
+ if (nz)
+ addfield(map, &cmask, "", "rdwrmask=", val);
} else if (json_streq(map, field, "Invert")) {
if (nz)
addfield(map, &inv, "", "inv=", val);