Re: Latest Power Management tool for AMD64
T o n g wrote:
The default kernel governor is ONDEMAND, so Tong has probably been using
CPU frequency controls all along without knowing it.  :)  
Not after I've installed a bunch of packages that google implies 
necessary, because I'm using a minimum set of packages.
What are the minimum set of packages to enable kernel space cpufreq 
ondemand governor?
To quote my own previous message:
    I personally use 'powernowd' with my Athlon 64 X2 desktop CPU, but
    it is true that the kernel's ondemand governor is "simpler" in the
    sense that it can be used without having to install (and configure)
    other software.
The ONDEMAND governor is a Linux kernel feature.  No userspace software 
is required at all!
These kernel features are available in any kernel compiled with the 
relevant options.  The latest Sid kernel (2.6.28-1) builds PERFORMANCE 
and ONDEMAND into the kernel (i.e., they are always present, and cannot 
be unloaded even when not being used) and makes the other governors 
available as modules:
    CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
    CONFIG_CPU_FREQ_GOV_POWERSAVE=m
    CONFIG_CPU_FREQ_GOV_USERSPACE=m
    CONFIG_CPU_FREQ_GOV_ONDEMAND=y
    CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
The default in this Sid kernel is to set ONDEMAND as the governor 
running when the kernel boots:
    # CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
    # CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
    # CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
    CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
    # CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
You can look at the settings for your running kernel by opening a 
terminal and running
    grep FREQ /boot/config-$(uname -r)
Other software you have installed, if it touches the CPU frequency 
kernel support, can interfere with which governor is currently being 
used on your system.
In the case of 'powernowd', for example, it is possible to control
things like:
   - polling time (how often frequency adjustments are made) - upper and
   lower CPU usage thresholds (which control the decision
     about whether to step CPU frequency up or down)
   - step size (how much frequency is altered when stepped up or down...
     though this is very much constrained by hardware limitations)
   - mode (basic behavior of the CPU governor)
What's your current frequency limits, and step sizes?
This is a matter of personal preference, so you should experiment with 
your own system until you like its behavior.  I suggest sticking with 
the defaults, unless something about those settings annoys you.
I _did_ find myself annoyed, so I experimented and settled on these 
settings:
    $ cat /etc/default/powernowd
    #default file for powernowd, see man 1 powernowd
    #
    # Options
    OPTIONS="-v -u 40 -l 5 -m 1 -s 200000 -p 500"
These options give me:  verbose output during boot (-v); upper usage 
threshold of 40% (-u 40); lower threshhold of 5% (-l 5); behavior model 
set to aggressive (-m 1) [unnecessary to list, since it is the default, 
but I specify it anyway as a reminder to self]; frequency step of 
200,000 Hz (-s 200000); and polling time of 1/2 second (-p 500).
The behavior I get from these settings is:
  - jump to max frequency if CPU usage hits 5%
  - do not decrease frequency unless usage drops below 40%
  - when dropping frequency, drop in 0.2 GHz decrements
My Athlon 64 X2 has a maximum frequency of 3.2 GHz, and a minimum of 1.0 
GHz.  For simple daily tasks, the frequency stays at 1.0 GHz, even with 
the hair-trigger settings I use.  Any hint of taxing the CPU resources 
causes the afterburners to kick in (my desired setting), and they mostly 
stay in use until they are really not needed at all.
After learning to compile my own kernels, and exhaustively researching 
which settings were truly needed and disabling everything not needed for 
my system, I found that these settings allow me to compile the kernel 
and package the DEBs in 6 minutes.  My CPU frequency stays pegged at
3.2 GHz for most of that time, and quickly drops back to 1.0 GHz once 
the DEBs are produced.  :-)
Having enabled my kernel ondemand cpufreq governor, this is what I get:
  $ cpufreq-info | grep frequency
    CPUs which need to switch frequency at the same time: 0 1
    available frequency steps: 2.30 GHz, 2.20 GHz, 2.00 GHz, 1.80 GHz, 
1000 MHz
    current policy: frequency should be within 1000 MHz and 2.30 GHz.
    current CPU frequency is 1000 MHz (asserted by call to hardware).
Can I further lower the 1000 MHz boundary any way?
That is determined entirely by the hardware, not by the software.  it 
was mentioned earlier in this thread that Intel CPUs (so far) are much 
less flexible than AMD CPUs in this regard.
The 'powernowd' software defaults to "aggressive" mode, which jumps the
CPU frequency to maximum when the upper threshold on CPU usage is
reached.  This is what I use, and I set both the lower and upper
boundaries quite low in order to kick the CPU into high gear easily, and
keep it there as long as anything is going on.
That's similar to the "performance" governor of cpufreq, which is what I 
got by default after having crazily installed a bunch of packages:
  $ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
  performance
However, the CPU frequency was still very high, even my CPU utilization 
was near 0% for quite a long time:
  $ grep MHz /proc/cpuinfo
  cpu MHz         : 2300.000
Umm, the purpose of the PERFORMANCE governor is to use the maximum CPU 
frequency, and ONLY the maximum CPU frequency.  My impression was that 
you wanted to use the minimum frequency, until more power was needed....
You want ONDEMAND, which requires no userspace software (though you may 
need to manually set that governor if the kernel you use does not set it 
by default); or you want USERSPACE, if you use 'powernowd' or some other 
userspace frequency-controlling software (like me!).
HTH,
Dave W.
Reply to: