Skip to content

fix(cpu): don't panic when SMT cannot be enabled - #38

Open
6jrx wants to merge 1 commit into
ShadowBlip:mainfrom
6jrx:fix/smt-control-panic
Open

fix(cpu): don't panic when SMT cannot be enabled#38
6jrx wants to merge 1 commit into
ShadowBlip:mainfrom
6jrx:fix/smt-control-panic

Conversation

@6jrx

@6jrx 6jrx commented Aug 22, 2026

Copy link
Copy Markdown

Cpu::new() unwraps the result of opening /sys/devices/system/cpu/smt/control for writing:

https://github.com/ShadowBlip/PowerStation/blob/v0.8.1/src/performance/cpu/cpu_features.rs#L29-L31

That knob only exists when the kernel is built with CONFIG_HOTPLUG_SMT, and /sys isn't always writable. When either is the case the daemon aborts, and since Cpu::new() is the first thing main() does, nothing else gets a chance to run — no GPU discovery, no DBus interfaces, no log line explaining why.

Reproducing it is as easy as starting PowerStation somewhere /sys is read-only:

INFO  [powerstation] Starting PowerStation v0.8.1

thread 'main' (41529) panicked at src/performance/cpu/cpu_features.rs:31:22:
called `Result::unwrap()` on an `Err` value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }

After:

INFO  [powerstation] Starting PowerStation v0.8.1
WARN  [powerstation::performance::cpu::cpu_features] Unable to enable SMT: Permission denied (os error 13)
INFO  [powerstation::performance::cpu::cpu_features] Core Map: {12: [CPUCore { number: 8, ...

Both set_smt_enabled() and set_boost_enabled() already turn the same kind of failure into a DBus error rather than panicking, so this only brings startup in line with the rest of the file. Behaviour on a system where the write does succeed is unchanged.

Found while testing #37; unrelated to it, so it's on its own branch off main.

Cpu::new() unwrapped the result of opening
/sys/devices/system/cpu/smt/control for writing, so PowerStation aborted
during startup on any system where that knob is absent, e.g. a kernel
built without CONFIG_HOTPLUG_SMT, or where /sys is not writable. It is
the first thing main() does, so nothing else got a chance to run.

Every other user of that path turns the error into a DBus error rather
than panicking. Log it and carry on here as well.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant