Conversation
Add plugin_scx.py — a new tuned plug-in that manages sched-ext schedulers via the scx_loader D-Bus service (org.scx.Loader).The plug-in exposes two configuration options: scheduler— name of the scx scheduler to activate (e.g. scx_bpfland, scx_lavd), or "none" to stop any running scheduler. mode — operating mode: auto, gaming, lowlatency, powersave, server. Scheduler state is saved and restored across profile switches using the standard tuned command_get/command_set framework.When scx_loader is not present the plug-in logs an informational message and does nothing. Signed-off-by: Peter Jung <admin@ptr1337.dev>
Signed-off-by: Peter Jung <admin@ptr1337.dev>
There was a problem hiding this comment.
Pull request overview
Adds a new TuneD plugin to control sched-ext (scx) schedulers through the scx_loader D-Bus service, plus commented profile snippets showing how to enable it in CachyOS profiles.
Changes:
- Introduce
tuned/plugins/plugin_scx.pyimplementing[scx]options (scheduler,mode) viaorg.scx.Loader. - Persist/restore scheduler state across profile switches using TuneD’s
command_get/command_setstorage mechanism. - Add commented
[scx]configuration examples to CachyOS desktop/gaming/laptop/powersave profiles.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tuned/plugins/plugin_scx.py | New plugin for selecting/stopping scx schedulers and managing scheduler mode via D-Bus. |
| profiles/cachyos-powersave/tuned.conf | Add commented [scx] example snippet for powersave mode. |
| profiles/cachyos-laptop/tuned.conf | Add commented [scx] example snippet for powersave mode. |
| profiles/cachyos-gaming/tuned.conf | Add commented [scx] example snippet for gaming mode. |
| profiles/cachyos-desktop/tuned.conf | Add commented [scx] example snippet for desktop/auto mode. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @command_set("mode") | ||
| def _set_mode(self, value, instance, sim, remove): | ||
| # Mode is applied together with the scheduler in _set_scheduler. | ||
| # This handler only validates the value. | ||
| if value is None: | ||
| return None | ||
| value = str(value).strip().lower() | ||
| if value not in MODE_MAP: | ||
| if not sim: | ||
| log.warning("scx: invalid mode '%s', expected one of: %s" | ||
| % (value, ", ".join(sorted(MODE_MAP.keys())))) | ||
| return None | ||
| return value | ||
|
|
There was a problem hiding this comment.
mode is registered as an independent @command_set/@command_get option, but _set_mode explicitly does not apply any tuning. This means profiles that set mode (with or without scheduler) will have the framework save/verify/restore a value that the plugin never enforces, leading to confusing behavior and potential verification failures. Either make mode a non-command auxiliary option (validated/used by _set_scheduler only) or implement mode changes by applying them through scx_loader (e.g., switching the currently running scheduler with the requested mode).
tuned/plugins/plugin_scx.py
Outdated
| mode_opt = instance.options.get("mode", "auto") | ||
| if mode_opt is None: | ||
| mode_opt = "auto" | ||
| mode_str = str(mode_opt).strip().lower() |
There was a problem hiding this comment.
_set_scheduler reads instance.options.get("mode") directly, so any TuneD variable expansion applied elsewhere (the base class expands per-option values) will not be applied to mode here. Other plugins expand dependent options explicitly (e.g., plugin_irq expands mode in _instance_init). Consider using self._variables.expand(...) when reading the mode option to keep behavior consistent.
| mode_str = str(mode_opt).strip().lower() | |
| mode_opt = self._variables.expand(str(mode_opt)) | |
| mode_str = mode_opt.strip().lower() |
| @command_get("scheduler") | ||
| def _get_scheduler(self, instance): | ||
| proxy, _ = _get_dbus_proxy() | ||
| if proxy is None: | ||
| return None | ||
| current = _get_property(proxy, "CurrentScheduler") |
There was a problem hiding this comment.
On systems without scx_loader, _get_scheduler/_get_mode return None, which causes tuned-adm verify (ignore_missing=false) to fail for profiles that set [scx] options, even though the plugin is intended to be a no-op when the service is absent. Consider overriding _instance_verify_static to treat missing scx_loader as ignore_missing=True (or short-circuit verification to True) when the D-Bus proxy cannot be obtained, similar to plugins that hardcode ignore_missing for optional facilities.
Signed-off-by: Peter Jung <admin@ptr1337.dev>
Add a new scaling_min_freq option to the cpu plugin that accepts either a direct Hz value or a sysfs sibling filename (e.g. cpuinfo_min_freq, amd_pstate_lowest_nonlinear_freq). In the latter case the plugin reads the numeric value from that file and writes it to scaling_min_freq, exactly mirroring what power-profiles-daemon does in its AMD P-State driver. Wire it up in the four CachyOS PPD-mapped profiles: - cachyos-powersave→ cpuinfo_min_freq (absolute minimum, max savings) - cachyos-desktop→ amd_pstate_lowest_nonlinear_freq (balanced floor) - cachyos-laptop → amd_pstate_lowest_nonlinear_freq (balanced floor) - cachyos-gaming → amd_pstate_lowest_nonlinear_freq (perf floor) On systems where the source file does not exist (Intel, AMD without amd-pstate active mode) the option is silently skipped. The rollback path correctly restores the original numeric value saved at apply time. Signed-off-by: Peter Jung <admin@ptr1337.dev>
Add plugin_scx.py — a new tuned plug-in that manages sched-ext schedulers
via the scx_loader D-Bus service (org.scx.Loader).The plug-in exposes
two configuration options:
scheduler— name of the scx scheduler to activate (e.g. scx_bpfland, scx_lavd), or "none" to stop any running scheduler.
mode — operating mode: auto, gaming, lowlatency, powersave, server.
Scheduler state is saved and restored across profile switches using the
standard tuned command_get/command_set framework.When scx_loader is not
present the plug-in logs an informational message and does nothing.
Signed-off-by: Peter Jung admin@ptr1337.dev