uncore: Allow to configure uncore ELC control #796
As per comments in https://github.com/redhat-performance/tuned/pull/731
updated pull request.
Thanks @jmencak and @yarda for the code suggestions.
Thank you @spandruvada for addressing the issues in https://github.com/redhat-performance/tuned/pull/731, I guess we can close it now.
@yarda , do we want to include this in the next FDP? Thanks.
LGTM
If I am not missing anything, the _get_all() method returns tuple with 8 values, but here you are assigning only five.
Requested changes.
The CentOS 7 CI failure is unrelated.
Fixed the issue pointed by @yarda . Thanks for review.
/packit build
@coderabbitai full review
<!-- This is an auto-generated reply by CodeRabbit -->
<!-- CodeRabbit review command invocation: de363d02-354f-4e4b-9952-08aa0817035b -->
<details>
<summary>✅ Action performed</summary>
Full review finished.
</details>
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->

<!-- review_stack_entry_end -->
<!-- walkthrough_start -->
<details>
<summary>📝 Walkthrough</summary>
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
New Features
Added support for configuring ELC floor frequency.
Added options for ELC high- and low-threshold percentages.
Added the ability to enable or disable the ELC high-threshold state.
Added support for reading and applying these ELC settings through device commands.
Documentation
* Added documentation describing the new ELC configuration options.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Walkthrough
The uncore plugin now documents ELC controls, collects their sysfs values, registers configuration options, and provides handlers for reading and setting floor frequency, threshold percentages, and high-threshold enable state.
Changes
Uncore ELC controls
|Layer / File(s)|Summary|
|---|---|
|ELC values and configuration <br> tuned/plugins/plugin_uncore.py|The plugin documents four ELC options, collects their sysfs values, registers configuration options, and updates frequency and percentage tuple validation.|
|ELC floor frequency handlers <br> tuned/plugins/plugin_uncore.py|The plugin adds getter and setter handlers for ELC floor frequency with validation, simulation handling, sysfs error handling, and logging.|
|ELC threshold handlers <br> tuned/plugins/plugin_uncore.py|The plugin adds getter and setter handlers for high and low threshold percentages and high-threshold enable state. The handlers validate values and handle simulation, sysfs errors, and logging.|
Estimated code review effort: 3 (Moderate) | ~20 minutes
</details>
<!-- walkthrough_end -->
<!-- pre_merge_checks_walkthrough_start -->
<details>
<summary>🚥 Pre-merge checks | ✅ 5</summary>
<details>
<summary>✅ Passed checks (5 passed)</summary>
| Check name | Status | Explanation |
| :------------------------: | :------- | :------------------------------------------------------------------------------------------------------------- |
| Title check | ✅ Passed | The title clearly identifies the main change: configurable uncore ELC control. |
| Description check | ✅ Passed | The description explains the ELC configuration changes and provides a relevant example and documentation link. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
</details>
</details>
<!-- pre_merge_checks_walkthrough_end -->
<!-- finishing_touch_checkbox_start -->
<details>
<summary>✨ Finishing Touches 💡 1</summary>
<!-- finishing_touch_suggestion:fix_ci -->
<details open>
<summary>🛠️ Fix failing CI checks 💡</summary>
</details>
</details>
<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->
---
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
<details>
<summary>❤️ Share</summary>
</details>
<sub>Comment @coderabbitai help to get the list of available commands.</sub>
<!-- tips_end -->
_🎯 Functional Correctness_ | _🟠 Major_ | _⚡ Quick win_
Preserve existing frequency controls when ELC files are absent.
Lines 102-105 make _get_all require all ELC sysfs files. If a system supports max_freq_khz and min_freq_khz but does not expose ELC, _get_all returns None. _validate_khz_value then rejects existing max/min configuration before it writes either file.
Treat unavailable ELC values as optional, or read ELC values only from ELC handlers.
<details>
<summary>Proposed direction</summary>
- elc_floor_freq_khz = self._get(device, "elc_floor_freq_khz")
- elc_high_threshold_enable = self._get(device, "elc_high_threshold_enable")
- elc_high_threshold_percent = self._get(device, "elc_high_threshold_percent")
- elc_low_threshold_percent = self._get(device, "elc_low_threshold_percent")
+ # Keep `_get_all` limited to values required by max/min validation.
Move ELC reads into their respective getters or a separate optional ELC-value helper.
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tuned/plugins/plugin_uncore.py` around lines 102 - 112, Update _get_all so
missing ELC sysfs files do not cause the entire frequency-value read to return
None. Keep max_freq_khz and min_freq_khz retrieval and validation independent,
and obtain elc_floor_freq_khz, elc_high_threshold_enable,
elc_high_threshold_percent, and elc_low_threshold_percent through optional
ELC-specific getters or a separate helper that tolerates unavailable files.
</details>
<!-- fingerprinting:phantom:poseidon:tapir -->
<!-- cr-indicator-types:potential_issue -->
<!-- cr-comment:v1:5cb79ad1accae80e8c027be1 -->
<!-- This is an auto-generated comment by CodeRabbit -->
Actionable comments posted: 1
<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tuned/plugins/plugin_uncore.py`:
- Around line 102-112: Update _get_all so missing ELC sysfs files do not cause
the entire frequency-value read to return None. Keep max_freq_khz and
min_freq_khz retrieval and validation independent, and obtain
elc_floor_freq_khz, elc_high_threshold_enable, elc_high_threshold_percent, and
elc_low_threshold_percent through optional ELC-specific getters or a separate
helper that tolerates unavailable files.
</details>
<details>
<summary>🪄 Autofix</summary>
Fix all unresolved CodeRabbit comments on this PR:
</details>
---
<details>
<summary>ℹ️ Review info</summary>
<details>
<summary>⚙️ Run configuration</summary>
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e82f4e71-151d-4d9a-9791-9bb10ef7b130
</details>
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between c07833ba62c9d0707fb9d3b60a87719801047be0 and a4f0364f4c09ebb85d60ce56b9c78265ae39b5e1.
</details>
<details>
<summary>📒 Files selected for processing (1)</summary>
tuned/plugins/plugin_uncore.py</details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
IMHO this can happen that the basic uncore knobs exist but the ELC ones don't, @spandruvada can you please address it? Otherwise LGTM.
yarda
spandruvada
The Efficiency Latency Control (ELC) feature improves performance per watt. With this feature hardware power management algorithms optimize trade-off between latency and power consumption.
Add additional configuration for uncore plugin to include attributes to configure ELC.
Refer to Intel White Paper
Link:
Linux kernel documentation:
https://docs.kernel.org/admin-guide/pm/intel_uncore_frequency_scaling.html
Example configuration:
[uncore_all]
type=uncore
elc_floor_freq_khz=2400000
elc_high_threshold_enable=1
elc_high_threshold_percent=95
elc_low_threshold_percent=10