Messages in this thread | | | Date | Mon, 27 Jun 2005 13:36:30 +0200 | From | Paolo Marchetti <> | Subject | Re: [PATCH] cpufreq: ondemand+conservative=condemand |
| |
On 6/27/05, Peter Chubb <peter@chubb.wattle.id.au> wrote: > >>>>> "Paolo" == Paolo Marchetti <natryum@gmail.com> writes: > > >> Just change defaults in conservative governor to make it more > >> responsive. > >> > Paolo> Alexey, I played with conservative governor trying to make it > Paolo> work decently on my p4 with no results. As you know it works > Paolo> but it isn't responsive, it takes eons to step up/down. > > You can always use a userspace governer. I've attached the one I use. > > Every five seconds (you can make it faster if you wish, but that seems > about right for my usage patterns), the program reads the load > average, and decides whether to adjust the CPU frequency. If the one > second load average is above $FASTTRESHHOLD, the frequency will be > stepped up by $FASTINC; otherwise if it's above $SLOWTHRESHHOLD, it's > incremented by $SLOWINC. If the 15-second load average is below > $DECTHRESSHOLD, the frequency is stepped downwards by $DEC. So you > get fast increases, and slow decreases, but becasue the time constant > for the decrease is long, you can get good response for a load spike, > then fairly rapid decrease. The aim is to keep the load average > around 0.9. > > > -- > #!/bin/sh > > # Seconds to sleep between adjustments > INTERVAL=5 > > # The controller increments the throttling state by FASTINC > # if the load average is over FASTTRHESHHOLD. > # Thresholds are in percentage points load average -- i.e., the one > # second load average of 1.0 corresponds to a threshold of 100. > FASTINC=3 > FASTTHRESHOLD=100 > # Slow increment > SLOWINC=1 > SLOWTHRESHOLD=80 > # Decrement > DEC=1 > DECTHRESHOLD=500 > > cd /sys/devices/system/cpu/cpu0/cpufreq > > # Do some parameter checks. > [ $FASTTHRESHOLD -le $SLOWTHRESHOLD ] && { > echo >&2 "Fast Threshold $FASTTHRESHOLD must be greater than the" > echo >&2 "slow threshold $SLOWTHRESHOLD" > exit 1 > } > > [ \( $SLOWINC -ge 1 \) -a \( $FASTINC -ge 1 \) -a \( $DEC -ge 1 \) ] || { > echo >&2 "Increments must all be small integers in the range 1 to 7" > exit 1 > } > > # convert a two dec place number to an int scaled by 100. > function to_int() > { > val=$1 > OIFS="$IFS" > IFS="." > set $val > IFS="$OIFS" > expr $1 \* 100 + $2 > } > > # get load averages > function loadavg() > { > read onesec fivesec fifteensec rest < /proc/loadavg > onesec=`to_int $onesec` > fifteensec=`to_int $fifteensec` > } > > function getspeeds() > { > echo userspace > scaling_governor > set `cat scaling_available_frequencies` > i=0 > for j > do > i=`expr $i + 1` > eval speed$i=$j > done > nspeeds=$i > } > > # Get current throttling factor. > # This can be changed automatically by the BIOS in response to power > # events (e.g., AC coming on line). > function throttle() { > < scaling_cur_freq read curfreq > i=1; > while [ $i -lt $nspeeds ] > do > eval [ \$speed$i -eq 0$curfreq ] && expr $nspeeds - $i > i=`expr $i + 1` > done > } > > function set_speed() { > x=`expr $nspeeds - $1` > eval speed=\$speed$x > echo $speed > scaling_setspeed > } > > # Increase the effective processor speed. > function up() > { > [ $current_throttle -eq 0 ] || { > current_throttle=`expr $current_throttle - $1` > [ $current_throttle -lt 0 ] && current_throttle=0 > set_speed $current_throttle > } > } > > # Decrease the effective processor speed. > function down() > { > [ $current_throttle -eq $nspeeds ] || { > current_throttle=`expr $current_throttle + $1` > [ $current_throttle -gt $nspeeds ] && current_throttle=$nspeeds > set_speed $current_throttle > } > } > > > getspeeds > current_throttle=`throttle` > while sleep $INTERVAL > do > loadavg > > # Go up fast, then tail off. > # > if [ $onesec -gt $FASTTHRESHOLD ] > then > up $FASTINC > elif [ $onesec -gt $SLOWTHRESHOLD ] > then > up $SLOWINC > elif [ $fifteensec -lt $DECTHRESHOLD ] > then > down $DEC > fi > done > Thank you, I'll try it. Unfortunately the problem is: how to get conservative governor work decently on a p4 laptop? - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |