Steps to getting CPUDYN and CPUDYND to work on your system

There are a few steps involved
1) Make sure your system is set up properly to handle the cpudyn program (kernel and module settings)
2) Make sure you know how cpudyn works (understanding throttling)
3) Configuring and Launching cpudyn (understanding cpudyn parameters and how to launch it)


1)  Kernel and Module Settings

    One thing I learned is that not only does one have to set the kernel properly but they also need to make sure that the modules that they've chosen during the kernel configuration ARE INDEED loaded.  This has always been a tripping point for me.  If the item is configured as a module then YOU are responsible for making sure it is loaded at boot time or when needed.  If it is compiled as something that is integrated with the kernel then it should be loaded at boot time and it is a good idea to make sure that things are indeed working as thought.

    To get CPUDYN to work one needs to have the proper kernel configurations chosen as shown at the cpudyn homepage but as a quick reference one needs to enable the following (for 2.6 kernel):

Power management options ->CPU Frequency Scaling ->
*
CPU Frequency scaling needs to be turned on
*
CPU Frequency scaling needs to be turned on
*
/proc/cpufreq interface (doesn't matter if on or off, I use it off)
*
Default CPUFreq governor (I set it to userspace)
*
performance governor is set to yes NOT module (module is fine but the module will need to be loaded at boot time and I "think" it is called gov-performance and this can be done by adding the line gov-performance to /etc/modprobe.preload)
*
powersave governor is set to yes NOT module(module is fine but the module will need to be loaded at boot time and I "think" it is called gov-powersave and this can be done by adding the line gov-powersave to /etc/modprobe.preload)
*
my userspace governor for userspace frequency scaling is set
*
/proc/sys/cpu interface is not set for me but I think it'll work even if set
* CPU frequency table helper is set as a module and loaded with the module chosen for the particular processor
*
now, one needs to choose the proper module to control their cpu.  I have a PIV-M based laptop so I chose the Intel Speedstep on ICH-M chipset and the Intel Pentium 4 clock modulator although I only load the Intel Speedstep module at boot time by adding a line to my /etc/modprobe.preload file which states speedstep-ich


In short you need to choose the modules and MAKE SURE they are loaded otherwise cpudyn won't work.  My modprobe.preload has the following line

            speedstep-ich

but if you compiled the governors as modules then you would need to have the following lines

            gov-performance
            gov-powersave
            speedstep-ich

This ensures that you have the modules compiled and called.  After rebooting, issue the following commands to make sure they are loaded.  Must be root user

lsmod | more and see if the modules are loaded.  You can also tell if they are loaded by checking to see if the

/sys/devices/system/cpu/cpu0/cpufreq/ directory exists.  Those directories won't exist if the proper module isn't loaded.  Note, this assumes that you have done what is necessary to make sure that the /sys file structure is used instead of the deprecated /proc/ directory structure.  Create the folder /sys and add the following line to your /etc/fstab:

none                    /sys                    sysfs   defaults        0 0

2) Cpudyn works by manipulating the performance modes that exist but it needs to have the proper module loaded so that the proper modes are present

After rebooting you should find the performance modes at,

/sys/devices/system/cpu/cpu0/cpufreq/

and if the modules loaded properly you should find the following files and they will contain some information that can be revealed when "cat-ed" , meaning

 cat /sys/devices/system/cpu/cpu0/cpufreq/"filename"


cpuinfo_max_freq - what the maximum cpu speed is in kilohertz (not configurable)
cpuinfo_min_freq - what the minimum cpu speed is in kilohertz (not configurable)
scaling_available_governors -the available governors to throttle your speed and should now contain
 powersave userspace performance  (not configurable)

scaling_driver -the name of the module that is doing the throttling (for me it is speedstep-ich).  Configurable by loading the correct module.
scaling_governor -configurable governor being used and it will be either powersave, userspace, OR performance.  If it is userspace then the user can issue commands to the scaling_setspeed to throttle the cpu by kilohertz.  If cpudyn is working correctly then it will issue either the powersave or performance command to the scaling_setspeed file which then sets your cpu speed to either the maximum or minimum frequency defined by scaling_max_freq or scaling_min_freq.
scaling_min_freq -configurable minimum frequency
scaling_max_freq -configurable maximum frequency
scaling_setspeed -configurable speed when throttling BUT will not appear if cpudyn is working and only appears if the scaling_governor is set to userspace

How to set certain parameters (as root):
you can "echo" a parameter to the file.  For example, if I wanted to set the scaling_governor to userspace then I would

Setting and using the userspace governor
echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

at which point the scaling_speed would become available and if I wanted to throttle the speed to something lower than my 2.4Ghz PIV-M was I could

echo 1200000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed

which is 1/2 of my maximum and also coincides with my cpuinfo_min_freq.  I've never tried setting it to anything other than the frequencies specified by cpuinfo_min_freq or cpuinfo_max_freq.

Cpudyn and the userspace governor

cpudyn uses the userspace  governor even though it doesn't appear to since it issues either the powersave or performance governor to the scaling_governor.  What this means is that you won't see userspace as the scaling_governor although cpudyn IS a userspace governor.

Adjusting the min and max throttle speeds

the scaling_min_freq and scaling_max_freq setting are, by default, set to the cpuinfo_min_freq and cpuinfo_max_freq respectively BUT if one would like other max and min SUPPORTED settings then they can adjust the scaling_min_freq and scaling_max_freq settings by echoing them the desired frequencies such as

echo 1400000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq

which adjusts my min from 1.2 to 1.4Ghz.  NOTE:  I have not tried this but this is how it "should" work.

Essentially, cpudyn is watching your cpu idle states and will throttle up if it isn't idling too much and throttle down if it is.  Sure, you could do it yourself by adjusting the scaling_setspeed but this would get tiresome quickly.

3) Understanding the CPUDYN parameters and how to launch it

After compiling and installing cpudyn by typing "make install" in the directory where you untarred cpudyn (as root) cpudyn will put a few of the files in different locations.  There are other files but these are the ones that I toy with.


cpudyn - located in /etc/init.d and can be run upon bootup by linking to it in your /etc/rcX.d directory (more below)
cpudyn
- located in /etc/sysconfig and contain default parameters and are called by /etc/init.d/cpudyn when run - configurable parameters
cpudynd
- located in /usr/sbin/  and called by the /etc/init.d/cpudyn after it is passed the parameters that are set by /etc/sysconfig/cpudyn which, by default, sets the -d parameter and loads this daemon (see below)

loading cpudyn at bootup
  Systems typically boot up in 2 of 5 modes, either mode 3 which is multi-user non-graphical and mode 5 which is multi-user graphical mode.  If you want to load items at boot time then the file is put in the /etc/init.d directory and a link to that file is put in whichever mode you typically boot.  In this way, all the available bootup programs are available but depending on bootup mode only the ones desired are loaded by symbolic links.  In other words if I want something in /etc/init.d to be started at boot time and my default boot mode is 3 then I would make a symbolic link in /etc/rc3.d to that file in /etc/init.d or if the default mode was 5 then I'd make the link in /etc/rc5.d.  The key here is that the link needs a special "S" parameter followed by a "numeral" so it knows when to load.  If the number is too low and it depends on something that is loaded later then it won't load properly.  For that reason, I typically set it to 99.  So get to your default directory (e.g. for me it is /etc/rc3.d)

        cd /etc/rc3.d

and create the symbolic link to the /etc/init.d/cpudyn file

       ln -s ../init.d/cpudyn S99cpudyn

this will make cpudyn load at the end of the loading process and don't worry if there are multiple S99 files as it isn't a big deal this late in the load process.

Note:  The default boot mode can be made by adjusting the numeral in the /etc/inittab file at the line that has

        id:3:initdefault:      (just change the 3 to 5 if you want to boot up in multiuser GUI mode)

         
Cpudyn parameters
Here is a brief description of what those variables are and what they do...

the default options are "-d -i 1 -p 0.5 0.90"
or
the default options are "-d -i 1 -p 0.5 0.90 -t 120"  (where the t is for throttling down the hard drive after 120 seconds if not used)

-d  - means daemonize the cpudyn program so it is always running in the background and monitoring your cpu status

-i - means to set the interval of cpu idle/load checking to the numeral that follows (in 1/10th of seconds).  The default is to check the cpu idle/load status every tenth of a second (decisecond).

-p - is the variable for signifying that the next two numerals are to be used for comparing the processor idle/load time.  The default is 0.5 and 0.9 which means that if the cpu is idle less than 50% of the time it will step up the processors speed and if it gets to the point where it is idle more than 90% of the time then it will step down the speed.  I like to use more aggressive settings because of my laptop usage and so I don't bump up until the cpu is idle to less than 40% and I won't bump down until it is less than 75% of the time.

Here is a listing of all the variables from the cpudynd.c file that can be found by typing /usr/sbin/cpudynd -?

-acpi
- do not use frequency scaling, use ACPI throttling if available (I added this option to my /etc/sysconfig/cpudyn file BUT it causes the daemon to stop working - apparantly some acpi problems exist)
-asus
- Enable Asus laptop led display
-d - Daemonize process (run in background)
-h <dev0[,dev1]...> - Specified the disks to spindown, example: -h /dev/hda,/dev/hdc
    If this option is specified, but not -t, the default is 120 secs)
-i <interval> - Check period in 1/10 seconds. Alternative to -ms.
-l <state> - Specifies to which throttling state the cpu is set when speeding down (default is 3)
-minf <min>
- Set the minimum CPU's frequency in a value between 0.0 and 1.0
-ms <interval> - Check period in miliseconds. Alternative to -i.
-nice 
- Count nice CPU usage as load (default = no)
-p <up> <down> - Set CPU idle:work ratios to speed up or down CPU (default is 0.5 0.9)
 -t <timeout> - Set the timeout to put the disk in standby mode if there were no io during that period
Not_ activated by default
 /dev/hda is assumed if not  specified option -h)
 If option -h is specified, but not -t, the default is 120 secs)
-X
- Just exit after initial checkings
 -V 
- just print version and exit
 -?, --help 
- print this help

HTML Counter
stats counter