# CPU freq while emerging

## HermanR

I just finished installing Gentoo on my new AMD64 3200+ machine. Works like a charm, no problems that I can't handle. (Hehe,  :Smile:  ) But...

I've got the powersave thing working with the ondemand governor. My CPU normally runs at 1 GHz, but when there's work to be done, it goes up to 2 GHz (and back again after it's finished, of course). I've got a sensor for it in my SuperKaramba-theme so I can follow what's happening. So far, so good.

Whenever I do an emerge, however, the CPU speed just stays at 1 GHz. I guess that has to do with the nice-level or something, but I would like to have my full CPU speed set automatically. (Of course, I know I can set the governor to something else, like performance.)

Can anyone explain why this happens? And/or does anyone have a solution/workaround?

Thanks!

----------

## wuzzerd

Do you have the ondemand govenor installed in you kernel?

----------

## HermanR

Yes, the ondemand governor is installed and is working. When I fire up glxgears, for example, the CPU goes up to 2 GHz, but not when I emerge something.

----------

## Master One

I just discovered the same behaviour on one of my servers. It's a P4 2.4, on which I ran the ondemand govenor ever since without any problem. On low workload it just goes down to 300 MHz, but I just discovered, that something must have changed, because it simply stays at 300 MHz independently of the load, which I just checked during an emerge.

I am not quite sure, what may have changed, but I recently upgraded that machine from gentoo-sources-2.6.12-r9 to gentoo-sources-2.6.12-r10, so maybe a bug in the ondemand governor has been introduced?

----------

## toralf

```
tfoerste@n22 ~ $ grep NICE /etc/make.conf

PORTAGE_NICENESS="3"

```

?

----------

## Coogee

If you have set PORTAGE_NICENESS in /etc/make.conf to any value > 0, you also have to put the line

"echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice" into /etc/conf.d/local.start.

This line forces the ONDEMAND governor to take the "niced" processes also into account.

----------

## Master One

Ok, some further investigation showed, that the ondemand govenor generally seems to be working (at least it jumps shorly to the max freq, then drops down to 300 MHz, when I start an emerge, I also saw it go up to 600 MHz one time).

So I assume it really has something to do with the NICE setting, but I am not quite sure how it works. PORTAGE_NICENESS is set to "3" by standard (just checked on all my machines, but I am not quite sure where this setting comes from, because I am using the same make.conf base-file for a pretty long time now), but the comment in /etc/make.conf is not quite clear:

```
# PORTAGE_NICENESS provides a default increment to emerge's niceness level.

#     Note: This is an increment. Running emerge in a niced environment will

#     reduce it further. Default is unset.

PORTAGE_NICENESS=3
```

When I enter "nice" in a console, it returns the value "0". From the nice-manpage I know, that the range is -20 (highest prior) to +19 (lowest prior).

So what does me "PORTAGE_NICENESS=3" really tell then?

How comes, that setting is not influencing the ondemand govenor on one machine (leaves my server at 300 MHz), but kicks in as expected on another machine (my notebook with a P-M 1.8, toggles between 600 MHz and 1800 MHz depending on load, as it should be)?

What would be a reasonable PORTAGE_NICENESS setting, so that the ondemand governor works properly?

One other thing: I just saw, that mldonkey has a niceness setting in its config-file as well:

```
# nice level, 0<x<19, more nice -> less cpuspeed consumed

NICE="19"
```

How comes, the comment tells a range from 0 to 19?

Running it with NICE=19 may be the cause, why I have some problems with it lately (core often dies without feedback, no connect using the webgui during an emerge,...).

Any suggestion for a reasonable NICE setting for mldonkey?

P.S. I know this is a little OT, but it seems indeed to be related to having the ondemand govenor not working properly on that machine.

----------

## Master One

 *Coogee wrote:*   

> If you have set PORTAGE_NICENESS in /etc/make.conf to any value > 0, you also have to put the line
> 
> "echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice" into /etc/conf.d/local.start.
> 
> This line forces the ONDEMAND governor to take the "niced" processes also into account.

 

Oh, haven't seen your comment during writing my answer. That's quite interesting, I didn't know of this possibility. I don't use local.start or a cpufreq-daemon to control the govenor settings, but I have cpufrequtils installed, which sets the intended governor on boot.

I just tested that setting your recommended, and it is indeed working now!

Thank's a lot, another riddle solved   :Smile: 

I have put that command for ignore_nice in my local.start, I just wonder, why this setting isn't enabled by default...

Nevertheless I am still unsure, why this was only a problem on my server, but not on my notebook (there it also worked without setting ignore_nice to "1" also it has PORTAGE_NICENESS=3 as well).

----------

## Coogee

I think this behaviour of the ONDEMAND governor has changed from kernel 2.6.12 to 2.6.13. Maybe you are using different kernels on your PCs...?

----------

## Master One

No, all my machines run the same kernel (until recently gentoo-sources-2.6.12-r9, and I just upgraded all machines to gentoo-sources-2.6.12-r10 yesterday).

----------

