Add global governor dropdown (hidden for default SD config)
This commit is contained in:
parent
286ad30378
commit
e63310f62e
11 changed files with 67 additions and 18 deletions
2
backend/Cargo.lock
generated
2
backend/Cargo.lock
generated
|
@ -826,7 +826,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "powertools-rs"
|
name = "powertools-rs"
|
||||||
version = "1.1.0-beta5"
|
version = "1.1.0-beta6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"limits_core",
|
"limits_core",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "powertools-rs"
|
name = "powertools-rs"
|
||||||
version = "1.1.0-beta5"
|
version = "1.1.0-beta6"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
|
authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
|
||||||
description = "Backend (superuser) functionality for PowerTools"
|
description = "Backend (superuser) functionality for PowerTools"
|
||||||
|
|
|
@ -33,6 +33,7 @@ pub struct CpusLimits {
|
||||||
pub cpus: Vec<CpuLimits>,
|
pub cpus: Vec<CpuLimits>,
|
||||||
pub count: usize,
|
pub count: usize,
|
||||||
pub smt_capable: bool,
|
pub smt_capable: bool,
|
||||||
|
pub governors: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
|
|
|
@ -134,6 +134,7 @@ impl<C: AsMut<Cpu> + AsRef<Cpu> + TCpu + OnResume + OnSet> TCpus for Cpus<C> {
|
||||||
cpus: self.cpus.iter().map(|x| x.as_ref().limits()).collect(),
|
cpus: self.cpus.iter().map(|x| x.as_ref().limits()).collect(),
|
||||||
count: self.cpus.len(),
|
count: self.cpus.len(),
|
||||||
smt_capable: self.smt_capable,
|
smt_capable: self.smt_capable,
|
||||||
|
governors: Vec::with_capacity(0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,12 @@ impl TCpus for Cpus {
|
||||||
cpus: self.cpus.iter().map(|x| x.limits()).collect(),
|
cpus: self.cpus.iter().map(|x| x.limits()).collect(),
|
||||||
count: self.cpus.len(),
|
count: self.cpus.len(),
|
||||||
smt_capable: self.smt_capable,
|
smt_capable: self.smt_capable,
|
||||||
|
governors: if self.limits.global_governors {
|
||||||
|
self.cpus.iter()
|
||||||
|
.next()
|
||||||
|
.map(|x| x.governors())
|
||||||
|
.unwrap_or_else(|| Vec::with_capacity(0))
|
||||||
|
} else { Vec::with_capacity(0) },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,7 +364,7 @@ impl Cpu {
|
||||||
min: self.limits.clock_max.min,
|
min: self.limits.clock_max.min,
|
||||||
max: self.limits.clock_max.max
|
max: self.limits.clock_max.max
|
||||||
}),
|
}),
|
||||||
clock_step: 100,
|
clock_step: self.limits.clock_step,
|
||||||
governors: self.governors(),
|
governors: self.governors(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,20 +222,18 @@ impl OnResume for Gpu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const PPT_DIVISOR: u64 = 1_000_000;
|
|
||||||
|
|
||||||
impl TGpu for Gpu {
|
impl TGpu for Gpu {
|
||||||
fn limits(&self) -> crate::api::GpuLimits {
|
fn limits(&self) -> crate::api::GpuLimits {
|
||||||
crate::api::GpuLimits {
|
crate::api::GpuLimits {
|
||||||
fast_ppt_limits: Some(RangeLimit {
|
fast_ppt_limits: Some(RangeLimit {
|
||||||
min: self.limits.fast_ppt.min / PPT_DIVISOR,
|
min: self.limits.fast_ppt.min / self.limits.ppt_divisor,
|
||||||
max: self.limits.fast_ppt.max / PPT_DIVISOR,
|
max: self.limits.fast_ppt.max / self.limits.ppt_divisor,
|
||||||
}),
|
}),
|
||||||
slow_ppt_limits: Some(RangeLimit {
|
slow_ppt_limits: Some(RangeLimit {
|
||||||
min: self.limits.slow_ppt.min / PPT_DIVISOR,
|
min: self.limits.slow_ppt.min / self.limits.ppt_divisor,
|
||||||
max: self.limits.slow_ppt.max / PPT_DIVISOR,
|
max: self.limits.slow_ppt.max / self.limits.ppt_divisor,
|
||||||
}),
|
}),
|
||||||
ppt_step: 1,
|
ppt_step: self.limits.ppt_step,
|
||||||
tdp_limits: None,
|
tdp_limits: None,
|
||||||
tdp_boost_limits: None,
|
tdp_boost_limits: None,
|
||||||
tdp_step: 42,
|
tdp_step: 42,
|
||||||
|
@ -247,7 +245,7 @@ impl TGpu for Gpu {
|
||||||
min: self.limits.clock_max.min,
|
min: self.limits.clock_max.min,
|
||||||
max: self.limits.clock_max.max,
|
max: self.limits.clock_max.max,
|
||||||
}),
|
}),
|
||||||
clock_step: 100,
|
clock_step: self.limits.clock_step,
|
||||||
memory_control_capable: true,
|
memory_control_capable: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,12 +255,12 @@ impl TGpu for Gpu {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ppt(&mut self, fast: Option<u64>, slow: Option<u64>) {
|
fn ppt(&mut self, fast: Option<u64>, slow: Option<u64>) {
|
||||||
self.fast_ppt = fast.map(|x| x * PPT_DIVISOR);
|
self.fast_ppt = fast.map(|x| x * self.limits.ppt_divisor);
|
||||||
self.slow_ppt = slow.map(|x| x * PPT_DIVISOR);
|
self.slow_ppt = slow.map(|x| x * self.limits.ppt_divisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_ppt(&self) -> (Option<u64>, Option<u64>) {
|
fn get_ppt(&self) -> (Option<u64>, Option<u64>) {
|
||||||
(self.fast_ppt.map(|x| x / PPT_DIVISOR), self.slow_ppt.map(|x| x / PPT_DIVISOR))
|
(self.fast_ppt.map(|x| x / self.limits.ppt_divisor), self.slow_ppt.map(|x| x / self.limits.ppt_divisor))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clock_limits(&mut self, limits: Option<MinMax<u64>>) {
|
fn clock_limits(&mut self, limits: Option<MinMax<u64>>) {
|
||||||
|
|
|
@ -66,12 +66,14 @@ impl Default for BatteryLimits {
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
pub(super) struct CpusLimits {
|
pub(super) struct CpusLimits {
|
||||||
pub cpus: Vec<CpuLimits>,
|
pub cpus: Vec<CpuLimits>,
|
||||||
|
pub global_governors: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for CpusLimits {
|
impl Default for CpusLimits {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
cpus: [(); 8].iter().map(|_| CpuLimits::default()).collect()
|
cpus: [(); 8].iter().map(|_| CpuLimits::default()).collect(),
|
||||||
|
global_governors: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,13 +82,15 @@ impl Default for CpusLimits {
|
||||||
pub(super) struct CpuLimits {
|
pub(super) struct CpuLimits {
|
||||||
pub clock_min: MinMax<u64>,
|
pub clock_min: MinMax<u64>,
|
||||||
pub clock_max: MinMax<u64>,
|
pub clock_max: MinMax<u64>,
|
||||||
|
pub clock_step: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for CpuLimits {
|
impl Default for CpuLimits {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
clock_min: MinMax { min: 1400, max: 3500 },
|
clock_min: MinMax { min: 1400, max: 3500 },
|
||||||
clock_max: MinMax { min: 400, max: 3500 }
|
clock_max: MinMax { min: 400, max: 3500 },
|
||||||
|
clock_step: 100,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,8 +99,11 @@ impl Default for CpuLimits {
|
||||||
pub(super) struct GpuLimits {
|
pub(super) struct GpuLimits {
|
||||||
pub fast_ppt: MinMax<u64>,
|
pub fast_ppt: MinMax<u64>,
|
||||||
pub slow_ppt: MinMax<u64>,
|
pub slow_ppt: MinMax<u64>,
|
||||||
|
pub ppt_divisor: u64,
|
||||||
|
pub ppt_step: u64,
|
||||||
pub clock_min: MinMax<u64>,
|
pub clock_min: MinMax<u64>,
|
||||||
pub clock_max: MinMax<u64>,
|
pub clock_max: MinMax<u64>,
|
||||||
|
pub clock_step: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for GpuLimits {
|
impl Default for GpuLimits {
|
||||||
|
@ -104,8 +111,11 @@ impl Default for GpuLimits {
|
||||||
Self {
|
Self {
|
||||||
fast_ppt: MinMax { min: 1000000, max: 30_000_000 },
|
fast_ppt: MinMax { min: 1000000, max: 30_000_000 },
|
||||||
slow_ppt: MinMax { min: 1000000, max: 29_000_000 },
|
slow_ppt: MinMax { min: 1000000, max: 29_000_000 },
|
||||||
|
ppt_divisor: 1_000_000,
|
||||||
|
ppt_step: 1,
|
||||||
clock_min: MinMax { min: 200, max: 1600 },
|
clock_min: MinMax { min: 200, max: 1600 },
|
||||||
clock_max: MinMax { min: 200, max: 1600 }
|
clock_max: MinMax { min: 200, max: 1600 },
|
||||||
|
clock_step: 100,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,6 +138,7 @@ impl TCpus for Cpus {
|
||||||
cpus: self.cpus.iter().map(|x| x.limits()).collect(),
|
cpus: self.cpus.iter().map(|x| x.limits()).collect(),
|
||||||
count: self.cpus.len(),
|
count: self.cpus.len(),
|
||||||
smt_capable: self.smt_capable,
|
smt_capable: self.smt_capable,
|
||||||
|
governors: Vec::with_capacity(0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "PowerTools",
|
"name": "PowerTools",
|
||||||
"version": "1.1.0-beta5",
|
"version": "1.1.0-beta6",
|
||||||
"description": "Power tweaks for power users",
|
"description": "Power tweaks for power users",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "shx rm -rf dist && rollup -c",
|
"build": "shx rm -rf dist && rollup -c",
|
||||||
|
|
|
@ -72,6 +72,7 @@ export type CpusLimits = {
|
||||||
cpus: CpuLimits[];
|
cpus: CpuLimits[];
|
||||||
count: number;
|
count: number;
|
||||||
smt_capable: boolean;
|
smt_capable: boolean;
|
||||||
|
governors: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type GeneralLimits = {};
|
export type GeneralLimits = {};
|
||||||
|
|
|
@ -54,6 +54,11 @@ export class Cpus extends Component<{}, CpuState> {
|
||||||
label: <span>{elem}</span>,
|
label: <span>{elem}</span>,
|
||||||
};});
|
};});
|
||||||
|
|
||||||
|
const governorGlobalOptions: SingleDropdownOption[] = (get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.governors.map((elem) => {return {
|
||||||
|
data: elem,
|
||||||
|
label: <span>{elem}</span>,
|
||||||
|
};});
|
||||||
|
|
||||||
return (<Fragment>
|
return (<Fragment>
|
||||||
{/* CPU */}
|
{/* CPU */}
|
||||||
<div className={staticClasses.PanelSectionTitle}>
|
<div className={staticClasses.PanelSectionTitle}>
|
||||||
|
@ -215,6 +220,32 @@ export class Cpus extends Component<{}, CpuState> {
|
||||||
}}
|
}}
|
||||||
/>}
|
/>}
|
||||||
</PanelSectionRow>}
|
</PanelSectionRow>}
|
||||||
|
{!advancedMode && governorGlobalOptions.length != 0 && <PanelSectionRow>
|
||||||
|
<Field
|
||||||
|
label={tr("Governor")}
|
||||||
|
>
|
||||||
|
<Dropdown
|
||||||
|
menuLabel={tr("Governor")}
|
||||||
|
rgOptions={governorGlobalOptions}
|
||||||
|
selectedOption={governorGlobalOptions.find((val: SingleDropdownOption, _index, _arr) => {
|
||||||
|
backend.log(backend.LogLevel.Debug, "POWERTOOLS: array item " + val.toString());
|
||||||
|
backend.log(backend.LogLevel.Debug, "POWERTOOLS: looking for data " + get_value(GOVERNOR_CPU)[0].toString());
|
||||||
|
return val.data == get_value(GOVERNOR_CPU)[0];
|
||||||
|
})}
|
||||||
|
strDefaultLabel={get_value(GOVERNOR_CPU)[0]}
|
||||||
|
onChange={(elem: SingleDropdownOption) => {
|
||||||
|
backend.log(backend.LogLevel.Debug, "Governor global dropdown selected " + elem.data.toString());
|
||||||
|
const governors = get_value(GOVERNOR_CPU);
|
||||||
|
for (let i = 0; i < total_cpus; i++) {
|
||||||
|
governors[i] = elem.data as string;
|
||||||
|
backend.resolve(backend.setCpuGovernor(i, elem.data as string), (_: string) => {});
|
||||||
|
}
|
||||||
|
set_value(GOVERNOR_CPU, governors);
|
||||||
|
reloadGUI("CPUGlobalGovernor");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
</PanelSectionRow>}
|
||||||
{/* CPU advanced mode */}
|
{/* CPU advanced mode */}
|
||||||
{advancedMode && <PanelSectionRow>
|
{advancedMode && <PanelSectionRow>
|
||||||
<SliderField
|
<SliderField
|
||||||
|
|
Loading…
Reference in a new issue