Skip to content

scx_lavd: make --no-use-em reach the userspace CPU-order builder#3644

Merged
multics69 merged 2 commits into
sched-ext:mainfrom
kurtislin:lavd/no-use-em-plumbing
Jun 17, 2026
Merged

scx_lavd: make --no-use-em reach the userspace CPU-order builder#3644
multics69 merged 2 commits into
sched-ext:mainfrom
kurtislin:lavd/no-use-em-plumbing

Conversation

@kurtislin

Copy link
Copy Markdown
Contributor

Problem

--no-use-em 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
never reaches CpuOrder::new(). The userspace EnergyModelOptimizer always
runs 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-em does not avoid the blow-up
("Tested scx_lavd --performance --no-use-em ... It still reproduces").

Fix

Plumb the (already normalized) flag into CpuOrderCtx and skip
EnergyModel construction when set, so every downstream consumer (optimizer
table, pd_adx assignment, has_energy_model) takes the exact same path as
on a machine without an energy model. That is also the only PCO table layout
the BPF side expects when no_use_em is set: its 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, 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.

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 multics69 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @kurtislin , for the patch! Looks good to me.

@multics69 multics69 added this pull request to the merge queue Jun 17, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 17, 2026
@multics69 multics69 enabled auto-merge June 17, 2026 08:59
@multics69 multics69 added this pull request to the merge queue Jun 17, 2026
Merged via the queue into sched-ext:main with commit f5e46f7 Jun 17, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants