git: 84b241f1cc12 - stable/15 - hwpmc: fix false callchain assertion on the PMC_UR ring

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Thu, 03 Sep 2026 16:29:52 UTC
The branch stable/15 has been updated by mhorne:

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

commit 84b241f1cc122a8735abffa74ea5f74b56b61648
Author:     Andre Silva <andasilv@amd.com>
AuthorDate: 2026-08-11 16:17:57 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2026-09-03 16:27:28 +0000

    hwpmc: fix false callchain assertion on the PMC_UR ring
    
    pmc_capture_user_callchain() asserts that TDP_CALLCHAIN is set on the
    current thread, but PMC_UR samples never set that flag -- only PMC_HR
    and PMC_SR do. That makes the assertion always fail for PMC_UR,
    panicking INVARIANTS kernels as soon as pmcstat -U is used.
    
    Skip the assertion for PMC_UR. No functional change on kernels built
    without INVARIANTS.
    
    Signed-off-by:  Andre Silva <andasilv@amd.com>
    Reviewed by:    mhorne
    MFC after:      1 week
    Sponsored by:   AMD
    Differential Revision:  https://reviews.freebsd.org/D58572
    
    (cherry picked from commit af3929c5152b47278c0b6ea66efbb782b9637495)
---
 sys/dev/hwpmc/hwpmc_mod.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c
index 21effa80a4bb..342b600276b0 100644
--- a/sys/dev/hwpmc/hwpmc_mod.c
+++ b/sys/dev/hwpmc/hwpmc_mod.c
@@ -4776,7 +4776,7 @@ pmc_capture_user_callchain(int cpu, int ring, struct trapframe *tf)
 	pass = 0;
 	start_ticks = ticks;
 
-	KASSERT(td->td_pflags & TDP_CALLCHAIN,
+	KASSERT(ring == PMC_UR || (td->td_pflags & TDP_CALLCHAIN) != 0,
 	    ("[pmc,%d] Retrieving callchain for thread that doesn't want it",
 	    __LINE__));
 restart: