scx_loader: add scx_flash as supported scheduler

This commit is contained in:
Vladislav Nepogodin 2024-11-19 20:58:56 +04:00
parent 489ce8a766
commit d5d4f463f9
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
3 changed files with 27 additions and 3 deletions

View File

@ -36,12 +36,18 @@ auto_mode = []
gaming_mode = ["--performance"] gaming_mode = ["--performance"]
lowlatency_mode = ["--performance"] lowlatency_mode = ["--performance"]
powersave_mode = ["--powersave"] powersave_mode = ["--powersave"]
[scheds.scx_flash]
auto_mode = []
gaming_mode = []
lowlatency_mode = []
powersave_mode = []
``` ```
**`default_sched`:** **`default_sched`:**
* This field specifies the scheduler that will be started automatically when `scx_loader` starts (e.g., on boot). * This field specifies the scheduler that will be started automatically when `scx_loader` starts (e.g., on boot).
* It should be set to the name of a supported scheduler (e.g., `"scx_bpfland"`, `"scx_rusty"`, `"scx_lavd"`). * It should be set to the name of a supported scheduler (e.g., `"scx_bpfland"`, `"scx_rusty"`, `"scx_lavd"`, `"scx_flash"`).
* If this field is not present or is set to an empty string, no scheduler will be started automatically. * If this field is not present or is set to an empty string, no scheduler will be started automatically.
**`default_mode`:** **`default_mode`:**
@ -52,7 +58,7 @@ powersave_mode = ["--powersave"]
**`[scheds.scx_name]`:** **`[scheds.scx_name]`:**
* This section defines the custom flags for a specific scheduler. Replace `scx_name` with the actual name of the scheduler (e.g., `scx_bpfland`, `scx_rusty`, `scx_lavd`). * This section defines the custom flags for a specific scheduler. Replace `scx_name` with the actual name of the scheduler (e.g., `scx_bpfland`, `scx_rusty`, `scx_lavd`, `scx_flash`).
**`auto_mode`, `gaming_mode`, `lowlatency_mode`, `powersave_mode`:** **`auto_mode`, `gaming_mode`, `lowlatency_mode`, `powersave_mode`:**
@ -74,6 +80,8 @@ The example configuration above shows how to set custom flags for different sche
* Gaming mode: `--performance` * Gaming mode: `--performance`
* Low Latency mode: `--performance` * Low Latency mode: `--performance`
* Power Save mode: `--powersave` * Power Save mode: `--powersave`
* For `scx_flash`:
* No custom flags are defined, so the default flags for each mode will be used.
## Fallback Behavior ## Fallback Behavior

View File

@ -88,6 +88,10 @@ pub fn get_default_config() -> Config {
"scx_lavd".to_string(), "scx_lavd".to_string(),
get_default_sched_for_config(&SupportedSched::Lavd), get_default_sched_for_config(&SupportedSched::Lavd),
), ),
(
"scx_flash".to_string(),
get_default_sched_for_config(&SupportedSched::Flash),
),
]), ]),
} }
} }
@ -176,6 +180,8 @@ fn get_default_scx_flags_for_mode(scx_sched: &SupportedSched, sched_mode: SchedM
}, },
// scx_rusty doesn't support any of these modes // scx_rusty doesn't support any of these modes
SupportedSched::Rusty => vec![], SupportedSched::Rusty => vec![],
// scx_flash doesn't support any of these modes
SupportedSched::Flash => vec![],
} }
} }
@ -205,6 +211,12 @@ auto_mode = []
gaming_mode = ["--performance"] gaming_mode = ["--performance"]
lowlatency_mode = ["--performance"] lowlatency_mode = ["--performance"]
powersave_mode = ["--powersave"] powersave_mode = ["--powersave"]
[scheds.scx_flash]
auto_mode = []
gaming_mode = []
lowlatency_mode = []
powersave_mode = []
"#; "#;
let parsed_config = parse_config_content(config_str).expect("Failed to parse config"); let parsed_config = parse_config_content(config_str).expect("Failed to parse config");

View File

@ -39,6 +39,8 @@ enum SupportedSched {
Rusty, Rusty,
#[serde(rename = "scx_lavd")] #[serde(rename = "scx_lavd")]
Lavd, Lavd,
#[serde(rename = "scx_flash")]
Flash,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
@ -114,7 +116,7 @@ impl ScxLoader {
/// Get list of supported schedulers /// Get list of supported schedulers
#[zbus(property)] #[zbus(property)]
async fn supported_schedulers(&self) -> Vec<&str> { async fn supported_schedulers(&self) -> Vec<&str> {
vec!["scx_bpfland", "scx_rusty", "scx_lavd"] vec!["scx_bpfland", "scx_rusty", "scx_lavd", "scx_flash"]
} }
async fn start_scheduler( async fn start_scheduler(
@ -546,6 +548,7 @@ fn get_scx_from_str(scx_name: &str) -> zbus::fdo::Result<SupportedSched> {
"scx_bpfland" => Ok(SupportedSched::Bpfland), "scx_bpfland" => Ok(SupportedSched::Bpfland),
"scx_rusty" => Ok(SupportedSched::Rusty), "scx_rusty" => Ok(SupportedSched::Rusty),
"scx_lavd" => Ok(SupportedSched::Lavd), "scx_lavd" => Ok(SupportedSched::Lavd),
"scx_flash" => Ok(SupportedSched::Flash),
_ => Err(zbus::fdo::Error::Failed(format!( _ => Err(zbus::fdo::Error::Failed(format!(
"{scx_name} is not supported" "{scx_name} is not supported"
))), ))),
@ -558,5 +561,6 @@ fn get_name_from_scx(supported_sched: &SupportedSched) -> &'static str {
SupportedSched::Bpfland => "scx_bpfland", SupportedSched::Bpfland => "scx_bpfland",
SupportedSched::Rusty => "scx_rusty", SupportedSched::Rusty => "scx_rusty",
SupportedSched::Lavd => "scx_lavd", SupportedSched::Lavd => "scx_lavd",
SupportedSched::Flash => "scx_flash",
} }
} }