# cpufreqd and multiple processors

## NathanZachary

Hello all,

I'm still battling some aspects of power management with my NC10.  In the CPU portion of the Power Management Guide, it shows how to set up the dynamic changing of processor frequencies using cpufreqd.  I am fine with everything mentioned there, but I don't know what steps need to be done in order to account for the 2 CPUs that are seen because of the hyperthreading of the Atom N270.  Are there modifications to be made given that both the CPUs will need to be changed at the same time?

Thank you preemptively.  :Smile: 

----------

## NeddySeagoon

kalos,

You only have a single CPU. Hyperthreading is a logical trick to try to stop long pipelines stalling.

You only have a single CPU clock to set.

----------

## disi

Even the dual core cannot change the speed for a single cpu, they need to run at the same speed. This should be working with a board that has 2+ sockets.

----------

## gentoo_ram

That's not quite true.  I have a quad-core AMD Phenom(tm) 9850.  Using the kernel on-demand governor, the kernel can control the clock rate of each core independently.  I agree that hyper-threaded probably can't control each virtual core independently.

As for the O.P., why do you want to use a user-space solution?  I use the in-kernel on-demand governor and it works great on my processors.

----------

## disi

I am not at my desktop right now. If I run cpufreq-info it tells something like "have to run at same speed" with an AMD X2 4600+.

Probably I missed some option, I never really tried to investigate...   :Very Happy: 

//edit: yahooed it:

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

----------

## NathanZachary

Hmmmmmmmm,

Whenever I use cpufreq-info, I get the following output:

```

$ 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

  hardware limits: 800 MHz - 1.60 GHz

  available frequency steps: 1.60 GHz, 1.33 GHz, 1.07 GHz, 800 MHz

  available cpufreq governors: conservative, powersave, userspace, performance

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

                  The governor "userspace" may decide which speed to use

                  within this range.

  current CPU frequency is 1.60 GHz.

analyzing CPU 1:

  driver: acpi-cpufreq

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

  hardware limits: 800 MHz - 1.60 GHz

  available frequency steps: 1.60 GHz, 1.33 GHz, 1.07 GHz, 800 MHz

  available cpufreq governors: conservative, powersave, userspace, performance

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

                  The governor "userspace" may decide which speed to use

                  within this range.

  current CPU frequency is 1.60 GHz.

```

I can manually set both of them, and they will both say different CPU frequencies.  I just want to make sure that everything is fine with dynamically setting my CPU frequencies.  I've never done any type of power management on this laptop with Gentoo until now.  I still haven't even figured out how to decrease the screen brightness automatically using xbacklight when switching to the battery runlevel.   :Embarassed: 

Thanks again for the help.  :Smile: 

----------

## NathanZachary

 *gentoo_ram wrote:*   

> That's not quite true.  I have a quad-core AMD Phenom(tm) 9850.  Using the kernel on-demand governor, the kernel can control the clock rate of each core independently.  I agree that hyper-threaded probably can't control each virtual core independently.
> 
> As for the O.P., why do you want to use a user-space solution?  I use the in-kernel on-demand governor and it works great on my processors.

 

According to the Power Management Guide, just having the kernel CPU scaling driver doesn't do anything unless a daemon like cpufreqd is installed to dynamically switch between the governors.

----------

## gentoo_ram

 *Quote:*   

> According to the Power Management Guide, just having the kernel CPU scaling driver doesn't do anything unless a daemon like cpufreqd is installed to dynamically switch between the governors.

 

You don't need a userspace anything to switch between the governors.  I have this in my /etc/conf.d/local.start:

```
echo 'ondemand' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

echo 'ondemand' > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor

echo 'ondemand' > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor

echo 'ondemand' > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor

```

That will set the governor to ondemand on all processors.  I guess what the userspace thing would gain you is being able to switch between different governors with different ACPI events (like on-battery, etc.)  But the kernel driver is still doing all the real work.  In my case, this machine is an always-on server so I don't need anything complicated.

----------

## NathanZachary

Ah, I understand.  Thanks for the information, and I will certainly remember that if I have a similar machine and would like that setup.  :Smile: 

----------

## Naib

 *gentoo_ram wrote:*   

>  *Quote:*   According to the Power Management Guide, just having the kernel CPU scaling driver doesn't do anything unless a daemon like cpufreqd is installed to dynamically switch between the governors. 
> 
> You don't need a userspace anything to switch between the governors.  I have this in my /etc/conf.d/local.start:
> 
> ```
> ...

 

```

for i in /sys/devices/system/cpu/cpu?; do echo 'ondemand' > "$i/cpufreq/scaling_governor"; done
```

----------

## overkll

I don't think Power management howto is relevent anymore, at least if one uses gnome or kde.  All the power management options are available via desktop environment apps - dimming, suspend on lid close, etc.  On gnome, it's the "Power Manager" package.  The only thing not included in that package is governor scaling, but that can be handled with the gnome desktop applet "CPU Frequency Scaling Monitor".  Just right click on a panel and select "add to panel" then select it.  I have two, one for each core (AMD Turion RM-70, each scales seperately).  

No need to set the scaling in /etc/conf.d/local.start, one can do this in the kernel.  The option in menuconfig is located at "Power Management and ACPI options -> CPU Frequency scaling -> Default CPUFreq governor

```
  │ │    [*] CPU Frequency scaling                                        │ │  

  │ │    [ ]   Enable CPUfreq debugging                                   │ │  

  │ │    <*>   CPU frequency translation statistics                       │ │  

  │ │    [*]     CPU frequency translation statistics details             │ │  

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

  │ │    -*-   'performance' governor                                     │ │  

  │ │    <*>   'powersave' governor                                       │ │  

  │ │    <*>   'userspace' governor for userspace frequency scaling       │ │  

  │ │    <*>   'ondemand' cpufreq policy governor                         │ │  

  │ │    <*>   'conservative' cpufreq governor 
```

I have it set for performance, then when gnome starts, it's set to adjust to "Ondemand" with the cpu freq panel applet.  Works fine.

EDIT:  Forgot to mention, sys-power/acpid is still required and should be added to default runlevel.  Also gnome-base/gnome-applets-2.24.3.1 contains a command line app "/usr/bin/cpufreq-selector" if you want to use the command line.

----------

## NathanZachary

The Power Management Guide might not be necessary anymore when using a larger DE, but it still has some very valid points if using a minimalistic environment like Openbox.  :Smile: 

----------

## bekkra

Hm, at least by topic, my problem is somewhat related.

I use a Q6700 on 2.6.28-r5 x64 and no matter how I try, I cannot get the /sys/devices/system/cpu/cpuX/cpufreq entries at all.

cpufreqd never starts, saying:

```
* cpufreqd requires the kernel to be configured with CONFIG_CPU_FREQ

* Make sure that the appropiate drivers for your CPU are available.
```

Quite expectedly, cpufreq-info says

```
no or unknown cpufreq driver is active on this CPU
```

 for all the cores. Yet, the config seems to have the necessary entries:

```

#

# CPU Frequency scaling

#

CONFIG_CPU_FREQ=y

CONFIG_CPU_FREQ_TABLE=y

CONFIG_CPU_FREQ_DEBUG=y

CONFIG_CPU_FREQ_STAT=y

CONFIG_CPU_FREQ_STAT_DETAILS=y

# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set

# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set

# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set

CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y

# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set

CONFIG_CPU_FREQ_GOV_PERFORMANCE=y

# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set

CONFIG_CPU_FREQ_GOV_USERSPACE=y

CONFIG_CPU_FREQ_GOV_ONDEMAND=y

# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set

#

# CPUFreq processor drivers

#

CONFIG_X86_ACPI_CPUFREQ=m

# CONFIG_X86_POWERNOW_K8 is not set

# CONFIG_X86_SPEEDSTEP_CENTRINO is not set

# CONFIG_X86_P4_CLOCKMOD is not set

```

Having configured the driver as a module, I have control over when to activate it, so I get:

```
~ # modprobe acpi-cpufreq

FATAL: Error inserting acpi_cpufreq (/lib/modules/2.6.28-gentoo-r5/kernel/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.ko): No such device

```

And since the driver debug option is set, I can see some messages:

```

acpi-cpufreq: acpi_cpufreq_init

acpi-cpufreq: acpi_cpufreq_early_init

acpi-cpufreq: acpi_cpufreq_cpu_init

acpi-cpufreq: acpi_cpufreq_cpu_init

acpi-cpufreq: acpi_cpufreq_cpu_init

acpi-cpufreq: acpi_cpufreq_cpu_init

```

I have been wondering if my CPU is crippled in some way:listing the first core for information

```
~ # cat /proc/cpuinfo

processor       : 0                                                                                                                                   

vendor_id       : GenuineIntel                                                                                                                        

cpu family      : 6                                                                                                                                   

model           : 15                                                                                                                                  

model name      : Intel(R) Core(TM)2 Quad CPU           @ 2.66GHz                                                                                     

stepping        : 7                                                                                                                                   

cpu MHz         : 3205.467                                                                                                                            

cache size      : 4096 KB                                                                                                                             

physical id     : 0                                                                                                                                   

siblings        : 4                                                                                                                                   

core id         : 0                                                                                                                                   

cpu cores       : 4                                                                                                                                   

apicid          : 0                                                                                                                                   

initial apicid  : 0                                                                                                                                   

fpu             : yes                                                                                                                                 

fpu_exception   : yes                                                                                                                                 

cpuid level     : 10                                                                                                                                  

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 syscall nx lm constant_tsc arch_perfmon pebs bts rep_good pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm tpr_shadow                                                                                                       

bogomips        : 6410.93                                                                                                                                                                   

clflush size    : 64                                                                                                                                                                        

cache_alignment : 64                                                                                                                                                                        

address sizes   : 36 bits physical, 48 bits virtual                                                                                                                                         

power management:                                                                                                                                                                           

```

which looks like pretty expected stuff, except for the "power management" entry, which is completely empty.

Since I am totally clueless at this point, I wonder if any of you might have an idea what I should do instead of what I have obviously tried ?

( Yeah, there might be tons of configuration information to post, so I'd rather see some suggestions, before making that 4MB post  :Smile:  )

//

----------

## pigeon768

bekkra: are you sure you recompiled your kernel and copied it to /boot and rebooted? It looks like your kernel config is not consistent with what you're actually running.

I'd also recommend compiling the acpi-cpufreq into the kernel as opposed to a module.

----------

## bekkra

pigeon768:

The config lines were actually from 

```
zcat /proc/config.gz
```

  :Cool: 

I also tested combinations of

acpi-cpufreq in kernel vs in module

default (x10) multiplier vs raised (x14, x :Cool: 

kernel 2.6.28-r5

kernel 2.6.29-r3

While browsing the dmesg output, I also saw two interesting messages:

```
acpid: input layer read error: no 

such device (19)
```

 and also the more telling

```
ACPI: I/O resource 0000:00:1f.3 [0x400-0x41f]  conflicts with ACPI region SMRG[0x400-0x40f]

ACPI: device needs an ACPI driver
```

 which boils down to the (easily Googlable) i801_smbus on my ASUS P5W DH  deluxe motherboard, possibly hinting a BIOS issue on mine and many related motherboards. Googling this (well, more like "ACPI I/O resource conflict with SMBus") gave lots of hits, none exactly an answer to my problems.

The latest experiment I've done was to remove the i801_smbus option from the kernel, and the result is:

...no change.

Actually, now that the SMBUS driver is gone, I get a similar warning about the hardware sensor chip:

```
ACPI: I/O resource w83627ehf [0x295-0x296] conflicts with ACPI region HWRE [0x290-0x299]
```

Something smells in the current ACPI support, and I am totally out of ideas. Still, I don't see that every desktop running a Q series processor in x64 mode runs without cpufreq support. There must be something that I have overlooked. But what ?

//

----------

## DigitalCorpus

I have a Q6700 as well. If you overclock, cpufrequtils becomes unusable. This is expected behavior, but I don't remember why. How did you go up to a x14 multiplier?

----------

## NathanZachary

The last time that I checked, overclocking + gentoo compilations = trouble.  Has this changed?

----------

## DigitalCorpus

Probably because of [slightly] more efficient use of the CPU and it's workings? I've been running a 3.2GHz (apparently 4GHz but I want to bench this to verify) Q6700 w/ 8GB of RAM since December with only 2.75 days of down time because of two crashes and one recovery. One because of filling RAM up and the other because I unplugged what I thought at the time was my monitors cable.

----------

## bekkra

DigitalCorpus:

After some googling, it becomes somewhat clear that cpufreqd uses the default frequency tables for the host CPU. Overcloking gives no matches into that table, which leads to no function. However; as I wrote above, I have run tests with default ( x10 ) multiplier, with no different results. The source of the problem is not "happy hardware hacking at home for better or worse".

I am sorry to dissapoint you, but the CPU is actually a QX6700, an "extreme" edition, which means that the multiplier is unlocked.

The CPU allows multipliers in the inclusive range of [6,20], with 10 as default. 14 was no problem, and I have also run 15, but without cpufreqd support, that is just a total waste of energy, so I run 12 when gaming and default when doing other stuff.

---

It's just that the same motherboard/CPU combination works flawlessly under Vista, and this makes me both curious and frustrated - I want Linux to be the better of the two. As it turns out, it's marginally easier to get information about problems under Linux, no matter its openness - the shere volume of the available information makes it  too difficult to find authorative information for specific problems. Bah, I'll dig further. Currently, I'm inserting diagnostic mesages into the driver to see why it must fail so miserably.

kalos:

No, Gentoo as a distribution exhibits no different behaviour to hardware related problems than other operating systems. Overclocking stresses various parts of the hardware and less stable hardware affects Gentoo just as it affects other software negatively. I have run Gentoo on all my boxes ( currently four, of which two are constantly overclocked ) for the better part of the past five years and I have experienced Gentoo as the best general purpose (ehrm, well, "fully tailorable general purpose", really) OS I can have.

---

Too bad this is Linux, which means lesser hardware support and so much technical information available that you just don't get the time to understand it all.

More ideas, please ?

//

----------

