Re: Simultaneous access to same CPU/counter across processes crashes hwpmc (TSC and other classes)

From: Adrian Chadd <adrian_at_freebsd.org>
Date: Sat, 22 Aug 2026 19:04:07 UTC
On Wed, 19 Aug 2026 at 07:18, Nascimento, Anderson Eduardo
<AndersonEduardo.Nascimento@amd.com> wrote:
>
> Public
>
> Hello all,
>
> I am working on developing a new class of PMCs for the hwpmc subsystem and I ran into a kernel crash while testing my implementation. I believe I have identified the reason the crash happens, and I could try to fix it on the affected classes, but so far it's still not clear to me what model the hwpmc subsystem intends to enforce. Should simultaneous access to the same CPU and counter by different processes be allowed?

The initial design goals and list from the original author (jkoshy@)
is still available on the wiki, eg see
https://wiki.freebsd.org/PmcTools/Features .

So yes, one of the design goals of hwpmc versus what was available in
Linux at the time (oprofile) was that counters
are virtualised both for context switching between processes /and/
multiple processes accessing the same counters
on a given CPU (and as part of this, handling context switching appropriately.)

It's what made it much nicer to use back when it was introduced versus
oprofile. (of course, oprofiles tooling
'just worked' versus pmc..)



-adrian