# Problems with dynamic frequenty cpufreq

## Dikkiedik

Problem: My cpu switched frequency, but switched back to max right after.

Only userspace governor is active, so no other governors.

How can I fix this?

CPU info:

Hyperthreading is active.

```

localhost linux # cat /proc/cpuinfo

processor       : 0

vendor_id       : GenuineIntel

cpu family      : 15

model           : 2

model name      : Intel(R) Pentium(R) 4 CPU 3.06GHz

stepping        : 7

cpu MHz         : 3054.446

cache size      : 512 KB

physical id     : 0

siblings        : 2

core id         : 0

cpu cores       : 1

fdiv_bug        : no

hlt_bug         : no

f00f_bug        : no

coma_bug        : no

fpu             : yes

fpu_exception   : yes

cpuid level     : 2

wp              : yes

flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid xtpr

bogomips        : 6111.73

processor       : 1

vendor_id       : GenuineIntel

cpu family      : 15

model           : 2

model name      : Intel(R) Pentium(R) 4 CPU 3.06GHz

stepping        : 7

cpu MHz         : 3054.446

cache size      : 512 KB

physical id     : 0

siblings        : 2

core id         : 0

cpu cores       : 1

fdiv_bug        : no

hlt_bug         : no

f00f_bug        : no

coma_bug        : no

fpu             : yes

fpu_exception   : yes

cpuid level     : 2

wp              : yes

flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid xtpr

bogomips        : 6107.78

```

cpufreq-info :

```

localhost linux # cpufreq-info

cpufrequtils 0.3: cpufreq-info (C) Dominik Brodowski 2004

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

analyzing CPU 0:

  driver: p4-clockmod

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

  hardware limits: 383 MHz - 3.07 GHz

  available frequency steps: 383 MHz, 767 MHz, 1.15 GHz, 1.53 GHz, 1.92 GHz, 2.30 GHz, 2.68 GHz, 3.07 GHz

  available cpufreq governors: userspace

  current policy: frequency should be within 2.02 GHz and 3.07 GHz.

                  The governor "userspace" may decide which speed to use

                  within this range.

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

analyzing CPU 1:

  driver: p4-clockmod

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

  hardware limits: 383 MHz - 3.07 GHz

  available frequency steps: 383 MHz, 767 MHz, 1.15 GHz, 1.53 GHz, 1.92 GHz, 2.30 GHz, 2.68 GHz, 3.07 GHz

  available cpufreq governors: userspace

  current policy: frequency should be within 2.02 GHz and 3.07 GHz.

                  The governor "userspace" may decide which speed to use

                  within this range.

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

```

----------

## dmsnell

you can compile in support for the other governers in the kernel-config.  "On-demand" I find lets me control the frequency a little better.

if you have powersave and performance, you can adjust high or low frequency with these commands.

```

cpufreq-set -g powersave

cpufreq-set -g performance

```

my cpu only has 1.8Ghz and 1.0Ghz steps, so it's not a problem.  If your steps in different increments, try the conservative governer.

----------

## Dikkiedik

```

'ondemand' - This driver adds a dynamic cpufreq policy governor.                                     

  │ The governor does a periodic polling and                                                             

  │ changes frequency based on the CPU utilization.                                                      

  │ The support for this governor depends on CPU capability to                                           

  │ do fast frequency switching (i.e, very low latency frequency                                         

  │ transitions).                                                                                       

  │                                                                                                      

  │ For details, take a look at linux/Documentation/cpu-freq.                                            

  │                                                                                                      

  │ If in doubt, say N.  

```

What I want to do is set the frequency myself. I don't want a governor telling the cpu what to do and what not to.

For example, when I compile large packages, like kde-base or kde-libs or anything, I don't want the cpu of my laptop

to get 75oC, that's just 2 much. Instead, I want to tell the cpu to run at, 1.53ghz for example, which is half of what

it can do. If I do that, compile time will increase (which I don't care about) but my cpu doens't get above 60oC, which

is a perfect temperature.

The ondemand governor doesn't allow that, the userspace governor does, which I have enabled.

But still it's switching back to the max available frequency, even if I tell cpufreq the highest available is 1.53ghz.

it doesn't matter wheter cpufreqd is active or not.

----------

## Dikkiedik

Kernel specs:

```

[*] CPU Frequency scaling                                                         

  │ │                [ ]   Enable CPUfreq debugging                                                  

  │ │                <*>   CPU frequency translation statistics                                        

  │ │                [ ]     CPU frequency translation statistics details                              

  │ │                      Default CPUFreq governor (userspace)  --->                                  

  │ │                < >   'performance' governor                                                     

  │ │                < >   'powersave' governor                                                        

  │ │                ---   'userspace' governor for userspace frequency scaling                        

  │ │                < >   'ondemand' cpufreq policy governor                                          

  │ │                < >   'conservative' cpufreq governor                                            

  │ │                ---   CPUFreq processor drivers                                                   

  │ │                <*>   ACPI Processor P-States driver                                              

  │ │                < >   AMD Mobile K6-2/K6-3 PowerNow!                                              

  │ │                < >   AMD Mobile Athlon/Duron PowerNow!                                          

  │ │                < >   AMD Opteron/Athlon64 PowerNow!                                              

  │ │                < >   Cyrix MediaGX/NatSemi Geode Suspend Modulation                              

  │ │                <M>   Intel Enhanced SpeedStep                                                    

  │ │                [*]     Use ACPI tables to decode valid frequency/voltage pairs                  

  │ │                [*]     Built-in tables for Banias CPUs                                           

  │ │                <M>   Intel Speedstep on ICH-M chipsets (ioport interface)                        

  │ │                <M>   Intel SpeedStep on 440BX/ZX/MX chipsets (SMI interface)                     

  │ │                <*>   Intel Pentium 4 clock modulation                                            

  │ │                <M>   nVidia nForce2 FSB changing                                                 

  │ │                < >   Transmeta LongRun                                                           

  │ │                < >   VIA Cyrix III Longhaul                                                     

  │ │                ---   shared options                                                              

  │ │                [ ]   /proc/acpi/processor/../performance interface (deprecated)                  

  │ │                [ ]   Relaxed speedstep capability checks

```

Edit: Just disabled the banias thingey ^^ it's of no use. lol

----------

## dmsnell

when you

```

cpufreq-set -f 1.53g

cpufreq-info

```

does it report 1.53Ghz or does it immediately return 3Ghz?  Your processor might not be able to step to the intermediate frequency.

----------

## dmsnell

just noticed that the gnome cpufreq applet keeps the speed constant.  you can try looking for daemons or applets that do the same if that helps you

----------

## Dikkiedik

When I change the frequency it stays on 1.53 just for a little time,

then it immediatly goes back to 3.07 ghz.

I don't know what deamons or applets for KDE there are, does anybody know.

----------

## Dikkiedik

I'm a bit lost now because sometimes the cpu frequency stays as I put it with cpufreq-set and cpufreq-info,

but cat /proc/cpuinfo never tells me the frequency cpufreq-info tells me.

cat /proc/cpuinfo always tells me the the cpu is running at 3054.459 mhz.

Does this matter??

I really don't know what to believe anymore.

----------

## dmsnell

/proc/cpuinfo reports the processor speed, but not the current running speed

----------

## jasm

 *dmsnell wrote:*   

> /proc/cpuinfo reports the processor speed, but not the current running speed

 

That is not according to my experience. But you easily check this for your system by doing the following experiment (assuming your system is idle for a little while):

1- Start the following command in a console 'watch -d cat /proc/cpuinfo'. 'watch -d' starts 'cat /proc/cpuinfo' every 2 seconds and shows the differences in reverse video.

2- Start some CPU intensive task and keep an eye on the output on the previous console

On my system, a pentium-m, I can clearly see changing values for the "cpu MHz" and the "bogomips" fields.

Jan

----------

## curtis119

Read this and install one of the frequency daemons. I suggest cpufreqd, it should do what you want.

----------

## Deadman

What kind of P4 do you have exactly ?

Because it seems that the driver in use is p4-clockmod, which is intended to be used with older P4s that didn't have speedstep (it works well with my Northwood 2GHz).

Maybe you should disable it in your kernel...

----------

