Commit 7be0568bd6a8

Vincent Demeester <vincent@sbr.pm>
2026-07-30 09:50:59
fix: tuned-ppd duplicate profile mapping in ppd.conf
Battery section mapped performance to powersave which conflicted with power-saver's powersave mapping. The tuned-ppd config requires injective (1:1) mappings. Fixed battery mappings: balanced→balanced-battery, performance→balanced. Changed default to balanced.
1 parent bab1a38
Changed files (2)
imperative
imperative/aomi/bootstrap.sh
@@ -368,16 +368,29 @@ setup_power() {
 		log_info "powertop service already exists"
 	fi
 
-	# Set tuned profile for battery life
+	# Configure tuned-ppd mapping (PPD profiles → tuned profiles)
+	# All values must be unique per map (injective) for reversibility.
+	# AC:      power-saver→powersave, balanced→balanced, performance→latency-performance
+	# Battery: power-saver→powersave, balanced→balanced-battery, performance→balanced
 	if command -v tuned-adm &>/dev/null; then
-		local current
-		current=$(tuned-adm active 2>/dev/null | sed 's/.*: //')
-		if [[ "$current" != "balanced-battery" ]]; then
-			log_info "Setting tuned profile to balanced-battery (was: $current)..."
-			sudo tuned-adm profile balanced-battery
-		else
-			log_info "tuned profile already balanced-battery"
-		fi
+		log_info "Configuring tuned-ppd..."
+		sudo tee /etc/tuned/ppd.conf >/dev/null <<-'EOF'
+			[main]
+			default=balanced
+			battery_detection=true
+			sysfs_acpi_monitor=true
+
+			[profiles]
+			power-saver=powersave
+			balanced=balanced
+			performance=latency-performance
+
+			[battery]
+			balanced=balanced-battery
+			performance=balanced
+		EOF
+		sudo systemctl restart tuned tuned-ppd
+		log_info "tuned-ppd configured"
 	fi
 }
 
imperative/kyushu/bootstrap.sh
@@ -378,13 +378,15 @@ setup_power() {
 		log_info "powertop service already exists"
 	fi
 
-	# Configure tuned-ppd for dev performance:
-	# AC → latency-performance (max speed), battery → powersave
+	# Configure tuned-ppd mapping (PPD profiles → tuned profiles)
+	# All values must be unique per map (injective) for reversibility.
+	# AC:      power-saver→powersave, balanced→balanced, performance→latency-performance
+	# Battery: power-saver→powersave, balanced→balanced-battery, performance→balanced
 	if command -v tuned-adm &>/dev/null; then
-		log_info "Configuring tuned-ppd for dev performance..."
+		log_info "Configuring tuned-ppd..."
 		sudo tee /etc/tuned/ppd.conf >/dev/null <<-'EOF'
 			[main]
-			default=performance
+			default=balanced
 			battery_detection=true
 			sysfs_acpi_monitor=true
 
@@ -394,10 +396,11 @@ setup_power() {
 			performance=latency-performance
 
 			[battery]
-			performance=powersave
+			balanced=balanced-battery
+			performance=balanced
 		EOF
-		sudo systemctl restart tuned
-		log_info "tuned-ppd configured: AC→latency-performance, battery→powersave"
+		sudo systemctl restart tuned tuned-ppd
+		log_info "tuned-ppd configured"
 	fi
 }