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
F176603034: D59361.id189818.diff
Tue, Oct 20, 4:01 AM
F176571079: D59361.id188245.diff
Mon, Oct 19, 10:37 PM
F176571048: D59361.id189818.diff
Mon, Oct 19, 10:36 PM
F176570944: D59361.id188460.diff
Mon, Oct 19, 10:35 PM
F176544499: D59361.id189818.diff
Mon, Oct 19, 5:27 PM
Unknown Object (File)
Sun, Oct 18, 11:02 PM
Unknown Object (File)
Sun, Oct 18, 11:50 AM
Unknown Object (File)
Fri, Oct 16, 5:15 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 78170
Build 75053: arc lint + arc unit

Event Timeline

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