P4-Clockfuck
by BenV on Sep.03, 2009, under Software
You know what’s really annoying?
Try this:
root@Uil:/sys/devices/system/cpu/cpu0/cpufreq:0>echo ondemand > scaling_governor
root@Uil:/sys/devices/system/cpu/cpu0/cpufreq:0>dmesg
[1325843.712549] ondemand governor failed, too long transition latency of HW, fallback to performance governor
Apparently this is caused by the p4-clockmod module.
You know, this piece of junk:
Also known as “CONFIG_X86_P4_CLOCKMOD“.
The reason?
Well, the ondemand and the conservative governors want to be able to switch to a different speed before their calculations become invalid.
The p4-clockmod thing apparently makes the latency of switching so BIG that it becomes impossible. Or so they think.
Which leaves only the sucky powersave and performance governors. (and of course userspace).
The kernel menuconfig help states:
This driver should be only used in exceptional
circumstances when very low power is needed because it causes severe
slowdowns and noticeable latencies. Normally Speedstep should be used
instead.
Lovely. I’ll keep that in mind, thanks.
*enables CONFIG_X86_ACPI_CPUFREQ instead*
Note that when they’re both compiled in (as opposed to modules) the retarded thing seems to go for the clockmod. Just great.
November 21st, 2009 on 21:28
ACPI_CPUFREQ only gives me 2 speeds! 3.2 and 2.4GHz. Clockmod gives me 8 from 3.2GHz to 400MHz. Just because someone deemed that my processors too slow for me to use this, despite the fact I’ve been using it just fine for ages?! Thankfully it’s open source and very easy to undo if you’re building your own kernel/modules, and so I thought I’d share what I found cuz it *%#! annoyed the hell out of me too.
If you run:
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_transition_latency
you will notice the latency is 10000001, which I thought looked highly suspicously like someone had hardcoded that number somewhere to be 1 more than a max number set somewhere where the ondemand/etc would work. You can find it in the file (assuming kernel sources are in /usr/src/linux) :
/usr/src/linux/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c
If you search in that file for the number 10000001 in that file, decrease it by one to 10000000, and recompile the module (if you have p4-clockmod compiled as a module; if it’s linked into the kernel you’ll need to recompile the kernel and reboot).
I have found that changing the up_threshold of the ondemand governor from its default to 40 makes it ramp its speed up when I need it to, and stay there until it drops back down again. With my usage pattern it’s not making these switches very often, so any delays in changing the speed are perfectly acceptable -to me-. To do this, simply:
echo 40 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
Hope this is useful to you / anyone.