Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Jul 2026 19:14:16 +0000
From:      Olivier Cochard <olivier@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 6c4d9b9af1a3 - main - hwpmc: fix event allocation on pre-Zen AMD CPUs
Message-ID:  <6a68ff88.42c64.963a62e@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by olivier:

URL: https://cgit.FreeBSD.org/src/commit/?id=6c4d9b9af1a3b247bf82a4228c835d106f535613

commit 6c4d9b9af1a3b247bf82a4228c835d106f535613
Author:     Olivier Cochard <olivier@FreeBSD.org>
AuthorDate: 2026-07-28 19:06:27 +0000
Commit:     Olivier Cochard <olivier@FreeBSD.org>
CommitDate: 2026-07-28 19:11:04 +0000

    hwpmc: fix event allocation on pre-Zen AMD CPUs
    
    amd_allocate_pmc() chose the pmu-events code path whenever pmc_cpuid was
    non-empty, and rejected any allocation lacking PMC_F_EV_PMU.
    But pmc_cpuid is set for every AMD CPU, while the pmu-events tables only cover
    Zen and later.
    On older families (K8, Bobcat, Jaguar/16h, Bulldozer) libpmc finds no
    pmu-events entry and falls back to the legacy path, which never sets
    PMC_F_EV_PMU.
    
    Reviewed by:    mhorne
    Approved by:    mhorne
    MFC after:      1 week
    MFC to:         stable/14, stable/15
    Sponsored by:   Netflix
    Differential Revision:  https://reviews.freebsd.org/D58468
---
 sys/dev/hwpmc/hwpmc_amd.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sys/dev/hwpmc/hwpmc_amd.c b/sys/dev/hwpmc/hwpmc_amd.c
index 41e1eaad9d67..1afdb59ed745 100644
--- a/sys/dev/hwpmc/hwpmc_amd.c
+++ b/sys/dev/hwpmc/hwpmc_amd.c
@@ -403,9 +403,6 @@ amd_allocate_pmc(int cpu __unused, int ri, struct pmc *pm,
 	if (pd->pd_class != a->pm_class)
 		return (EINVAL);
 
-	if ((a->pm_flags & PMC_F_EV_PMU) == 0)
-		return (EINVAL);
-
 	caps = pm->pm_caps;
 
 	PMCDBG2(MDP, ALL, 1,"amd-allocate ri=%d caps=0x%x", ri, caps);
@@ -418,7 +415,8 @@ amd_allocate_pmc(int cpu __unused, int ri, struct pmc *pm,
 	    ((pd->pd_caps & PMC_CAP_PRECISE) == 0))
 		return (EINVAL);
 
-	if (strlen(pmc_cpuid) != 0) {
+	/* PMC_F_EV_PMU: config comes from pmu-events tables. */
+	if ((a->pm_flags & PMC_F_EV_PMU) != 0) {
 		config = a->pm_md.pm_amd.pm_amd_config;
 		if ((config & ~amd_config_mask(amd_pmcdesc[ri].pm_subclass,
 		    caps)) != 0)


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a68ff88.42c64.963a62e>