Repository navigation
Fallback package governor driven by per-core instruction rates - #196
Closed
totemofwolf wants to merge 1 commit into
Closed
totemofwolf wants to merge 1 commit into
totemofwolf wants to merge 1 commit into
Conversation
On systems where the idle path does not route through our pmDispatch (Cezanne laptops with another dispatch owner present), the idle-hook accounting in pmRyzen_machine_idle never runs and every core stays pinned at P0 forever (24W / 90C at desktop idle on a 5800H). Drive the package P-state from the main workloop timer instead, using per-core retired-instruction rates (MSR PERF_IRPC, already collected every tick). The rate is frequency-independent, so governing works even while cores sit in a low P-state: any core > 0.3G inst/s -> P0 (instant) all cores < 0.1G inst/s for ~4s -> P2 (clamped by pstatelimit) otherwise -> P1 Respects the UserClient pstatelimit (LPM/PPM) and reuses applyPowerControl().
Owner
|
I need to hear your reasoning and review of the code. Not from AIs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The per-core idle accounting lives in
pmRyzen_machine_idle(), which only runs when the kernel's idle path routes through ourpmDispatchregistration. On some systems that never happens — on a Cezanne laptop (Lenovo Legion R7000P 2021, Ryzen 7 5800H) another kext owning the dispatch slot (CpuTscSync) leaves the machine-idle hook dead even when our kext registers last; changing kext load order does not help.When the accounting never runs,
set_PState()is never called and every core stays pinned at P0 (~24 W, ~90 °C at desktop idle), regardless ofPSTATE_LIMIT.Fix
Drive the package P-state from the main workloop timer instead, using the per-core retired-instruction rates that are already collected every tick (MSR
PERF_IRPCviaupdateInstructionDelta). The rate is frequency-independent — an idle core retires <0.1 G inst/s, a busy core >1 G inst/s — so governing works correctly even while cores are parked in a low P-state:getPMPStateLimit())Respects the existing
pstatelimit(LPM/PPM toggles) and reusesapplyPowerControl().Result (Ryzen 7 5800H, Legion R7000P 2021, Ventura 13.7.8, with CpuTscSync installed)
Desktop idle now drops to the firmware P2 state (1.2 GHz, ~9 W package power) and returns to P0 + boost instantly under load. Before this change the CPU was pinned at ~3.4 GHz / 24 W / 85–90 °C whenever the machine was on.
Note
Independent of the P-state-limit change in my other PR — this one makes down-clocking happen at all on systems where the idle hook is unavailable; both together give the full idle→boost range on Cezanne mobile.