Skip to contentSkip to conversation

fancontrol: max of multiple temp sensors for single PWM control

lm-sensors Chusslove Illich 1 participant 1 message Mar 21, 2012

lore
Share & tools
lore
#0 lore raw

A while back, there was this post

http://lists.lm-sensors.org/pipermail/lm-sensors/2010-July/029109.html

which sumed up the issue (for me, the alternating-fan sound pattern is annoying). I attach a patch to make this possible, by giving a comma- separated list of temperature sensors in FCTEMPS.

I've tested it by forcing the affinity of a high-load process to different cores, while monitoring the /sys/class/hwmon/hwmonN/device/pwmM contents to make sure it does not change.

(Not subscribed, please CC.)

Signature · 1 line
Chusslove Illich (Часлав Илић)
fancontrol.txt +4 -0
Index: doc/fancontrol.txt
===================================================================
@@ -37,6 +37,10 @@
 	Maps pwm outputs to temperature sensors so fancontrol knows which
 	temperature sensors should be used for calculation of new values for
 	the corresponding pwm outputs.
+	Several temperature sensors may be mapped to single pwm output
+	as a comma-separated list, in which case the maximum of all readings
+	is taken as the referent temperature. This is useful for a CPU fan
+	on a multi-core CPU with separate temperature sensors per core.
 
 FCFANS
 	FCFANS records the association between a pwm and a fan.
pwm/fancontrol +22 -12
Index: prog/pwm/fancontrol
===================================================================
@@ -224,12 +224,14 @@
 	let fcvcount=0
 	while (( $fcvcount < ${#AFCTEMP[@]} )) # go through all temp inputs
 	do
-		tsen=${AFCTEMP[$fcvcount]}
-		if [ ! -r $tsen ]
-		then
-			echo "Error: file $tsen doesn't exist" >&2
-			outdated=1
-		fi
+		for tsen in $(echo ${AFCTEMP[$fcvcount]} | tr ',' ' ')
+		do
+			if [ ! -r $tsen ]
+			then
+				echo "Error: file $tsen doesn't exist" >&2
+				outdated=1
+			fi
+		done
 		let fcvcount=$fcvcount+1
 	done
 
@@ -391,12 +393,20 @@
 		minpwm=${AFCMINPWM[$fcvcount]}
 		maxpwm=${AFCMAXPWM[$fcvcount]}
 
-		read tval < ${tsens}
-		if [ $? -ne 0 ]
-		then
-			echo "Error reading temperature from $DIR/$tsens"
-			restorefans 1
-		fi
+		tval=0
+		for tsen in $(echo ${tsens} | tr ',' ' ')
+		do
+			read tval1 < ${tsen}
+			if [ $? -ne 0 ]
+			then
+				echo "Error reading temperature from $DIR/$tsen"
+				restorefans 1
+			fi
+			if [ $tval -lt $tval1 ]
+			then
+				tval=$tval1
+			fi
+		done
 
 		read pwmpval < ${pwmo}
 		if [ $? -ne 0 ]

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors