Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Apr 2026 18:49:25 +0000
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Cc:        Andre Silva <andasilv@amd.com>
Subject:   git: a9a562a08e77 - main - hwpmc_ibs: Add external error handling
Message-ID:  <69f10135.24578.6926be1@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by mhorne:

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

commit a9a562a08e77ac024066a6ca7ab77e7e25e007dc
Author:     Andre Silva <andasilv@amd.com>
AuthorDate: 2026-04-06 20:55:43 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2026-04-28 18:49:21 +0000

    hwpmc_ibs: Add external error handling
    
    Add EXTERR_CAT_HWPMC_IBS to the external error categories and replace generic
    EINVAL returns in ibs_allocate_pmc() with EXTERROR() calls that provide
    detailed error messages.
    
    This will be augmented with additional cases in the near future.
    
    Reviewed by:    mhorne
    Sponsored by:   AMD
    Signed-off-by:  Andre Silva <andasilv@amd.com>
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2134
---
 lib/libc/gen/exterr_cat_filenames.h |  1 +
 sys/dev/hwpmc/hwpmc_ibs.c           | 11 ++++++++---
 sys/sys/exterr_cat.h                |  1 +
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/libc/gen/exterr_cat_filenames.h b/lib/libc/gen/exterr_cat_filenames.h
index e45d05e384bd..be65c1990af5 100644
--- a/lib/libc/gen/exterr_cat_filenames.h
+++ b/lib/libc/gen/exterr_cat_filenames.h
@@ -2,6 +2,7 @@
  * Automatically @generated, use
  * tools/build/make_libc_exterr_cat_filenames.sh
  */
+	[EXTERR_CAT_HWPMC_IBS] = "dev/hwpmc/hwpmc_ibs.c",
 	[EXTERR_CAT_VMM] = "dev/vmm/vmm_dev.c",
 	[EXTERR_CAT_FUSE_DEVICE] = "fs/fuse/fuse_device.c",
 	[EXTERR_CAT_FUSE_VFS] = "fs/fuse/fuse_vfsops.c",
diff --git a/sys/dev/hwpmc/hwpmc_ibs.c b/sys/dev/hwpmc/hwpmc_ibs.c
index 56903699ac51..280a84208847 100644
--- a/sys/dev/hwpmc/hwpmc_ibs.c
+++ b/sys/dev/hwpmc/hwpmc_ibs.c
@@ -38,6 +38,9 @@
 #include <sys/smp.h>
 #include <sys/systm.h>
 
+#define	EXTERR_CATEGORY	EXTERR_CAT_HWPMC_IBS
+#include <sys/exterrvar.h>
+
 #include <machine/cpu.h>
 #include <machine/cpufunc.h>
 #include <machine/md_var.h>
@@ -185,16 +188,18 @@ ibs_allocate_pmc(int cpu __unused, int ri, struct pmc *pm,
 
 	/* check class match */
 	if (a->pm_class != PMC_CLASS_IBS)
-		return (EINVAL);
+		return (EXTERROR(EINVAL, "PMC class is not IBS"));
 	if (a->pm_md.pm_ibs.ibs_type != ri)
-		return (EINVAL);
+		return (EXTERROR(EINVAL,
+		    "IBS type %ju does not match PMC index %ju",
+		    (uint64_t)a->pm_md.pm_ibs.ibs_type, (uint64_t)ri));
 
 	caps = pm->pm_caps;
 
 	PMCDBG2(MDP, ALL, 1, "ibs-allocate ri=%d caps=0x%x", ri, caps);
 
 	if ((caps & PMC_CAP_SYSTEM) == 0)
-		return (EINVAL);
+		return (EXTERROR(EINVAL, "IBS requires SYSTEM capability"));
 
 	if (!PMC_IS_SAMPLING_MODE(a->pm_mode))
 		return (EINVAL);
diff --git a/sys/sys/exterr_cat.h b/sys/sys/exterr_cat.h
index 4f3ff6925242..edc23d7dfbe6 100644
--- a/sys/sys/exterr_cat.h
+++ b/sys/sys/exterr_cat.h
@@ -40,6 +40,7 @@
 #define	EXTERR_CAT_FORK		15
 #define	EXTERR_CAT_PROCEXIT	16
 #define	EXTERR_CAT_VMM		17
+#define	EXTERR_CAT_HWPMC_IBS	18
 
 #endif
 


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69f10135.24578.6926be1>