# Cpu Frequency Scaling - Intel P State

## Spargeltarzan

Hi,

I migrated my notebook to openrc and my cpu frequency scaling isn't working any more.

I have compiled the kernel with Intel P State for the modern cpus and selected the governor "performance", because this is the recommended setting for modern cpu and provides even better scaling than "ondemand". Formerly I was also on this governor.

I have installed laptop-mode-tools and activated the cpufreq.conf.

My frequency is constantly ~3000 Mhz - what could I do more?

Thanks in advance!

----------

## Jaglover

You better add powersave, it will be used by pstates driver to scale down the frequency.

----------

## P.Kosunen

Some kernels CPU Frequency scaling drivers need to be also enabled.

----------

## fedeliallalinea

 *P.Kosunen wrote:*   

> Some kernels CPU Frequency scaling drivers need to be also enabled.

 

If I'm not mistaken p-state ignore this module is the processor that decides what to do

----------

## bunder

I could be wrong about this, but I think most intels only support 'performance' and 'powersave', if you set it to powersave it should go down to around 800mhz.

----------

## P.Kosunen

```
# cat /sys/devices/system/cpu/cpufreq/policy1/scaling_governor

powersave

# cat /sys/devices/system/cpu/cpufreq/policy1/scaling_available_governors

performance powersave
```

Oh yes, remember having same problem with NUCs.

----------

## Spargeltarzan

 *Jaglover wrote:*   

> 
> 
> You better add powersave, it will be used by pstates driver to scale down the frequency.
> 
> 

 

I was thinking opposite, that the machine boots in "performance" and pstate scales done when the CPU is not needed. My thinking was wrong, I compiled the kernel now with default "powersave" and it scales down to ~800 Mhz. When launching firefox for example, it increases to 3000 Mhz again.

Would you support me to optimise my power consumption a bit more, I still feel like it is less battery than formerly with systemd setup (but I guess the init system has not much todo with it).

 *fedeliallalinea wrote:*   

>  *P.Kosunen wrote:*   Some kernels CPU Frequency scaling drivers need to be also enabled. 
> 
> If I'm not mistaken p-state ignore this module is the processor that decides what to do

 

I have attached my kernel .config for CPU scaling and ACPI. For drivers I have X86_INTEL_PSTATE=y and X86_PCC_CPUFREQ=m and the rest no. Am I right here?

Maybe I will need additionally those two for better idle?

# CONFIG_INTEL_IDLE is not set

# CONFIG_CPU_IDLE_GOV_LADDER is not set

```

#

# CPU Frequency scaling

#

CONFIG_CPU_FREQ=y

CONFIG_CPU_FREQ_GOV_ATTR_SET=y

CONFIG_CPU_FREQ_GOV_COMMON=y

CONFIG_CPU_FREQ_STAT=y

# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set

CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE=y

# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set

# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set

# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set

# CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL is not set

CONFIG_CPU_FREQ_GOV_PERFORMANCE=y

CONFIG_CPU_FREQ_GOV_POWERSAVE=y

CONFIG_CPU_FREQ_GOV_USERSPACE=y

CONFIG_CPU_FREQ_GOV_ONDEMAND=y

CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y

CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y

#

# CPU frequency scaling drivers

#

CONFIG_X86_INTEL_PSTATE=y

CONFIG_X86_PCC_CPUFREQ=m

# CONFIG_X86_ACPI_CPUFREQ is not set

# CONFIG_X86_SPEEDSTEP_CENTRINO is not set

# CONFIG_X86_P4_CLOCKMOD is not set

#

# shared options

#

#

# CPU Idle

#

CONFIG_CPU_IDLE=y

# CONFIG_CPU_IDLE_GOV_LADDER is not set

CONFIG_CPU_IDLE_GOV_MENU=y

# CONFIG_INTEL_IDLE is not set

```

Additionally, I have attached my current ACPI settings:

```

#

# Power management and ACPI options

#

CONFIG_ARCH_HIBERNATION_HEADER=y

CONFIG_SUSPEND=y

CONFIG_SUSPEND_FREEZER=y

# CONFIG_SUSPEND_SKIP_SYNC is not set

CONFIG_HIBERNATE_CALLBACKS=y

CONFIG_HIBERNATION=y

CONFIG_PM_STD_PARTITION=""

CONFIG_PM_SLEEP=y

CONFIG_PM_SLEEP_SMP=y

# CONFIG_PM_AUTOSLEEP is not set

# CONFIG_PM_WAKELOCKS is not set

CONFIG_PM=y

CONFIG_PM_DEBUG=y

# CONFIG_PM_ADVANCED_DEBUG is not set

# CONFIG_PM_TEST_SUSPEND is not set

CONFIG_PM_SLEEP_DEBUG=y

CONFIG_PM_TRACE=y

CONFIG_PM_TRACE_RTC=y

CONFIG_PM_CLK=y

# CONFIG_WQ_POWER_EFFICIENT_DEFAULT is not set

CONFIG_ACPI=y

CONFIG_ACPI_LEGACY_TABLES_LOOKUP=y

CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC=y

CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT=y

# CONFIG_ACPI_DEBUGGER is not set

CONFIG_ACPI_SPCR_TABLE=y

CONFIG_ACPI_LPIT=y

CONFIG_ACPI_SLEEP=y

# CONFIG_ACPI_PROCFS_POWER is not set

CONFIG_ACPI_REV_OVERRIDE_POSSIBLE=y

# CONFIG_ACPI_EC_DEBUGFS is not set

CONFIG_ACPI_AC=y

CONFIG_ACPI_BATTERY=y

CONFIG_ACPI_BUTTON=y

CONFIG_ACPI_VIDEO=y

CONFIG_ACPI_FAN=y

# CONFIG_ACPI_TAD is not set

CONFIG_ACPI_DOCK=y

CONFIG_ACPI_CPU_FREQ_PSS=y

CONFIG_ACPI_PROCESSOR_CSTATE=y

CONFIG_ACPI_PROCESSOR_IDLE=y

CONFIG_ACPI_CPPC_LIB=y

CONFIG_ACPI_PROCESSOR=y

CONFIG_ACPI_HOTPLUG_CPU=y

CONFIG_ACPI_PROCESSOR_AGGREGATOR=m

CONFIG_ACPI_THERMAL=y

CONFIG_ACPI_NUMA=y

CONFIG_ARCH_HAS_ACPI_TABLE_UPGRADE=y

CONFIG_ACPI_TABLE_UPGRADE=y

# CONFIG_ACPI_DEBUG is not set

# CONFIG_ACPI_PCI_SLOT is not set

CONFIG_ACPI_CONTAINER=y

CONFIG_ACPI_HOTPLUG_IOAPIC=y

# CONFIG_ACPI_SBS is not set

# CONFIG_ACPI_HED is not set

# CONFIG_ACPI_CUSTOM_METHOD is not set

# CONFIG_ACPI_BGRT is not set

# CONFIG_ACPI_REDUCED_HARDWARE_ONLY is not set

# CONFIG_ACPI_NFIT is not set

CONFIG_HAVE_ACPI_APEI=y

CONFIG_HAVE_ACPI_APEI_NMI=y

# CONFIG_ACPI_APEI is not set

# CONFIG_DPTF_POWER is not set

# CONFIG_ACPI_EXTLOG is not set

# CONFIG_PMIC_OPREGION is not set

# CONFIG_ACPI_CONFIGFS is not set

CONFIG_X86_PM_TIMER=y

# CONFIG_SFI is not set

```

Powertop reports a power consumption of ~ 9W. I have 850 awaking calls/second. Are those good values?

----------

## albright

 *Quote:*   

> Powertop reports a power consumption of ~ 9W. I have 850 awaking calls/second. Are those good values?

 

I have a thinkpad x1 carbon with i7-6600U and powertop reports idle

power use about  5 watts.

I use TLP for power management and it seems to work well.

----------

## Spargeltarzan

 *albright wrote:*   

> 
> 
> I have a thinkpad x1 carbon with i7-6600U and powertop reports idle
> 
> power use about  5 watts.
> ...

 

Do you use an overlay for it? Could you send me some details? I have found an  bug  for it, but it is not commented in 2018.

Do you think this suits also on a Lenovo Yoga 900? Looks like it is for Thinkpads

----------

## albright

yes, I use the tlp overlay

the config file is pretty clear (tlp.conf). There might be

some thinkpad specific stuff but I think it's mostly

pretty widely applicable. Worth a try.

You might also try undervolting See: https://github.com/georgewhewell/undervolt

though it does not do much on the U-chips ...

----------

## Logicien

With generic kernels I pass the kernel parameter intel_pstate=disable and use acpi-cpufreq as the support for frequency scaling, it work well.

----------

## Spargeltarzan

@albright: I installed tlp from the overlay and activated it.

In idle with wifi on I have around 7-8.5 W power consumption. Without wifi I get 6.5W. Is your 5 W with all devices deactivated? Did you further tune something?

@Logicien: Thanks for the hint, I will compare results with acpi-cpufreq.

----------

## albright

 *Quote:*   

> In idle with wifi on I have around 7-8.5 W power consumption. Without wifi I get 6.5W. Is your 5 W with all devices deactivated? Did you further tune something? 

 

bluetooth is deactivated, but everything else is running,

my screen is about 1/3 brightness (good enough in my

dim room).

I have all the power save features ON BAT in tlp.conf set ON

(I suspect you do too).

----------

## Spargeltarzan

Hmm, whatever I try I can't reduce the power consumption further. I have even set in powertop all measurements to "good" additionally to tlp with the power saving features on. My 8.5 W are with wifi on and on extremely little display brightness, one step less would lead to a black screen. Only at night possible to work with it. 

It somehow must be possible to reduce it a bit more, in my former setup with systemd I managed to run 8-9hours with wifi on, one day with my notebook with battery only wasn't a problem for me. Now it says ~5-6 hours.

I am on the latest 4.18.5 kernel which offers better energy management since 4.17.

I can't imagine systemd helped me for less power consumption, or at least I don't want it to be true   :Rolling Eyes: 

What do you think?

----------

## albright

you have verified that your cpu is scaling properly and spends

a lot of time in C10?

my cpu goes down to 600mhz when idle and spends 90%+

in C10.

----------

## Spargeltarzan

My cpu goes down to 800 Mhz, but scales up extremely easy. For example if I have "top" in one terminal without touching my notebook, the cpu scales up every 5 seconds. When I click something with the mouse, like just open the menu "file" or "edit", the cpu scales up already to ~2500 Mhz.

With only 2 terminals open, powertop and top, the cpu is about 50-80 % in C10, 25% in C8 and the rest spreads in C6 and C0 (active) mostly. When I close everything beside "powertop", my cpu is after one minute 87% in C10. Until I touch something minor...

My cpu climbes very easy to 25%, or 30% usage without touching my computer, only with those two terminals open. gnome-shell and tracker-extract are like every 10 seconds in "top" on the top two places. I have deactivated "the search" in the gnome-settings.

On my Desktop CPU with the same setup the CPU doesn't climb up that easily, although "the search" is activated. While typing this post in firefox it is mostly at 2-3% usage, sometimes goes up to 10%.

hmmmmmmm

----------

## P.Kosunen

 *Spargeltarzan wrote:*   

> Maybe I will need additionally those two for better idle?
> 
> # CONFIG_INTEL_IDLE is not set

 

I believe this should be enabled, don't know about ladders.

https://github.com/torvalds/linux/blob/master/drivers/idle/intel_idle.c

 *Quote:*   

> /*
> 
>  * intel_idle is a cpuidle driver that loads on specific Intel processors
> 
>  * in lieu of the legacy ACPI processor_idle driver.  The intent is to
> ...

 

----------

## Spargeltarzan

I activated already both options before:

CONFIG_INTEL_IDLE

CONFIG_CPU_IDLE_GOV_LADDER

to be on the safe side. So my results above are with those =y.

----------

