From nobody Wed Nov 04 17:47:59 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jKXwP3Nv2z6ybxJ for ; Wed, 04 Nov 2026 17:48:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jKXwN6z0Zz5393 for ; Wed, 04 Nov 2026 17:48:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793814485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DvuxNSm1EfPt2cfyQG3gN3F2t74o5WKYGaLMqb/+OLg=; b=LK3J42+/q3XgDYML/W5AS4Mb5kTfSJR7LD7aZa/AQsuk2Jld09jqjOKtx9wT5TRnXUSTEk OTQEr04jNjSPxHYieS3k/zTF7Mizjgncc7XMu7mcoXx/hsyuhjz6dgp/K1dQvM9avYMH3D Hpwj+j4BMUSunw/UrjAWLrt6oGHyx5LhHLVqV8WOWCcbwVGoxnDQzJ8v45cOMyfsBpOgne AowKCfAMrW6/FCHiIVPnUG84atYloc8jnZW/HgIdnIKIPulf79GU+/+FXpTt4iJ/7bUSeJ WW/dCsdNAjZJnBjJ6vMxPDZaMzk/ZWWkdtubnXvL36vdK+QEooAOdsLxQ02tEg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793814485; b=PkFEN/fGKOiNGOS37Q9kICFpG1t1cZT0My/9T0lw2AJj0Qn9x3SOiaixaRbqu1Mj4IDbTt hUFxMMwm04mjYe8kXffkwQseVaD4hwiY+fVSfnOnlGgTmCoUzq9q2Mb7J0WqEbcggNKFim UR9/KWG3lr827DHHekwEhDN26Zj/R+aQhU0J85nhbwbn/EF2E5T1sAJiBPovCqk+Az5zXO wz4zgDnCPSRnsQ7YhJzHpysUqQJnqOPfe79s8abahMoml7oj+oer9YljVjNbrHM1nTEuoH 2Fusbr9RQ2TD3/A+Rwzy+Wi0KhPkJHdzGD4A1ZXwLPs80FbYyJanlU2TNz7rZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793814485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DvuxNSm1EfPt2cfyQG3gN3F2t74o5WKYGaLMqb/+OLg=; b=dxqRhqRkCqmjtfAvXQoGIet+mSiNzWXA64+fcXLoF1uQA6EpULk3mIFWrORXKx4yAI6tLt b+rP5W5FkpTOGSzNLwxVOoCwtVvfi9cs/xr57oswc9ebyEkHaGjo+Igj9duIEMz3wnECst S9ZlTrBvqfi5M0nK5lcVPy58ItYFn3V/aWiAuJmWlg0hjol2bR8wY26e+i5Zvjdbr+2+E8 WOaPRp5jmY7PJn/7njWN0L9hzq92HglewkBlL/xsWUOFsTPNbS6HuZpl10rrHPKAeEaPzm N5xiQghtcnVFeau/b/Um4bh9k4mKENYsVQdkjGBZYuEE2p3Ez/JU4XxF5v9/xw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jKXwN6MW3z1CLd for ; Wed, 04 Nov 2026 17:48:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 273d5 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 04 Nov 2026 17:47:59 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Osvaldo Janeri Filho From: Mitchell Horne Subject: git: 869bb2bbb780 - main - hwpmc: use the PerfMonV2 DF encoding on Family 19h List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 869bb2bbb7809e79cd672a6adc46bdc79a38f382 Auto-Submitted: auto-generated Date: Wed, 04 Nov 2026 17:47:59 +0000 Message-Id: <6aeb6fcf.273d5.362e786a@gitrepo.freebsd.org> The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=869bb2bbb7809e79cd672a6adc46bdc79a38f382 commit 869bb2bbb7809e79cd672a6adc46bdc79a38f382 Author: Osvaldo Janeri Filho AuthorDate: 2026-11-04 17:43:15 +0000 Commit: Mitchell Horne CommitDate: 2026-11-04 17:47:57 +0000 hwpmc: use the PerfMonV2 DF encoding on Family 19h Family 19h processors with PerfMonV2 use the Family 1Ah DF encoding. Selecting it by family alone drops the upper unit mask bits, and most DF events count zero. Reviewed by: Ali Mashtizadeh Sponsored by: AMD MFC after: 1 week Signed-off-by: Osvaldo Janeri Filho Differential Revision: https://reviews.freebsd.org/D60769 --- lib/libpmc/libpmc_pmu_util.c | 21 ++++++++++++++++++++- sys/dev/hwpmc/hwpmc_amd.c | 2 +- sys/dev/hwpmc/hwpmc_amd.h | 4 ++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/libpmc/libpmc_pmu_util.c b/lib/libpmc/libpmc_pmu_util.c index e0fac9884b77..6472dd8311de 100644 --- a/lib/libpmc/libpmc_pmu_util.c +++ b/lib/libpmc/libpmc_pmu_util.c @@ -34,6 +34,12 @@ #include #include #include + +#if defined(__amd64__) || defined(__i386__) +#include +#endif + +#include #include #include #include @@ -520,6 +526,18 @@ pmc_pmu_print_counter_full(const char *ev) } #if defined(__amd64__) || defined(__i386__) +static bool +pmu_events_amd_perfmonv2(void) +{ + u_int regs[4]; + + do_cpuid(0x80000000, regs); + if (regs[0] < CPUID_EXTPERFMON) + return (false); + do_cpuid(CPUID_EXTPERFMON, regs); + return (EXTPERFMON_PERFMONV2(regs[0]) != 0); +} + static int pmc_pmu_amd_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm, struct pmu_event_desc *ped) @@ -581,7 +599,8 @@ pmc_pmu_amd_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm, } } else if (strcmp("amd_df", pe->pmu) == 0) { amd->pm_amd_sub_class = PMC_AMD_SUB_CLASS_DATA_FABRIC; - if (cpu_family <= 0x19) { + if (cpu_family < 0x19 || + (cpu_family == 0x19 && !pmu_events_amd_perfmonv2())) { amd->pm_amd_config |= AMD_PMC_DF1_TO_EVENTMASK(ped->ped_event); amd->pm_amd_config |= diff --git a/sys/dev/hwpmc/hwpmc_amd.c b/sys/dev/hwpmc/hwpmc_amd.c index 14e850ee7410..dac50207656d 100644 --- a/sys/dev/hwpmc/hwpmc_amd.c +++ b/sys/dev/hwpmc/hwpmc_amd.c @@ -250,7 +250,7 @@ amd_init_policy(void) amd_l3_allowed_mask = (family <= 0x17) ? AMD_PMC_L3_FAMILY17_MASK : AMD_PMC_L3_FAMILY19_MASK; - amd_df_allowed_mask = (family <= 0x19) ? + amd_df_allowed_mask = (family <= 0x19 && !amd_perfmon_v2) ? AMD_PMC_DF_FAMILY17_MASK : AMD_PMC_DF_FAMILY1A_MASK; amd_umc_allowed_mask = AMD_PMC_UMC_MASK; diff --git a/sys/dev/hwpmc/hwpmc_amd.h b/sys/dev/hwpmc/hwpmc_amd.h index 4936ea620884..e12ef90bb51a 100644 --- a/sys/dev/hwpmc/hwpmc_amd.h +++ b/sys/dev/hwpmc/hwpmc_amd.h @@ -158,8 +158,8 @@ PMC_CAP_QUALIFIER | PMC_CAP_DOMWIDE) /* - * DF counters change their encoding between Family 19h and Family 1Ah - * processors. + * DF counters change their encoding between Family 19h processors without + * PerfMonV2 and later processors. * * Refer to the same documents as the L3 counters. */