CPU frequency scaling issue

A couple of Quirky 1.2rc testers reported jerky playing of youtube videos. I think at least one of those people is also using the CPU frequency scaling tool.

There may be a clash here. From this site:
http://wiki.archlinux.org/index.php/Cpufrequtils

Quoting:

Some CPUs may suffer from poor performance with the default settings of the ondemand governor (e.g. flash videos not playing smoothly or stuttering window animations).


Posted on 2 Jun 2010, 17:45


Comments:

Posted on 2 Jun 2010, 18:31 by BarryK
Ondemand governor
The 'acpi-cpufreq' module is recommended for most modern computers. However there are warnings that it might not work on older CPUs.

The 'cpufreq_ondemand' module is recommended for better temperature and power control, however there are warnings that it might not work on older CPUs, and might give jerky playback of media files.

I would like an "out of the box" solution, that works, nothing to be done. I was thinking of something like this in /etc/init.d:

#!/bin/sh

#BK got this from http://murga-linux.com/puppy/viewtopic.php?t=55417&start=15
# but added test for /proc/acpi, bios-date.

[ ! -d /proc/acpi ] && exit
[ `dmidecode -s "bios-release-date" | cut -f 3 -d '/'` -lt 6 ] && exit #<2006

#maybe could auto-load correct module based on this:
# dmidecode -s "processor-version"

modprobe acpi-cpufreq
modprobe cpufreq_ondemand
echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo ondemand > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
echo > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq
echo > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq


...or maybe not.



Posted on 2 Jun 2010, 19:44 by pakt
Frequency-scaling startup script
Barry, I've had success with the following code - not elegant but it has worked for me under limited testing. Note that max and min values for ondemand are automatically set.
#!/bin/sh

# Set up cpu frequency scaling and ondemand governor
# can be run in a startup script
# pakt, 19jan10

KERNVER="`uname -r`"
MODLIST="`ls /lib/modules/$KERNVER/kernel/arch/x86/kernel/cpu/cpufreq/ | cut -f 1 -d '.' | tr '\n' ' '`"
CPUSCALING=false

#no gentle way of detecting cpu type so do this
#loop through freq scaling modules and test for right one
for ONEMOD in $MODLIST
do
if modprobe -q $ONEMOD 2> /dev/null; then
modprobe cpufreq_ondemand
CPUSCALING=true
break
fi
sleep 1
done

if [ $CPUSCALING ]; then
ALLCPUS="`ls /sys/devices/system/cpu/ | grep 'cpu[0-9]' | tr '\n' ' '`"
#set governor to 'ondemand' for all cpus
for CPUNUM in $ALLCPUS
do
echo ondemand >/sys/devices/system/cpu/$CPUNUM/cpufreq/scaling_governor
done
fi



Posted on 2 Jun 2010, 21:25 by perthie
Some Test Results
My netbook often runs hot, like when I do a backup of its Windows partition to a USB drive. On hot days, it could get up to 70C. Using Quirky, that would trigger a warning from traytemp.

I did a number of tests using both Quirky and 4.3.1, with combinations of ACPI on/off and CPU frequency scaling (on demand) on/off. They all ran at basically the same temperature +/- 1C.

I then decreased the maximum scaling frequency and got an improvement of over 10C! I did this using Utility > CPU Frequency Scaling Tool, which dropped all the correct lines into /root/Startup/start_cpu_freq.

Along the way I discovered an odd bug. In Quirky, geany cannot open the files in /sys/devices/system/cpu/cpu0.




Posted on 2 Jun 2010, 22:13 by Jemimah
acpi and frequency scaling
What I do in Puppeee and Fluppy is use ACPI events to change the governor.

When you unplug, it automatically switches to powersave, then when you plug in, you get ondemand. I also change the brightness, and in the case of Puppeee do some other power saving tricks.

I've also created GUI that allows the user to switch it manually and switch it to performance mode if that is needed for flash video or something.

Most netbooks aren't designed to be run at full speed all the time - it's fairly critical to have power management working out of the box. Otherwise you get the over heating problem and terrible battery life.



Posted on 3 Jun 2010, 9:20 by BarryK
Scaling auto start script
Ok, I have created /etc/init.d/start_cpu_freq in Woof:

#!/bin/sh

#BK got this from http://murga-linux.com/puppy/viewtopic.php?t=55417&start=15
# but added test for /proc/acpi, bios-date, processor-manufacturer.
# added extra code provided by pakt.

#disable freq scaling for older computers...
[ ! -d /proc/acpi ] && exit
[ `dmidecode -s "bios-release-date" | cut -f 3 -d '/'` -lt 6 ] && exit #<2006

INTEL='p4-clockmod speedstep-centrino speedstep-ich'
VIA='longhaul e_powersaver'
CYRIX='gx-suspmod'

case "$1" in
start)
CPUMAN="`dmidecode -s 'processor-manufacturer' | tr '[A-Z]' '[a-z]' | cut -f 1 -d ' '`"
case $CPUMAN in
intel) FREQMODS="${INTEL} acpi-cpufreq" ;;
via) FREQMODS="${VIA} acpi-cpufreq" ;;
cyrix) FREQMODS="${CYRIX} acpi-cpufreq" ;;
*) FREQMODS="acpi-cpufreq" ;;
esac
for ONEMOD in $FREQMODS
do
modprobe -q $ONEMOD
if [ $? -eq 0 ];then
modprobe cpufreq_ondemand
if [ $? -eq 0 ];then
for CPUNUM in `ls -1 /sys/devices/system/cpu/ | grep 'cpu[0-9]' | tr '\n' ' '`
do
echo ondemand >/sys/devices/system/cpu/$CPUNUM/cpufreq/scaling_governor
done
#echo > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
#echo > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
#echo > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq
#echo > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
break
else
rmmod $ONEMOD
fi
fi
done
;;
esac




Posted on 3 Jun 2010, 11:52 by jemimah
p4-clockmod
I just tested this with Quirky on one of may Atom EeePcs. Unfortunately, it loads p4-clockmod instead of acpi-cpufreq.

P4-clockmod is not desirable. From what I read, it does slow down the cpu, but it doesn't actually reduce power consumption. It definitely should not be used on CPUs that support real scaling, and it's questionable whether you should use it on CPUs that don't, since it degrades performance without any power savings. I only know about this in terms of the EeePC so it probably requires research whether this is universally the case, but I think it is.

When I removed the INTEL code it loaded acpi-cpufreq correctly and did set it to ondemand mode.


Posted on 3 Jun 2010, 12:04 by jemimah
another tip
If you compile the kernel with ondemand as the default governor, you don't need to know how many cpus there are or any of that stuff. 'Modprobe acpi-cpufreq' will do the right thing automatically.

Compiling all the governors in to the acpi-cpufreq module (instead of as separate modules) will also make things simpler for the user.



Posted on 3 Jun 2010, 16:02 by BarryK
Procesor version
Jemimah,
What do you get when you run this in a terminal:

# dmidecode -s 'processor-version'

On my main laptop I get:
Intel(R) Celeron(R) M CPU

I'm thinking, maybe I will only load acpi-cpufreq, and only for certain CPUs as determined by the above test.



Posted on 3 Jun 2010, 20:31 by jemimah
processor version
On my Eee701SD I get
Intel(R) Celeron(R) M processor
This one does not support frequency scaling. You can load p4-clockmod, but it doesn't buy you anything. I don't even include it in Puppeee any more.

---
Intel(R) Atom(TM) CPU N280 @ 1.66GHz
Intel(R) Atom(TM) CPU N270 @ 1.60GHz

These are from my Eee 1005ha and 1000h. The both need to have scaling activated to avoid overheating and to get anywhere near the advertised battery life.

--
Intel(R) Core(TM) Duo CPU T8100 @ 2.10GHz

This is my work Centrino laptop. This one also supports scaling with acpi-cpufreq.





Posted on 5 Jun 2010, 5:11 by rjbrewer
cpu scaling
Cpu scaling is working great on Wary (the Wonderdog)
on my Inspiron 700m,1.6ghz single core.

Setting max cpu to 800mhz (default battery speed)
lowers the 70c+ temperatures to a steady 53c;
with little if any effect on video stream playing.