libpmc: Map AMD Family 1Ah models 00h-0Fh to amdzen5

178d0b5b8d adapted the Zen 5 pattern matching from Linux perf.
However, Linux prints CPU models with a single digit when under 0xF
(allowing |[[:xdigit:]] to match 0h-Fh), whereas hwpmc/libpmc formats
model numbers with two leading hex digits (00h-0Fh).

Fix the pattern to explicitly cover two-digit hex models in the 00h-0Fh
range, and add a test case verifying table selection across Zen 5 and Zen 6
cpuid strings.

Reviewed by:	Ali Mashtizadeh <[email protected]>
Signed-off-by:	Osvaldo Janeri Filho <[email protected]>
Fixes:		178d0b5b8d ("libpmc: Import AMD Zen 6 PMU events.")
Sponsored by:	Advanced Micro Devices, Inc.
Differential Revision:	https://reviews.freebsd.org/D60625
This commit is contained in:
Osvaldo Janeri Filho authored and Mitchell Horne committed 2026-11-04 13:53:55 -04:00
1 parent 869bb2bbb7
commit a01ea51561
3 files changed
+89 -1

No files matched your search

+1 -1
View File
@@ -59,6 +59,6 @@ AuthenticAMD-23-[012][0-9A-F],v2,amdzen1,core
AuthenticAMD-23-[[:xdigit:]]+,v1,amdzen2,core
AuthenticAMD-25-[0245][[:xdigit:]],v1,amdzen3,core
AuthenticAMD-25-[[:xdigit:]]+,v1,amdzen4,core
AuthenticAMD-26-[12467][[:xdigit:]],v1,amdzen5,core
AuthenticAMD-26-[012467][[:xdigit:]],v1,amdzen5,core
AuthenticAMD-26-[[:xdigit:]]+,v1,amdzen6,core
HygonGenuine-24-00,v2,amdzen1,core
1 Family-model Version Filename EventType
59 AuthenticAMD-23-[[:xdigit:]]+ v1 amdzen2 core
60 AuthenticAMD-25-[0245][[:xdigit:]] v1 amdzen3 core
61 AuthenticAMD-25-[[:xdigit:]]+ v1 amdzen4 core
62 AuthenticAMD-26-[12467][[:xdigit:]] AuthenticAMD-26-[012467][[:xdigit:]] v1 amdzen5 core
63 AuthenticAMD-26-[[:xdigit:]]+ v1 amdzen6 core
64 HygonGenuine-24-00 v2 amdzen1 core
+1
View File
@@ -6,6 +6,7 @@ ATF_TESTS_C+= pmc_detach_test
ATF_TESTS_C+= pmc_exec_test
.if ${MACHINE_ARCH} == "amd64"
ATF_TESTS_C+= pmc_exterr_test
ATF_TESTS_C+= pmc_mapfile_test
.endif
ATF_TESTS_C+= pmc_lifecycle_test
ATF_TESTS_C+= pmc_log_test
+87
View File
@@ -0,0 +1,87 @@
/*
* Copyright (c) 2026 Advanced Micro Devices, Inc.
*
* Author: Osvaldo Janeri Filho <ojanerif@amd.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
/*
* libpmc picks its pmu-events table by matching kern.hwpmc.cpuid against
* mapfile.csv. hwpmc prints the model with two digits, so Turin (Family
* 1Ah, model 02h) is "AuthenticAMD-26-02-<stepping>". For Zen 5 and Zen 6
* cpuid strings, look up an event that only one of amdzen5 and amdzen6 has.
* No PMC hardware is needed.
*/
#include <sys/param.h>
#include <atf-c.h>
#include <pmc.h>
#define ZEN5_ONLY_EVENT "bp_l2_btb_correct"
#define ZEN6_ONLY_EVENT "bp_fe_redir.all"
static const char *const zen5_cpuids[] = {
"AuthenticAMD-26-02-0",
"AuthenticAMD-26-0F-0",
"AuthenticAMD-26-11-0",
"AuthenticAMD-26-2F-0",
"AuthenticAMD-26-44-0",
"AuthenticAMD-26-70-0",
"AuthenticAMD-26-7F-0",
};
static const char *const zen6_cpuids[] = {
"AuthenticAMD-26-50-0",
"AuthenticAMD-26-80-0",
"AuthenticAMD-26-C0-0",
"AuthenticAMD-26-D8-0",
"AuthenticAMD-26-EF-0",
};
static void
check_table(const char *cpuid, const char *has, const char *lacks,
const char *table)
{
ATF_CHECK_MSG(pmc_pmu_idx_get_by_event(cpuid, has) >= 0 &&
pmc_pmu_idx_get_by_event(cpuid, lacks) < 0,
"%s does not select %s", cpuid, table);
}
ATF_TC(zen5_models);
ATF_TC_HEAD(zen5_models, tc)
{
atf_tc_set_md_var(tc, "descr",
"Zen 5 cpuid strings, including models 00h-0Fh, select amdzen5");
}
ATF_TC_BODY(zen5_models, tc)
{
size_t i;
for (i = 0; i < nitems(zen5_cpuids); i++)
check_table(zen5_cpuids[i], ZEN5_ONLY_EVENT, ZEN6_ONLY_EVENT,
"amdzen5");
}
ATF_TC(zen6_models);
ATF_TC_HEAD(zen6_models, tc)
{
atf_tc_set_md_var(tc, "descr", "Zen 6 cpuid strings select amdzen6");
}
ATF_TC_BODY(zen6_models, tc)
{
size_t i;
for (i = 0; i < nitems(zen6_cpuids); i++)
check_table(zen6_cpuids[i], ZEN6_ONLY_EVENT, ZEN5_ONLY_EVENT,
"amdzen6");
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, zen5_models);
ATF_TP_ADD_TC(tp, zen6_models);
return (atf_no_error());
}