Add CPU Scheduler Governors.

Add a new enumeration for cpu scheduler governors.
Adds a property to get the available governors as a map of
value to strings similar to how we expose GPU Power Profiles.
Adds another property to get and set the current governor which
is applied to all cpus when set.
This commit is contained in:
Jeremy Whiting 2024-06-05 15:26:30 -06:00
parent 71827ac7ee
commit 7f9d25074e
4 changed files with 223 additions and 4 deletions

View file

@ -20,8 +20,8 @@ use crate::daemon::DaemonCommand;
use crate::error::{to_zbus_error, to_zbus_fdo_error};
use crate::hardware::{variant, FanControl, FanControlState, HardwareVariant};
use crate::power::{
set_gpu_clocks, set_gpu_performance_level, set_gpu_power_profile, set_tdp_limit,
GPUPerformanceLevel, GPUPowerProfile,
set_cpu_governor, set_gpu_clocks, set_gpu_performance_level, set_gpu_power_profile,
set_tdp_limit, CPUGovernor, GPUPerformanceLevel, GPUPowerProfile,
};
use crate::process::{run_script, script_output, ProcessManager};
use crate::wifi::{
@ -191,6 +191,14 @@ impl SteamOSManager {
.map_err(to_zbus_fdo_error)
}
async fn set_cpu_governor(&self, governor: u32) -> fdo::Result<()> {
let governor = CPUGovernor::try_from(governor).map_err(to_zbus_fdo_error)?;
set_cpu_governor(governor)
.await
.inspect_err(|message| error!("Error setting CPU governor: {message}"))
.map_err(to_zbus_fdo_error)
}
async fn set_gpu_performance_level(&self, level: u32) -> fdo::Result<()> {
let level = match GPUPerformanceLevel::try_from(level) {
Ok(level) => level,