Skip to content

Conversation

@arighi
Copy link
Contributor

@arighi arighi commented May 28, 2025

CPU frequency scaling drivers, such as intel_pstate or amd_pstate, expose intermediate "balanced" performance scaling preferences: balance_power and balance_performance.

Expose them via `scx_utils::autopower, so that scx schedulers can use this information to apply more fine-grained performance / power-saving optimizations.

Adjust the behavior of scx_bpfland -m auto to use the new power modes balance_power and balance_performance.

@multics69 FYI, this includes a small change to scx_lavd as well to support the new PowerProfile::Balanced { power: true | false } states, which are both mapped to LAVD_PM_BALANCED, so there's no functional change.

@arighi arighi requested review from hodgesds, htejun and multics69 May 28, 2025 16:13
@arighi arighi force-pushed the bpfland-auto-power branch from 64f9553 to a790a6f Compare May 28, 2025 16:24
Copy link
Contributor

@hodgesds hodgesds left a comment

Choose a reason for hiding this comment

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

Seems legit

arighi added 2 commits May 30, 2025 12:29
Some CPU frequency scaling drivers, such as intel_pstate or amd_pstate,
expose intermediate performance scaling preferences: balance_power and
balance_performance.

These represent a spectrum between maximum power efficiency and peak
performance, offering more granular control than the traditional
performance or powersave modes.

Expose this information in the scx_utils crate, so that schedulers can
also apply more fine-grained performance or power-saving optimizations.

Signed-off-by: Andrea Righi <arighi@nvidia.com>
Use the following logic when running in auto mode (`-m auto`):

 +------------------------+----------------+
 | Current Power Profile  | Active Cores   |
 +------------------------+----------------+
 | powersave              | slow cores     |
 | balance_power          | slow cores     |
 | balance_performance    |  all cores     |
 | performance            |  all cores     |
 +------------------------+----------------+

With this logic, on battery-powered systems, the scheduler prioritizes
the slow cores when running on battery. When plugged into AC power, it
uses all cores more evenly.

If the CPU frequency scaling driver supports only a single "balanced"
mode, the scheduler operates as balance_performance, using all cores
equally.

Signed-off-by: Andrea Righi <arighi@nvidia.com>
@arighi arighi force-pushed the bpfland-auto-power branch from a790a6f to f18d94e Compare May 30, 2025 10:35
@arighi
Copy link
Contributor Author

arighi commented May 30, 2025

After discussing this with the CachyOS community, I decided to slightly change the logic to use all cores also with EPP=performance instead of prioritizing the fast cores.

Giving more context on this: auto mode should just try to save power when running on battery or when the powersave EPP is selected, otherwise it should just use all the cores evenly. Prioritizing the fast cores is not always the optimal choice in terms of performance and it can actually lead to sub-optimal performance, especially when the fast cores are slightly faster than the others (e.g., turbo boosted cores).

Therefore, it's preferable to let the user decide when to prioritize the fast cores by using -m performance. This gives -m performance a clearer meaning, which is not "go faster", but it's "maximize performance predictability on hybrid architectures". In fact, on such systems, favoring the fast cores and minimizing task migration between fast and slow cores can significantly enhance performance consistency. In non-hybrid systems, prioritizing the fast cores typically leads to worse performance due to a reduced work conservation.

Copy link
Contributor

@multics69 multics69 left a comment

Choose a reason for hiding this comment

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

LGTM

@arighi arighi added this pull request to the merge queue May 30, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 30, 2025
@arighi arighi added this pull request to the merge queue May 30, 2025
Merged via the queue into main with commit 08f6e97 May 30, 2025
32 checks passed
@arighi arighi deleted the bpfland-auto-power branch May 30, 2025 14:25
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.

4 participants