From 5fe4e9d15d201294c9bd599de3fe33668e2f7b02 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Sat, 24 Dec 2022 10:21:27 -0500 Subject: [PATCH] Complete switch to linux kernel SMT toggle #48 --- backend/limits_srv/src/main.rs | 4 ++-- backend/src/api/handler.rs | 1 + backend/src/settings/generic/cpu.rs | 4 ++++ backend/src/settings/steam_deck/cpu.rs | 4 ++++ backend/src/settings/steam_deck_adv/cpu.rs | 4 ++++ backend/src/settings/traits.rs | 2 ++ backend/src/settings/unknown/cpu.rs | 4 ++++ main.py | 2 +- 8 files changed, 22 insertions(+), 3 deletions(-) diff --git a/backend/limits_srv/src/main.rs b/backend/limits_srv/src/main.rs index 7f423f3..d0054ce 100644 --- a/backend/limits_srv/src/main.rs +++ b/backend/limits_srv/src/main.rs @@ -9,13 +9,13 @@ static VISIT_COUNT: AtomicU64 = AtomicU64::new(0); fn get_limits(base: Base) -> impl warp::Reply { VISIT_COUNT.fetch_add(1, Ordering::AcqRel); - //println!("Count: {} + 1", old_count); + println!("Limits got"); warp::reply::json(&base) } fn get_visits() -> impl warp::Reply { let count = VISIT_COUNT.load(Ordering::Relaxed); - //println!("Count: {}", count); + println!("Count got"); warp::reply::json(&count) } diff --git a/backend/src/api/handler.rs b/backend/src/api/handler.rs index bf31495..cd77ed3 100644 --- a/backend/src/api/handler.rs +++ b/backend/src/api/handler.rs @@ -67,6 +67,7 @@ impl CpuMessage { } }, Self::SetSmt(status, cb) => { + *settings.smt() = status; let mut result = Vec::with_capacity(settings.len()); for i in 0..settings.len() { *settings.cpus()[i].online() = *settings.cpus()[i].online() && (status || i % 2 == 0); diff --git a/backend/src/settings/generic/cpu.rs b/backend/src/settings/generic/cpu.rs index df5a6d4..568b40f 100644 --- a/backend/src/settings/generic/cpu.rs +++ b/backend/src/settings/generic/cpu.rs @@ -188,6 +188,10 @@ impl TCpus for Cpus { self.cpus.len() } + fn smt(&mut self) -> &'_ mut bool { + &mut self.smt + } + fn provider(&self) -> crate::persist::DriverJson { crate::persist::DriverJson::Generic } diff --git a/backend/src/settings/steam_deck/cpu.rs b/backend/src/settings/steam_deck/cpu.rs index 8f02867..35f498b 100644 --- a/backend/src/settings/steam_deck/cpu.rs +++ b/backend/src/settings/steam_deck/cpu.rs @@ -152,6 +152,10 @@ impl TCpus for Cpus { self.cpus.len() } + fn smt(&mut self) -> &'_ mut bool { + &mut self.smt + } + fn provider(&self) -> crate::persist::DriverJson { crate::persist::DriverJson::SteamDeck } diff --git a/backend/src/settings/steam_deck_adv/cpu.rs b/backend/src/settings/steam_deck_adv/cpu.rs index 2b13c23..50e4f49 100644 --- a/backend/src/settings/steam_deck_adv/cpu.rs +++ b/backend/src/settings/steam_deck_adv/cpu.rs @@ -152,6 +152,10 @@ impl TCpus for Cpus { self.cpus.len() } + fn smt(&mut self) -> &'_ mut bool { + &mut self.smt + } + fn provider(&self) -> crate::persist::DriverJson { crate::persist::DriverJson::SteamDeckAdvance } diff --git a/backend/src/settings/traits.rs b/backend/src/settings/traits.rs index 219cc95..c2f70bf 100644 --- a/backend/src/settings/traits.rs +++ b/backend/src/settings/traits.rs @@ -44,6 +44,8 @@ pub trait TCpus: OnResume + OnSet + Debug + Send { fn len(&self) -> usize; + fn smt(&mut self) -> &'_ mut bool; + fn provider(&self) -> crate::persist::DriverJson { crate::persist::DriverJson::AutoDetect } diff --git a/backend/src/settings/unknown/cpu.rs b/backend/src/settings/unknown/cpu.rs index d4c183a..2e677ba 100644 --- a/backend/src/settings/unknown/cpu.rs +++ b/backend/src/settings/unknown/cpu.rs @@ -151,6 +151,10 @@ impl TCpus for Cpus { self.cpus.len() } + fn smt(&mut self) -> &'_ mut bool { + &mut self.smt + } + fn provider(&self) -> crate::persist::DriverJson { crate::persist::DriverJson::Unknown } diff --git a/main.py b/main.py index 6c1ab39..3e7acb9 100644 --- a/main.py +++ b/main.py @@ -11,6 +11,6 @@ class Plugin: # Asyncio-compatible long-running code, executed in a task when the plugin is loaded async def _main(self): # startup - #self.backend_proc = subprocess.Popen([PARENT_DIR + "/bin/backend"]) + self.backend_proc = subprocess.Popen([PARENT_DIR + "/bin/backend"]) while True: await asyncio.sleep(1)