fancontrol: max of multiple temp sensors for single PWM control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.)

-- 
Chusslove Illich (Часлав Илић)
Index: doc/fancontrol.txt
===================================================================
--- doc/fancontrol.txt	(revision 6037)
+++ doc/fancontrol.txt	(working copy)
@@ -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.
Index: prog/pwm/fancontrol
===================================================================
--- prog/pwm/fancontrol	(revision 6037)
+++ prog/pwm/fancontrol	(working copy)
@@ -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 ]

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux