# Gentoo and i7 sandy bridge with turbo boost

## kbzium

Hello,

my cpu is i7 2600 3.4GHz stock, max 4.2Ghz with turbo boost (4.2GHz - 1core, 4.0 2cores, 3.9-all cores).

cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq

returns 3401000

Does it mean that my cpu run at that speed or, what i think is right, that gentoo only reports that turbo boost was on (that 1) and i cannot determine real frequency. I'm asking to be sure, that I'm getting all that i can from this rig. 

Thanks!

----------

## gentoo_ram

I'm not sure you can directly see the turbo boost numbers.  Do you have the CPU frequency stuff turned on in the kernel?  If so, you can get information for each "CPU" in the system.

```

$ cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state

3401000 1870423

3400000 24155

3300000 17158

3200000 17398

3100000 21504

3000000 15002

2900000 19560

2800000 14144

2700000 15769

2600000 12017

2500000 12041

2400000 15470

2300000 12035

2200000 14898

2100000 67065

1600000 72200830

```

That's on my 'Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz'.  Notice there's a "3401000" entry and a "3400000" entry.  I'm assuming the first one means "greater than 3.4GHz" which would imply the turbo boost.

The first column is the frequency and the second column is the number of ticks in each clock state.

----------

## kbzium

Ok, so let's assume that turbo boost works fine. But: what about processor states? Do idling cores turn off preventing heat & power consumption? Again, how to check it?

----------

## megaflow

the app app-benchmarks/i7z will give u good info

----------

## kimmie

sys-power/powertop will tell you as well (the 2.0 version will give you more info)

----------

## kbzium

 *Quote:*   

> Cn                Avg residency       P-states (frequencies)
> 
> C0 (cpu running)        ( 0.6%)
> 
> polling           0.0ms ( 0.0%)
> ...

 

It also suggest me some things. Should I do it?

Suggestion: Enable the CONFIG_SND_AC97_POWER_SAVE kernel configuration option.

This option will automatically power down your sound codec when not in use,

and can save approximately half a Watt of power.

 Q - Quit   R - Refresh  

No detailed statistics available; please enable the CONFIG_TIMER_STATS kernel option

This option is located in the Kernel Debugging section of menuconfig

(which is CONFIG_DEBUG_KERNEL=y in the config file)

Note: this is only available in 2.6.21 and later kernels

Wakeups-from-idle per second : 343.9    interval: 15.0s (so many?)

i7z tells me that 

"True frequency (without accounting TUrbo) is 3400Mhz. So it means that turbo is on i think.

But I don't think it's detailed info because:

 *Quote:*   

> i7z DEBUG: i7z version: svn-r77-(20-Nov-2011)
> 
> i7z DEBUG: Found Intel Processor
> 
> i7z DEBUG:    Stepping 7
> ...

 

Wakeups-from-idle per second : 783.0    interval: 15.0s

It's red. I think it's bad. My governor is "ondemand" in both fields (i think one was present in processor tab, the other on the bottom of general menuconfig). How to lower that thing?

----------

## kimmie

Enabling AC97 power saving will probably save power, the downside is that some apps may not wake the hardware correctly (in which case you'll get no sound). Also, depending on your hardware, you might get annoying loud clicks when the hardware wakes. The only way to know is to give it a try.

If you want detailed stats from powertop, enable the CONFIG options it suggests. It won't hurt. Also, it looks like you're running powertop 1.0? Try 2.0 (it's in testing but it should work fine on a stable system).

I don't know i7z, but it seems to be complaining it can't access model specific registers. Try enabling the CONFIG_X86_MSR for your kernel (it's in processor type and features).

----------

## kbzium

Weird, but the system doesn't seem to use more thatn 25% of cpu power anytime, even during kernel compilation: is there any benchmark that could prove me wrong? Maybe haven? I downloaded haven.run but i don't really know how to run it... permission denied always.

----------

## kimmie

kernel compilation won't use > 1 processor unless you tell it to.. try using "make -j8" to build the kernel.

Same goes for portage, good settings to maximise your machine usage for emerge in make.conf are:

```
EMERGE_DEFAULT_OPTS="--jobs=3"

MAKEOPTS="-j9 -l8"
```

The --jobs==3 tells portage to emerge up to three packages in parallel. This is good because only the compilation stage of an emerge can use more than one processor. The MAKEOPTS allow the compilation stage of each emerge to run up to 9 tasks in parallel, but not to start new tasks if the load average is above 8. That last is important because it prevents parallel emerges from thrashing the system.. you'll only get about 8 make processes total, instead of 3 * 9 = 27.

BTW 300 wakeups/sec is normal for an active i7 desktop. If you want to see what's causing the wakeups, you need to build your kernel with timerstats.

----------

## kbzium

It seems i've made it already. But are the other settings okay? It's really slow.

/etc/make.conf

```
# These settings were set by the catalyst build script that automatically

# built this stage.

# Please consult /usr/share/portage/config/make.conf.example for a more

# detailed example.

CFLAGS="-march=native -O2 -pipe"

CXXFLAGS="${CFLAGS}"

# WARNING: Changing your CHOST is not something that should be done lightly.

# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.

CHOST="x86_64-pc-linux-gnu"

# These are the USE flags that were used in addition to what is provided by the

# profile used for building.

USE="-gtk -gnome gt4 kde dvd alsa cdr mmx sse sse2

consolekit dbus policykit udev"

EMERGE_DEFAULT_OPTS="--jobs 8 --load-average 16"

MAKEOPTS="-j9 -l16"

PORT_LOGDIR="var/log/portage"

CLEAN_DELAY="2"

PORTAGE_NICENESS="19"

PORTAGE_IONICE_COMMAND="ionice -c 3 -p \${PID}"

SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"

AUTOCLEAN="yes"

INPUT_DEVICES="evdev keyboard mouse"

VIDEO_CARDS="nvidia"

LINGUAS="pl en_US"

```

And /etc/portage/make.conf

```
## These settings were set by the catalyst build script that automatically

# built this stage.

# Please consult /usr/share/portage/config/make.conf.example for a more

# detailed example.

CFLAGS="-march=native -O2 -pipe"

CXXFLAGS="${CFLAGS}"

# WARNING: Changing your CHOST is not something that should be done lightly.

# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.

CHOST="x86_64-pc-linux-gnu"

# These are the USE flags that were used in addition to what is provided by the

# profile used for building.

USE="-gtk -gnome gt4 kde dvd alsa cdr mmx sse sse2"

EMERGE_DEFAULT_OPTS="--jobs 8 --load-average 16"

MAKEOPTS="-j9 -l16"

PORT_LOGDIR="var/log/portage"

CLEAN_DELAY="2"

PORTAGE_NICENESS="19"

PORTAGE_IONICE_COMMAND="ionice -c 3 -p \${PID}"

SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"

AUTOCLEAN="yes"

VIDEO_CARDS="nouveau"

INPUT_DEVICES="evdev keyboard mouse"

```

 Does this wakeups wear cpu's somehow? Or it's just energy-related? Do you happen to know how many wakeups does windows 7 (sorry  :Smile:  ) make? One more thing: what about voltages? How to check if cpu voltage is reduced when idle? This powertop should show me that too, yes? But I have misconfigured my kernel so it can't do that now i guess.

----------

## kimmie

 *kbzium wrote:*   

> It seems i've made it already. But are the other settings okay? It's really slow.

 

"It's really slow" is not an easy description to work with. A 3.4GHz core i7 is anything but slow, it's a beast. Maybe your expectations are a bit out of whack, compiling takes time. Compiling big packages takes quite a lot of time. But:

Having --load-average 16 will only slow things down. You only have 8 cores. You are letting make run twice as many processes as you have cores available to service them. You are reducing throughput this way. 

Having ionice -c 3 is only letting portage do disk IO when there has been no other IO for a grace period. Really not at all what you want, if you want portage to go faster. Get rid of the ionice setting altogether, the kernel manages io priority by itself just fine.

Having portage niceness at 19 gives portage processes the lowest possible priority. 5 would be more reasonable, if you just want it not to impact too much on your desktop.

 *Quote:*   

> Does this wakeups wear cpu's somehow? Or it's just energy-related? Do you happen to know how many wakeups does windows 7 (sorry  ) make? One more thing: what about voltages? How to check if cpu voltage is reduced when idle? This powertop should show me that too, yes? But I have misconfigured my kernel so it can't do that now i guess.

 

In practice you can't wear a CPU unless you overtweak it into toast. Minimising wakeups is about saving power. If you're not running off a battery, it's not all that important. Your numbers are fine, anyway. It is completely pointless to try to compare windows and linux in terms of wakeups/sec.

You haven't misconfigured your kernel, it's just that powertop needs special settings. I don't know about reduced voltages, I have a pre-sandybridge i7 myself.

----------

## JanR

Hi,

first: Intel CPUs offer Turbo boost hidden as the highest P-State. In your case 3400 (I leave out the remaining 3 Zeros in this post) is 3.4 GHz - your default frequency in no-turbo-mode. All lower frequencies are the lower P-states. The remaining one is max+1 MHz, in your case 3401. This is "enable turbo". It does NOT tell you a which frequency it will run but it enables turbo and let the hardware decide. 

By selecting this p-state you enable turbo (which seems to be the case for you).

Second: There is a tool called "turbostat" hidden in the tools-directory of the Linux kernel. Build this and you will see detailled statistics on turbo (updated every 10 s). Let it run and start load with different degrees of parallelism - you will see the individual states. Keep in mind that the highest state is only selected if really nothing else is running - this is nearly never the case with modern GUIs. Disable X and try it on console - this will give you much higher boost.

As your CPU seems to be overclocked (normal max turbo state for 2600K is 3.8 GHz, not 4.2) I'm not sure what turbostat will show.

Third: There is a great utility called "mhz" belonging to the very old "lmbench" (dropped from portage years ago but you can just download and build it). This one does not try to read some MSR etc. but runs a test that quite successful figures out the real frequency of the CPU. From my experience, it worked on every machine I tried (except P4 Northwood, here you get two times the frequency which is not that wrong as Northwood runs the ALU at that speed). On a multi-core system, it is better to taskset it to one core.

Example:

```

taskset -c 0 mhz

3603 MHz, 0.2775 nanosec clock

```

This is full single core turbo on my Xeon X3470.

Greetings,

Jan

----------

## kbzium

Thank you, you made it a lot clearer. But what about voltages? Does it also let processor (or bios) decide? I don't want my i7 running at 1.2V at 1600MHz, cause it normally runs at 0.9V then. That would be my last concern, if my "wakeups-per-second" are good too.

Moreover, do you happen to know what kernel options should I enable in order to fully monitor my CPU yet not let it be destroyed anyhow? Now i cannot display detailed things like temperature and so on.

// edit:

Kernel compilation still uses only 1 tread/core. up to 15%... Any ideas? I've changed those two options.

----------

## JanR

Hi,

 *Quote:*   

> 
> 
> But what about voltages? Does it also let processor (or bios) decide? I don't want my i7 running at 1.2V at 1600MHz, cause it normally runs at 0.9V then.
> 
> 

 

As long as you don't mess with some strange kernel patches or play with the MSR on your own, the CPU will do it on your own. Changing voltage in BIOS, however, MAY influence the way the hardware control works (but this applies to any OS, not just Linux).

And: Don't look at frequency! Even if permanently set to full frequency, the CPU will enter C6 (if enabled) and completely turn off the cores. In this case, frequency and voltage do not matter.

Look at the C6 columns of turbo-stat. In case of an completely idle system, all cores should spend most of the time in  C6.

 *Quote:*   

> 
> 
> Moreover, do you happen to know what kernel options should I enable in order to fully monitor my CPU yet not let it be destroyed anyhow? Now i cannot display detailed things like temperature and so on.
> 
> 

 

Emerge the lm_sensors package. In order to support all that, you need the appropriate sensor for Intel CPUs (if I remember correctly, it is called "CORETEMP" - you find that in the hardware monitoring section of device drivers in the kernel configuration). If you enable that (and load the module, if build as module) "sensors" will read the internal sensors of the CPU. These values will be significantly higher than the values reported by the (external to CPU) sensors of the mainboard. For your CPU, everything up to the lower 80s (celsius) should be okay for high load. Second, for reading voltage and temperature sensors of mainboard you need the right sensor modules for YOUR board. Best is here to try or to google for lm_sensors and your board. Please keep in mind that these values may not be correct.

 *Quote:*   

> 
> 
> Kernel compilation still uses only 1 tread/core. up to 15%... Any ideas? I've changed those two options.
> 
> 

 

Are you sure that you know how to compile a kernel?

Make clear that the kernel source is not yet compiled ("make clean" will erase everything leftover from last run), make sure, that all cores are enabled in Linux (count the output blocks of "cat /proc/cpuinfo) and run make with the right parameter. In your case, "make -j16" should do, minimum should be 8. That will give you full load for at least one minute on all cores if you have a rather minimalistic configuration.

Greetings,

Jan

----------

