Wednesday, November 02, 2005

Linux on a Vaio: CPU speed scaling

If you're looking for Fedora Core 6 (FC6) help, I've added a note here. (2006/11/7)

Random technical note for surfers looking for help...
[Request: this page gets a fair number of hits, but I'm not getting any feedback on it. If it doesn't have enough information to be useful to you, drop me a comment and let me know how I can make it better!]

I'm running Fedora Core 4 on a Sony Vaio type T laptop. One thing I never had working was CPU frequency scaling. One symptom was "error: no such device" during boot. If I tried it by hand, I got

[root@pokhara sony_acpi]# pushd /lib/modules/2.6.13-1.1526_FC4/kernel/arch/i386/kernel/cpu/cpufreq/
/lib/modules/2.6.13-1.1526_FC4/kernel/arch/i386/kernel/cpu/cpufreq /home/rdv/linux/sony_acpi
[root@pokhara cpufreq]# ls
acpi-cpufreq.ko p4-clockmod.ko powernow-k8.ko speedstep-smi.ko
[root@pokhara cpufreq]# insmod acpi-cpufreq.ko
insmod: error inserting 'acpi-cpufreq.ko': -1 No such device
[root@pokhara cpufreq]#


My *guess* (not having read the code) is that the kernel dynamically attempts to figure out what your hardware is, and load the right kernel module. In my case, it was picking acpi-cpufreq, which is wrong, and so it was putting out a misleading error message. If it gets it right, I don't think you need a specific configuration step. If it can't figure it out, though, you need to add the "DRIVER=" line
to /etc/cpuspeed.conf. Here's my config, for a 900MHz Celeron M, which is apparently similar to a P4:


[rdv@pokhara dist-arch]$ cat /etc/cpuspeed.conf
VMAJOR=1
VMINOR=1

# uncomment this and set to the name of your CPUFreq module
#DRIVER="powernow-k7"
#DRIVER="acpi-cpufreq"
#DRIVER="powernow-k8"
#DRIVER="speedstep-smi"
DRIVER="p4-clockmod"

# Let background (nice) processes speed up the cpu
OPTS="$OPTS -n"

# Add your favorite options here
#OPTS="$OPTS -s 0 -i 10 -r"

# uncomment and modify this to check the state of the AC adapter
#OPTS="$OPTS -a /proc/acpi/ac_adapter/*/state"

# uncomment and modify this to check the system temperature
#OPTS="$OPTS -t /proc/acpi/thermal_zone/*/temperature 75"


Once I did that, it all works well. Copy the above, and try uncommenting the different "DRIVER" lines until you find one that works.

/proc/acpi/processor/CPU0/throttling doesn't appear to correctly flag the current CPU speed, but there is lots of info in /sys/devices/system/cpu/cpu0/cpufreq/ that wasn't present before this module loaded correctly, such as

[rdv@pokhara dist-arch]$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
112500 225000 337500 450000 562500 675000 787500 900000


I added the CPU frequency monitor to my GNOME panel, and I see it scaling from 900MHz down to 112MHz pretty aggressively as the machine goes idle. I can't manually adjust the speed from that widget, like some people can, but I think that's because my monitor isn't running setuid.

My minimum power consumption now seems to be about 9.4 watts with the WLAN off, disk idle, CPU speed down, and screen brightness on minimum. That should be good enough for 5.5 hours, not too far off Sony's claim of 6 hours of battery life. Realistically, I was getting 4-4.5 before this change with mid-level screen brightness, we'll see if the CPU frquency scaling actually brings me benefits or not...

The one thing I'm still missing is that it comes out of sleep only slowly, and not very reliably.

Hope this helps someone.

No comments: