All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Marchetti <natryum@gmail.com>
To: Peter Chubb <peter@chubb.wattle.id.au>,
	kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] cpufreq: ondemand+conservative=condemand
Date: Mon, 27 Jun 2005 13:36:30 +0200	[thread overview]
Message-ID: <cc27d5b105062704367ae2e44@mail.gmail.com> (raw)
In-Reply-To: <17087.18663.601754.480257@wombat.chubb.wattle.id.au>

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?

  reply	other threads:[~2005-06-27 11:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-26  1:01 [PATCH] cpufreq: ondemand+conservative=condemand Paolo Marchetti
2005-06-27  0:31 ` Peter Chubb
2005-06-27 11:36   ` Paolo Marchetti [this message]
  -- strict thread matches above, loose matches on Subject: below --
2005-06-25 15:08 Paolo Marchetti
2005-06-25 18:26 ` Alexey Dobriyan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cc27d5b105062704367ae2e44@mail.gmail.com \
    --to=natryum@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter@chubb.wattle.id.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.