From fe04105060d52215dae8c6dc48dfc4a72fbf9414 Mon Sep 17 00:00:00 2001 From: marco44 Date: Sat, 6 Oct 2018 15:06:08 +0200 Subject: [PATCH] Small improvements: - Sort the frequencies in decreasing order (it's not the case on arm for instance) - Monitor the temperature from all sources instead of only one entry. That's safer if only one core (or gpu) gets very hot --- temp_throttle.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/temp_throttle.sh b/temp_throttle.sh index 8d4f7d1..be0209f 100755 --- a/temp_throttle.sh +++ b/temp_throttle.sh @@ -56,7 +56,7 @@ FREQ_MAX="/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq" # Store available cpu frequencies in a space separated string FREQ_LIST. if [ -f $FREQ_FILE ]; then # If $FREQ_FILE exists, get frequencies from it. - FREQ_LIST=$(cat $FREQ_FILE) || err_exit "Could not read available cpu frequencies from file $FREQ_FILE" + FREQ_LIST=$(cat $FREQ_FILE | xargs -n1 | sort -g -r | xargs) || err_exit "Could not read available cpu frequencies from file $FREQ_FILE" elif [ -f $FREQ_MIN -a -f $FREQ_MAX ]; then # Else if $FREQ_MIN and $FREQ_MAX exist, generate a list of frequencies between them. FREQ_LIST=$(seq $(cat $FREQ_MAX) -100000 $(cat $FREQ_MIN)) || err_exit "Could not compute available cpu frequencies" @@ -132,9 +132,9 @@ unthrottle () { } get_temp () { - # Get the system temperature. + # Get the system temperature. Take the max of all counters - TEMP=$(cat $TEMP_FILE) + TEMP=$(cat $TEMPERATURE_FILES 2>/dev/null | xargs -n1 | sort -g -r | head -1) } ### END define script functions.