git: 569f89b2f442 - main - hwpmc: add error for HWPMC_DEBUG without KTR

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Fri, 16 Jun 2023 16:45:08 UTC
The branch main has been updated by mhorne:

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

commit 569f89b2f442e2187f750a5892a1662390364cc6
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2023-06-16 16:38:26 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2023-06-16 16:44:54 +0000

    hwpmc: add error for HWPMC_DEBUG without KTR
    
    The option is a no-op otherwise, but this is not necessarily obvious.
    Failing the compile gives the user a hint.
    
    Reviewed by:    jkoshy, emaste
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D40544
---
 sys/sys/pmc.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/sys/pmc.h b/sys/sys/pmc.h
index cc8c4108aecc..cbb82408dcbf 100644
--- a/sys/sys/pmc.h
+++ b/sys/sys/pmc.h
@@ -1069,6 +1069,12 @@ extern struct pmc_cpu **pmc_pcpu;
 extern struct pmc_driverstats pmc_stats;
 
 #if	defined(HWPMC_DEBUG)
+
+/* HWPMC_DEBUG without KTR will compile but is a no-op. */
+#if !defined(KTR) || !defined(KTR_COMPILE) || ((KTR_COMPILE & KTR_SUBSYS) == 0)
+#error "HWPMC_DEBUG requires KTR and KTR_COMPILE=KTR_SUBSYS -- see ktr(4)"
+#endif
+
 #include <sys/ktr.h>
 
 #define	__pmcdbg_used		/* unused variable annotation */