# cpufreqd issues - Cannot set policy

## mroconnor

I get this message in /var/log/messages about every 2 seconds:

```
Jul 17 12:41:01 cosmo cpufreqd: cpufreqd_loop            : Cannot set policy, Rule unchanged ("AC Rule").

Jul 17 12:41:03 cosmo cpufreqd: cpufreqd_set_profile     : Couldn't set profile "Performance Low" set for cpu0 (1667000-1667000-performance)

Jul 17 12:41:03 cosmo cpufreqd: cpufreqd_loop            : Cannot set policy, Rule unchanged ("AC Rule").

Jul 17 12:41:05 cosmo cpufreqd: cpufreqd_set_profile     : Couldn't set profile "Performance Low" set for cpu0 (1667000-1667000-performance)

Jul 17 12:41:05 cosmo cpufreqd: cpufreqd_loop            : Cannot set policy, Rule unchanged ("AC Rule").

Jul 17 12:41:07 cosmo cpufreqd: cpufreqd_set_profile     : Couldn't set profile "Performance Low" set for cpu0 (1667000-1667000-performance)

Jul 17 12:41:07 cosmo cpufreqd: cpufreqd_loop            : Cannot set policy, Rule unchanged ("AC Rule").

Jul 17 12:41:09 cosmo cpufreqd: cpufreqd_set_profile     : Couldn't set profile "Performance Low" set for cpu0 (1667000-1667000-performance)

Jul 17 12:41:09 cosmo cpufreqd: cpufreqd_loop            : Cannot set policy, Rule unchanged ("AC Rule").

Jul 17 12:41:11 cosmo cpufreqd: cpufreqd_set_profile     : Couldn't set profile "Performance Low" set for cpu0 (1667000-1667000-performance)

Jul 17 12:41:11 cosmo cpufreqd: cpufreqd_loop            : Cannot set policy, Rule unchanged ("AC Rule").

Jul 17 12:41:13 cosmo cpufreqd: cpufreqd_set_profile     : Couldn't set profile "Performance Low" set for cpu0 (1667000-1667000-performance)

```

What would cause that? I have all the governors in the kernel, I assume it is something in the config? Thanks for the assistance.

----------

## avieth

Are you sure that your CPU supports frequency scaling?

----------

## mroconnor

```
mroconnor@cosmo ~ $ uname -p

Intel(R) Core(TM)2 CPU T7200 @ 2.00GHz
```

It just never goes past 1.0+Ghz anymore.   :Confused: 

----------

## avieth

Did you check out this guide?

You should have ACPI drivers, particularly the "ACPI Processor P-States driver" which supports the Intel Core 2 Duo. 

Also, check if you have this directory:

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

----------

## mroconnor

Yes I have done that and definitly have that directory. It seems that doing this:

```

 cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
```

Always returns a value of 200000 when on AC and 1000000 when on battery. Nothing in between. Funny enough conky reads values of 1221687684560.00Ghz for cpu0/1.

```
cosmo coretemp.0 # cpufreq-info 

cpufrequtils 002: cpufreq-info (C) Dominik Brodowski 2004-2006

Report errors and bugs to linux@brodo.de, please.

analyzing CPU 0:

  driver: acpi-cpufreq

  CPUs which need to switch frequency at the same time: 0 1

  hardware limits: 1000 MHz - 2.00 GHz

  available frequency steps: 2.00 GHz, 1.67 GHz, 1.33 GHz, 1000 MHz

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

  current policy: frequency should be within 2.00 GHz and 2.00 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).

analyzing CPU 1:

  driver: acpi-cpufreq

  CPUs which need to switch frequency at the same time: 0 1

  hardware limits: 1000 MHz - 2.00 GHz

  available frequency steps: 2.00 GHz, 1.67 GHz, 1.33 GHz, 1000 MHz

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

  current policy: frequency should be within 2.00 GHz and 2.00 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).

```

----------

## dark_knight

I have encountered the same problem, and probably other people too...

https://forums.gentoo.org/viewtopic-t-684833-highlight-cpufreqd.html

https://forums.gentoo.org/viewtopic-t-698691-highlight-cpufreqd.html

The only explanation that I've found so far is this one: with kernel 2.6.25, part of the frequency scaling handling was rewritten, adding some extra "features". One of these (this is an assumption of mine, I've not googled for it neither grepped the sources) is to avoid an inconsistent setting of the frequencies: the currently allowed minimum frequency, obviously, cannot be higher than the maximum one, so a script like this one should fail:

```
darkplace dark # cd /sys/devices/system/cpu/cpu0/cpufreq/

darkplace cpufreq # cat scaling_available_frequencies 

1600000 1400000 1200000 1000000 800000 600000 

darkplace cpufreq # cat scaling_governor scaling_max_freq scaling_min_freq

ondemand

1400000

600000

darkplace cpufreq # echo 1600000 > scaling_min_freq 

bash: echo: write error: Invalid argument

darkplace cpufreq # cat scaling_governor scaling_max_freq scaling_min_freq

ondemand

1400000

600000
```

Indeed, it fails, and I don't recall seeing those failures before 2.6.25.

Probably cpufreqd (whose last release is dated 30 Nov 2006) does not follow the right order of operations when setting the minimum and maximum frequencies via sysfs, thus failing in changing the rule.

EDIT: Yes, my assumptions were correct. I investigated the issue and found that the incorrect code resides in the package sys-power/cpufrequtils, that handles policy change within the function sysfs_set_policy. A new version of cpufrequtils that solves the issue has been released (check version 004 @ http://www.kernel.org/pub/linux/utils/kernel/cpufreq/cpufrequtils.html ), but it is not in portage yet.

----------

## mroconnor

@dark_knight: Thanks for the info, I can now stop emerging, re-emerging and triple check configs looking for where I went wrong. 

/me waits for portage tree updates.

----------

## Abraxas

No need to wait for portage updates.  Just copy the existing ebuild into an overlay and rename it to the latest version.  You have to delete the "epatch" line because the patch doesn't work with the latest version but after that everything is working fine for me now.

----------

## mroconnor

@Abraxas:Thanks for the help, I'll do that today. 

Not sure if you use conky but does this help conky display the correct CPU speed?

Thanks again.

----------

## Abraxas

 *mroconnor wrote:*   

> @Abraxas:Thanks for the help, I'll do that today. 
> 
> Not sure if you use conky but does this help conky display the correct CPU speed?
> 
> Thanks again.

 

I started using conky about six months ago and haven't had a problem with displaying the correct CPU speed.

----------

