# cpufreqd

## [n00b@localhost]

I have a Thinkpad T61 with a Core 2 Duo CPU and nVidia Quadro NVS140M.  I am using cpufreqd (2.4.2-r1) to change the clock frequencies of both the CPU and GPU and change the brightness of the screen based on remaining battery/temperature.  My laptop has a safety feature in the BIOS that will cut the power if any of the CPU cores hits 100°C.  Therefore if I leave it on overnight compiling something I rely on cpufreqd to lower the clock speed if the temperature gets too high to prevent my laptop cutting out during a long compile.

My /etc/cpufreqd.conf is:

```
[General]

poll_interval=2

[/General]

[sensors_plugin]

sensors_conf=/etc/sensors3.conf

[/sensors_plugin]

[Profile]

name=Performance

minfreq=2001000

maxfreq=2001000

policy=performance

nv_core=0:400

nv_mem=0:1200

exec_post=echo 100 > /proc/acpi/video/VID1/LCD0/brightness

[/Profile]

[Profile]

name=Too Hot

minfreq=800000

maxfreq=1600000

nv_core=0:320

nv_mem=0:900

policy=ondemand

[/Profile]

[Profile]

name=Battery

minfreq=800000

maxfreq=2001000

policy=conservative

nv_core=0:400

nv_mem=0:1200

exec_post=echo 50 > /proc/acpi/video/VID1/LCD0/brightness

[/Profile]

[Profile]

name=Battery Low

minfreq=800000

maxfreq=800000

policy=powersave

nv_core=0:200

nv_mem=0:600

exec_post=echo 20 > /proc/acpi/video/VID1/LCD0/brightness

[/Profile]

[Rule]

name=Plugged in

ac=on

battery_interval=15-100

sensor=temp1:0-70

sensor=temp2:0-70

acpi_temperature=thermal_zone0:0-70

acpi_temperature=thermal_zone1:0-70

profile=Performance

[/Rule]

 

[Rule]

name=On Batteries

ac=off

battery_interval=15-100

sensor=temp1:0-70

sensor=temp2:0-70

acpi_temperature=thermal_zone0:0-70

acpi_temperature=thermal_zone1:0-70

profile=Battery

[/Rule]

[Rule]

name=Overheating

battery_interval=15-100

sensor=temp1:70-127

sensor=temp2:70-100

acpi_temperature=thermal_zone0:70-127

acpi_temperature=thermal_zone1:70-100

profile=Too Hot

[/Rule]

[Rule]

name=Low Power

ac=off

battery_interval=0-15

sensor=temp1:0-70

sensor=temp2:0-70

acpi_temperature=thermal_zone0:0-70

acpi_temperature=thermal_zone1:0-70

profile=Battery Low

[/Rule]
```

I have all the required (and available) governors compiled into the kernel.  The cpufreq driver in use is acpi-cpufreq which is also compiled into the kernel (tuxonice-sources-2.6.38-r1).

Seeing as I have the above configuration would anyone like to hazard a guess as to why cpufreqd might consider doing this??

```
garyslaptop ~ # cpufreq-info 

cpufrequtils 007: cpufreq-info (C) Dominik Brodowski 2004-2009

Report errors and bugs to cpufreq@vger.kernel.org, please.

analyzing CPU 0:

  driver: acpi-cpufreq

  CPUs which run at the same hardware frequency: 0 1

  CPUs which need to have their frequency coordinated by software: 0

  maximum transition latency: 10.0 us.

  hardware limits: 800 MHz - 2.00 GHz

  available frequency steps: 2.00 GHz, 2.00 GHz, 1.60 GHz, 1.20 GHz, 800 MHz

  available cpufreq governors: conservative, ondemand, userspace, powersave, performance

  current policy: frequency should be within 1.60 GHz and 2.00 GHz.

                  The governor "performance" may decide which speed to use

                  within this range.

  current CPU frequency is 2.00 GHz (asserted by call to hardware).

  cpufreq stats: 2.00 GHz:51.58%, 2.00 GHz:41.00%, 1.60 GHz:1.41%, 1.20 GHz:0.17%, 800 MHz:5.84%  (1756)

analyzing CPU 1:

  driver: acpi-cpufreq

  CPUs which run at the same hardware frequency: 0 1

  CPUs which need to have their frequency coordinated by software: 1

  maximum transition latency: 10.0 us.

  hardware limits: 800 MHz - 2.00 GHz

  available frequency steps: 2.00 GHz, 2.00 GHz, 1.60 GHz, 1.20 GHz, 800 MHz

  available cpufreq governors: conservative, ondemand, userspace, powersave, performance

  current policy: frequency should be within 800 MHz and 1.60 GHz.

                  The governor "ondemand" may decide which speed to use

                  within this range.

  current CPU frequency is 2.00 GHz (asserted by call to hardware).

  cpufreq stats: 2.00 GHz:25.36%, 2.00 GHz:0.00%, 1.60 GHz:15.38%, 1.20 GHz:1.55%, 800 MHz:57.72%  (29606)
```

Any help is much appreciated!

----------

## [n00b@localhost]

To add to this I am currently stuck in the current situation (which is not specified in /etc/cpufreqd.conf):

```
garyslaptop ~ # cpufreq-info 

cpufrequtils 007: cpufreq-info (C) Dominik Brodowski 2004-2009

Report errors and bugs to cpufreq@vger.kernel.org, please.

analyzing CPU 0:

  driver: acpi-cpufreq

  CPUs which run at the same hardware frequency: 0 1

  CPUs which need to have their frequency coordinated by software: 0

  maximum transition latency: 10.0 us.

  hardware limits: 800 MHz - 2.00 GHz

  available frequency steps: 2.00 GHz, 2.00 GHz, 1.60 GHz, 1.20 GHz, 800 MHz

  available cpufreq governors: conservative, ondemand, userspace, powersave, performance

  current policy: frequency should be within 1.60 GHz and 2.00 GHz.

                  The governor "performance" may decide which speed to use

                  within this range.

  current CPU frequency is 2.00 GHz (asserted by call to hardware).

  cpufreq stats: 2.00 GHz:54.48%, 2.00 GHz:37.57%, 1.60 GHz:5.02%, 1.20 GHz:0.08%, 800 MHz:2.85%  (3369)

analyzing CPU 1:

  driver: acpi-cpufreq

  CPUs which run at the same hardware frequency: 0 1

  CPUs which need to have their frequency coordinated by software: 1

  maximum transition latency: 10.0 us.

  hardware limits: 800 MHz - 2.00 GHz

  available frequency steps: 2.00 GHz, 2.00 GHz, 1.60 GHz, 1.20 GHz, 800 MHz

  available cpufreq governors: conservative, ondemand, userspace, powersave, performance

  current policy: frequency should be within 800 MHz and 800 MHz.

                  The governor "ondemand" may decide which speed to use

                  within this range.

  current CPU frequency is 2.00 GHz (asserted by call to hardware).

  cpufreq stats: 2.00 GHz:4.60%, 2.00 GHz:0.00%, 1.60 GHz:6.73%, 1.20 GHz:0.27%, 800 MHz:88.40%  (17842)
```

Trying to change the CPU frequency manually (after stopping cpufreqd) does this:

```
garyslaptop ~ # cpufreq-set -gondemand -u1600MHz -d800MHz -r

garyslaptop ~ # cpufreq-info 

cpufrequtils 007: cpufreq-info (C) Dominik Brodowski 2004-2009

Report errors and bugs to cpufreq@vger.kernel.org, please.

analyzing CPU 0:

  driver: acpi-cpufreq

  CPUs which run at the same hardware frequency: 0 1

  CPUs which need to have their frequency coordinated by software: 0

  maximum transition latency: 10.0 us.

  hardware limits: 800 MHz - 2.00 GHz

  available frequency steps: 2.00 GHz, 2.00 GHz, 1.60 GHz, 1.20 GHz, 800 MHz

  available cpufreq governors: conservative, ondemand, userspace, powersave, performance

  current policy: frequency should be within 800 MHz and 800 MHz.

                  The governor "ondemand" may decide which speed to use

                  within this range.

  current CPU frequency is 800 MHz (asserted by call to hardware).

  cpufreq stats: 2.00 GHz:54.41%, 2.00 GHz:37.64%, 1.60 GHz:5.01%, 1.20 GHz:0.08%, 800 MHz:2.86%  (3370)

analyzing CPU 1:

  driver: acpi-cpufreq

  CPUs which run at the same hardware frequency: 0 1

  CPUs which need to have their frequency coordinated by software: 1

  maximum transition latency: 10.0 us.

  hardware limits: 800 MHz - 2.00 GHz

  available frequency steps: 2.00 GHz, 2.00 GHz, 1.60 GHz, 1.20 GHz, 800 MHz

  available cpufreq governors: conservative, ondemand, userspace, powersave, performance

  current policy: frequency should be within 800 MHz and 800 MHz.

                  The governor "ondemand" may decide which speed to use

                  within this range.

  current CPU frequency is 800 MHz (asserted by call to hardware).

  cpufreq stats: 2.00 GHz:4.59%, 2.00 GHz:0.00%, 1.60 GHz:6.72%, 1.20 GHz:0.27%, 800 MHz:88.42%  (17844)
```

I can run it in a loop and it will not select the correct upper frequency:

```
garyslaptop ~ # while [ $(cpufreq-info | grep "800 MHz and 800 MHz" | wc -l) -ne 0 ]; do cpufreq-set -gondemand -u1600MHz -d800MHz -r; done

^C

garyslaptop ~ # cpufreq-info 

cpufrequtils 007: cpufreq-info (C) Dominik Brodowski 2004-2009

Report errors and bugs to cpufreq@vger.kernel.org, please.

analyzing CPU 0:

  driver: acpi-cpufreq

  CPUs which run at the same hardware frequency: 0 1

  CPUs which need to have their frequency coordinated by software: 0

  maximum transition latency: 10.0 us.

  hardware limits: 800 MHz - 2.00 GHz

  available frequency steps: 2.00 GHz, 2.00 GHz, 1.60 GHz, 1.20 GHz, 800 MHz

  available cpufreq governors: conservative, ondemand, userspace, powersave, performance

  current policy: frequency should be within 800 MHz and 800 MHz.

                  The governor "ondemand" may decide which speed to use

                  within this range.

  current CPU frequency is 800 MHz (asserted by call to hardware).

  cpufreq stats: 2.00 GHz:53.69%, 2.00 GHz:37.13%, 1.60 GHz:4.95%, 1.20 GHz:0.08%, 800 MHz:4.16%  (3370)

analyzing CPU 1:

  driver: acpi-cpufreq

  CPUs which run at the same hardware frequency: 0 1

  CPUs which need to have their frequency coordinated by software: 1

  maximum transition latency: 10.0 us.

  hardware limits: 800 MHz - 2.00 GHz

  available frequency steps: 2.00 GHz, 2.00 GHz, 1.60 GHz, 1.20 GHz, 800 MHz

  available cpufreq governors: conservative, ondemand, userspace, powersave, performance

  current policy: frequency should be within 800 MHz and 800 MHz.

                  The governor "ondemand" may decide which speed to use

                  within this range.

  current CPU frequency is 800 MHz (asserted by call to hardware).

  cpufreq stats: 2.00 GHz:4.53%, 2.00 GHz:0.00%, 1.60 GHz:6.63%, 1.20 GHz:0.26%, 800 MHz:88.57%  (17844)
```

After looking at the cpufreq files in /sys I find that the cpufreq driver is limiting the top speed of my CPU for some reason:

```
garyslaptop ~ # cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies 

2001000 2000000 1600000 1200000 800000 

garyslaptop ~ # cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq 

800000

garyslaptop ~ # cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 

800400

garyslaptop ~ # cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 

800000

garyslaptop ~ # cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq 

2001000

garyslaptop ~ # cat /sys/devices/system/cpu/cpu0/cpufreq/bios_limit 

2001000

garyslaptop ~ # cat /sys/devices/system/cpu/cpu0/thermal_throttle/core_throttle_count 

0
```

So it would seem something is limiting the speed of my CPU and could also be causing cpufreqd to be unable to select the required speed.  Cpufreqd was not running on my laptop while running the above commands and I don't have anything in the BIOS that would limit CPU frequency with increasing temperature.

Could it be a bug in the cpufreq driver?

EDIT:

I ran my system for a while tonight without cpufreqd running and it automatically changed the CPU profile to performance/1.6GHz-2GHz by itself so it would appear something else besides cpufreqd is monitoring the CPU temperature and incorrectly altering the current governor and CPU frequency limits.

Anyone know what it could possibly be?  I have acpid, cpufreqd and cpufrequtils installed and all the governors and cpufreq driver compiled into the kernel.  Does the kernel or acpi(d) do any sort of monitoring?

----------

## jrittenh

What kernel are you running?  I have a T61p that had similar issues.  It regularly overheats.  When running 2.6.29-r5, it was stuck at 800MHz, no matter what I did.  The note at the top of the ThinkWiki page (http://www.thinkwiki.org/wiki/Problem_with_CPU_frequency_scaling) says that if it's stuck, there's probably a reason.

That being said, I had been holding out on updating my kernel for some time, basically because I didn't want to mess with it.  I also hadn't been doing system updates, so I was quite a bit behind.  I ended up doing a fairly large update which forced me to use a newer kernel, which ended up "unlocking" the CPU.  However, with that has come a slew of heating issues (I haven't taken the time to configure cpufreq yet, so it's pretty much my fault).  The problem is that if I fix cpufreq, it's probably going to effectively keep the CPU at 800MHz because it overheats at any higher speed.  Basically, the T61/T61p have horrible heat issues from what I can tell and there's probably not much we can do to get much speed out of them without some sort of enhanced cooling.

----------

## jowr

Huh, that's interesting. I had a similar problem (cpufreqd sticking @ 800mhz) until I looked carefully at the config files and realized it'll throttle as long as the temp is below something like 70C. The laptop CPU runs hotter than that - mid 80's to 90, or a little more if in full burn. After adjusting accordingly, the laptop stays at full performance more often until actual dangerous temperatures are hit.

----------

## [n00b@localhost]

 *jrittenh wrote:*   

> What kernel are you running?  I have a T61p that had similar issues.  It regularly overheats.  When running 2.6.29-r5, it was stuck at 800MHz, no matter what I did.  The note at the top of the ThinkWiki page (http://www.thinkwiki.org/wiki/Problem_with_CPU_frequency_scaling) says that if it's stuck, there's probably a reason.

 

VERY interesting link - thanks!

Having read that I failed to mention that I'm usually running my laptop without the battery in when compiling as drawing a large amount power from the battery over a long time as it's charging causes it to lose the ability to charge faster than normal.  I just checked my power supply and I have the 90W model so it would appear it doesn't matter anyway (if it's being detected properly by the laptop - is there a way to tell?).  I've not checked what I've got the BIOS thermal management set to but I'm pretty sure it's "Performance".  I also have "processor.ignore_ppc=1" and "processor.ignore_tpc=1" on the kernel command line.

I'm running tuxonice-sources.  Usually the latest version available from portage as I update quite often.

EDIT:  I've also tested my laptop with the battery in and the frequency scaling still jumps to an unspecified (and sometimes invalid - i.e. min=1.6GHz, max=2.0GHz, current=800MHz) range after a certain amount of time.

----------

