Page MenuHomeFreeBSD

hwpmc: fix false runcount assertion in user callchain capture
ClosedPublic

Authored by afscoelho_gmail.com on Fri, Jul 31, 2:21 PM.
Tags
None
Referenced Files
F168339923: D58571.id.diff
Thu, Aug 27, 4:49 PM
F168297963: D58571.id183155.diff
Thu, Aug 27, 12:07 PM
Unknown Object (File)
Thu, Aug 27, 10:23 AM
Unknown Object (File)
Wed, Aug 26, 4:12 AM
Unknown Object (File)
Sun, Aug 23, 4:13 AM
Unknown Object (File)
Fri, Aug 21, 8:47 PM
Unknown Object (File)
Thu, Aug 20, 5:53 AM
Unknown Object (File)
Thu, Aug 20, 4:14 AM
Subscribers

Details

Summary

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>
Sponsored by: AMD

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

spinlock_enter() is weird, and a somewhat confusing name. I believe it is the disabling of interrupts that really prevents hardclock() from interfering. It is somewhat misleading to say that pm->pm_runcount is "protected" by a spinlock.

Regardless, code change LGTM.

This revision is now accepted and ready to land.Wed, Aug 5, 4:58 PM