Page MenuHomeFreeBSD

kern: run the PMC context-switch-in hook in fork_exit
Needs ReviewPublic

Authored by afscoelho_gmail.com on Sep 3 2026, 9:32 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 9, 6:38 PM
Unknown Object (File)
Wed, Oct 7, 1:29 AM
Unknown Object (File)
Tue, Oct 6, 4:36 AM
Unknown Object (File)
Mon, Oct 5, 6:01 AM
Unknown Object (File)
Sun, Oct 4, 2:28 PM
Unknown Object (File)
Sun, Oct 4, 2:20 AM
Unknown Object (File)
Sun, Oct 4, 1:31 AM
Unknown Object (File)
Sat, Oct 3, 9:26 AM
Subscribers

Details

Summary

A new thread reaches the CPU for the first time through fork_exit()
instead of sched_switch(), so the context-switch-in hook that
sched_switch() runs is skipped. An inherited PMC is then not
programmed onto the hardware until the child's first real context
switch, and hwpmc does not count the work of a short-lived child.

Run the hook from fork_exit() for a process that uses PMCs. This
mirrors the mi_switch() path that fork_exit() already emulates.

Sponsored by: AMD

Signed-off-by: Andre Silva <andasilv@amd.com>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 77634
Build 74517: arc lint + arc unit

Event Timeline

Rebase on main (D60141 and D60185 are committed). No change.