HomeFreeBSD

hwpmc: fix false runcount assertion in user callchain capture

Description

hwpmc: fix false runcount assertion in user callchain capture

pmc_capture_user_callchain() checks a PMC's runcount before walking
the user stack, but reads it without holding the spinlock that
protects it. hardclock() can run on the same CPU during the capture
and drop the runcount to zero in between, tripping the assertion and
panicking INVARIANTS kernels under load.

Move the check inside the existing spinlock, right where the code
already confirms the sample is still valid. 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/D58571

Details

Provenance
afscoelho_gmail.comAuthored on Aug 11 2026, 4:16 PM
mhorneCommitted on Aug 11 2026, 4:22 PM
Reviewer
mhorne
Differential Revision
D58571: hwpmc: fix false runcount assertion in user callchain capture
Parents
rGe85ae6f6a6c0: fbsdrun_virtio_msix(): update virtio_msix to virtio.msix
Branches
Unknown
Tags
Unknown