Page MenuHomeFreeBSD

hwpmc: let MD code see every context switch and exec
Needs ReviewPublic

Authored by afscoelho_gmail.com on Sat, Oct 10, 1:22 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 11, 10:07 AM
Unknown Object (File)
Sun, Oct 11, 6:07 AM
Unknown Object (File)
Sun, Oct 11, 1:31 AM
Unknown Object (File)
Sat, Oct 10, 4:14 PM
Unknown Object (File)
Sat, Oct 10, 4:08 PM
Unknown Object (File)
Sat, Oct 10, 2:19 PM
Unknown Object (File)
Sat, Oct 10, 6:44 AM
Unknown Object (File)
Sat, Oct 10, 6:34 AM
Subscribers

Details

Summary

Branch records do not track address spaces, so the MD code must clear
them on every context switch and exec. Add optional pmd_lbr_csw()
and pmd_lbr_exec() hooks.

While a system-mode PMC that needs them runs, call the switch hooks for
all threads. Otherwise the scheduler fast path is unchanged.

Depends on D60566

Test Plan

Built amd64 GENERIC + hwpmc.ko, GENERIC without HWPMC_HOOKS, and arm64.
Ran tests/sys/pmc on AMD Zen 6 (LBR v2).

Diff Detail

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

Event Timeline

sys/dev/hwpmc/hwpmc_mod.c
1782

Why do you need the critical section there?
PMC_FN_CSW_OUT is always called under some spinlock: either the thread lock when done during normal context switch, or the process spinlock if called during thread exit. As is, the context switch is not possible already there.

You might add CRITICAL_ASSERT() there instead, if needed, I believe.