scx_lavd: make --no-use-em reach the userspace CPU-order builder#3644
Merged
Conversation
The --no-use-em flag is documented as "Do not use the energy model in making CPU preference order decisions", but the flag is only written to BPF rodata and is never passed to CpuOrder::new(). The userspace EnergyModelOptimizer therefore always runs when the kernel exposes an energy model, regardless of the flag. This leaves the users hit by issue sched-ext#3340 without a mitigation: the energy-model table generation enumerates 2^n performance-domain subsets -- one PD per CPU on the affected machines, e.g. ~34GB peak memory on a 24-CPU Intel Core Ultra 9 275HX -- and users there report that --no-use-em does not avoid the blow-up. Plumb the (already normalized) flag into CpuOrderCtx and skip EnergyModel construction when it is set, so every downstream consumer (the optimizer table, pd_adx assignment, has_energy_model) takes the exact same path as on a machine without an energy model. This is also the only PCO table layout the BPF side expects when no_use_em is set: its no_use_em branches assume the two-state fallback table, while the loader previously kept feeding it the EM-derived one. Also print the "Energy model won't be used" message whenever no_use_em is in effect, not only when it is implied, so users can confirm the flag took effect. Signed-off-by: Kurtis Lin <klaus.lin.sc@gmail.com>
multics69
approved these changes
Jun 17, 2026
multics69
left a comment
Contributor
There was a problem hiding this comment.
Thank you, @kurtislin , for the patch! Looks good to me.
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
--no-use-emis documented as "Do not use the energy model in making CPUpreference order decisions", but the flag is only written to BPF rodata and
never reaches
CpuOrder::new(). The userspaceEnergyModelOptimizeralwaysruns when the kernel exposes an energy model, regardless of the flag.
This matters for #3340: the EM table generation enumerates 2^n
performance-domain subsets (one PD per CPU on the affected Intel HX hybrids,
e.g. ~34GB peak memory on a 24-CPU Core Ultra 9 275HX), and users in that
thread report
--no-use-emdoes not avoid the blow-up("Tested scx_lavd --performance --no-use-em ... It still reproduces").
Fix
Plumb the (already normalized) flag into
CpuOrderCtxand skipEnergyModelconstruction when set, so every downstream consumer (optimizertable,
pd_adxassignment,has_energy_model) takes the exact same path ason a machine without an energy model. That is also the only PCO table layout
the BPF side expects when
no_use_emis set: its branches assume thetwo-state fallback table, while the loader previously kept feeding it the
EM-derived one.
Also print the "Energy model won't be used" message whenever
no_use_emisin effect, so users can confirm the flag took effect.
Scope
This restores the documented bypass and gives #3340 users an immediate
mitigation. It is not the root fix for the 2^n enumeration itself — that is
addressed by the algorithmic rewrite in #3548.