Skip to content

Commit 97e31c4

Browse files
committed
config: don't set EPP or EBP on performance profile on intel-pstate
fixes #46
1 parent b453df4 commit 97e31c4

4 files changed

Lines changed: 19 additions & 6 deletions

File tree

watt/config.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ mod expression {
395395
named!(power_supply_discharge_rate => "%power-supply-discharge-rate");
396396

397397
named!(discharging => "?discharging");
398+
named!(intel_pstate => "?intel-pstate");
398399
}
399400

400401
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
@@ -454,6 +455,9 @@ pub enum Expression {
454455
#[serde(with = "expression::discharging")]
455456
Discharging,
456457

458+
#[serde(with = "expression::intel_pstate")]
459+
IntelPstate,
460+
457461
Boolean(bool),
458462

459463
Number(f64),
@@ -615,7 +619,8 @@ pub struct EvalState<'peripherals, 'context> {
615619
pub power_supply_charge: Option<f64>,
616620
pub power_supply_discharge_rate: Option<f64>,
617621

618-
pub discharging: bool,
622+
pub discharging: bool,
623+
pub intel_pstate: bool,
619624

620625
pub context: EvalContext<'context>,
621626

@@ -748,6 +753,7 @@ impl Expression {
748753
},
749754

750755
Discharging => Boolean(state.discharging),
756+
IntelPstate => Boolean(state.intel_pstate),
751757

752758
literal @ (Boolean(_) | Number(_) | String(_)) => literal.clone(),
753759

@@ -1039,6 +1045,7 @@ mod tests {
10391045
power_supply_charge: Some(0.8),
10401046
power_supply_discharge_rate: Some(10.0),
10411047
discharging: false,
1048+
intel_pstate: false,
10421049
context: EvalContext::Cpu(&cpu),
10431050
cpus: &cpus,
10441051
power_supplies: &power_supplies,
@@ -1123,6 +1130,7 @@ mod tests {
11231130
power_supply_charge: Some(0.8),
11241131
power_supply_discharge_rate: Some(10.0),
11251132
discharging: false,
1133+
intel_pstate: false,
11261134
context: EvalContext::Cpu(&cpu),
11271135
cpus: &cpus,
11281136
power_supplies: &power_supplies,

watt/config.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ if.all = [
3535
]
3636
priority = 80
3737

38-
cpu.energy-performance-bias = { if.is-energy-performance-bias-available = "performance", then = "performance" }
39-
cpu.energy-performance-preference = { if.is-energy-performance-preference-available = "performance", then = "performance" }
38+
cpu.energy-performance-bias = { if.all = [{ not = "?intel-pstate" }, { is-energy-performance-bias-available = "performance" }], then = "performance" }
39+
cpu.energy-performance-preference = { if.all = [{ not = "?intel-pstate" }, { is-energy-performance-preference-available = "performance" }], then = "performance" }
4040
cpu.governor = { if.is-governor-available = "performance", then = "performance" }
4141
cpu.turbo = { if = "?turbo-available", then = true }
4242

@@ -49,8 +49,8 @@ if.all = [
4949
]
5050
priority = 70
5151

52-
cpu.energy-performance-bias = { if.is-energy-performance-bias-available = "balance_performance", then = "balance_performance" }
53-
cpu.energy-performance-preference = { if.is-energy-performance-preference-available = "performance", then = "performance" }
52+
cpu.energy-performance-bias = { if.all = [{ not = "?intel-pstate" }, { is-energy-performance-bias-available = "balance_performance" }], then = "balance_performance" }
53+
cpu.energy-performance-preference = { if.all = [{ not = "?intel-pstate" }, { is-energy-performance-preference-available = "performance" }], then = "performance" }
5454
cpu.governor = { if.is-governor-available = "performance", then = "performance" }
5555
cpu.turbo = { if = "?turbo-available", then = true }
5656

watt/cpu.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,10 @@ impl Cpu {
723723
.map(|x| x.map(|freq| freq / 1000))
724724
}
725725

726+
pub fn is_intel_pstate() -> bool {
727+
fs::exists("/sys/devices/system/cpu/intel_pstate")
728+
}
729+
726730
pub fn turbo() -> anyhow::Result<Option<bool>> {
727731
log::trace!("reading turbo boost status");
728732

watt/system.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,8 @@ pub fn run_daemon(config: config::DaemonConfig) -> anyhow::Result<()> {
792792
.map(|log| log.charge),
793793
power_supply_discharge_rate: system.power_supply_discharge_rate(),
794794

795-
discharging: system.is_discharging(),
795+
discharging: system.is_discharging(),
796+
intel_pstate: cpu::Cpu::is_intel_pstate(),
796797

797798
context: config::EvalContext::WidestPossible,
798799

0 commit comments

Comments
 (0)