# Gentoo-sources-5.10.76-r1 doesn't use P-State

## figueroa

I've been running gentoo-sources stable in the 5.4 series for nearly a year and have been very happy with it. But, I felt challenged to move up and did as I wrote at: https://forums.gentoo.org/viewtopic-t-1145115.html#8677562, and on my second build and boot I solved the reported pcspkr error message.

Now that I'm running it, I expected to stay with 5.10 series for another year or more. Only issue is, it takes over an hour (70 minutes) to complete "make && make modules_install" compared to 28 minutes with 5.4.156. During the builds after booting into 5.10.76-r1, CPU frequency and load barely budged above baseline.

I see the problem, but I don't know what to do about it. When booted to 5.10.76-r1, P-State is not being used. I'd like to continue to use P-State but don't know how to do that.

```
# cpupower frequency-info

analyzing CPU 0:

  driver: intel_cpufreq

  CPUs which run at the same hardware frequency: 0

  CPUs which need to have their frequency coordinated by software: 0

  maximum transition latency: 20.0 us

  hardware limits: 1.60 GHz - 3.80 GHz

  available cpufreq governors: userspace powersave performance schedutil

  current policy: frequency should be within 1.60 GHz and 3.80 GHz.

                  The governor "powersave" may decide which speed to use

                  within this range.

  current CPU frequency: Unable to call hardware

  current CPU frequency: 1.60 GHz (asserted by call to kernel)

  boost state support:

    Supported: yes

    Active: yes

    3500 MHz max turbo 4 active cores

    3600 MHz max turbo 3 active cores

    3700 MHz max turbo 2 active cores

    3800 MHz max turbo 1 active cores
```

Here were the settings in .config for 5.4.156:

```
# grep -i freq .config

CONFIG_ACPI_CPU_FREQ_PSS=y

# CPU Frequency scaling

CONFIG_CPU_FREQ=y

# CONFIG_CPU_FREQ_STAT is not set

# 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 is not set

# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set

# CONFIG_CPU_FREQ_GOV_SCHEDUTIL is not set

# CPU frequency scaling drivers

# CONFIG_X86_PCC_CPUFREQ is not set

# CONFIG_X86_ACPI_CPUFREQ is not set

# end of CPU Frequency scaling

# CONFIG_PM_DEVFREQ is not set

# grep -i pstate .config

CONFIG_X86_INTEL_PSTATE=y
```

And for 5.10.76-r1

```
# grep -i freq /usr/src/linux/.config

CONFIG_ACPI_CPU_FREQ_PSS=y

# CPU Frequency scaling

CONFIG_CPU_FREQ=y

CONFIG_CPU_FREQ_GOV_ATTR_SET=y

# CONFIG_CPU_FREQ_STAT is not set

# 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_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 is not set

# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set

CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y

# CPU frequency scaling drivers

# CONFIG_X86_PCC_CPUFREQ is not set

# CONFIG_X86_ACPI_CPUFREQ is not set

# end of CPU Frequency scaling

# CONFIG_INTEL_UNCORE_FREQ_CONTROL is not set

# CONFIG_PM_DEVFREQ is not set 

bethel # grep -i pstate /usr/src/linux/.config

CONFIG_X86_INTEL_PSTATE=y
```

ADDED: Maybe this looks at it from a different angle. I put the output of grep .config for 5.4.156 into file 54156 and the output for grep .config in the file 10761 and then ran diff:

```
$ diff 4156 10761

0a1

> CONFIG_CPU_FREQ_GOV_ATTR_SET=y

4,5d4

< # CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set

< # CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set

12c11

< # CONFIG_CPU_FREQ_GOV_SCHEDUTIL is not set

---

> CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y

19d17

< # CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR is not set

24d21

< # CONFIG_THERMAL_GOV_POWER_ALLOCATOR is not set
```

What I mainly notice is that "CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y" is force Y in 5.10.76-r1.

----------

## spica

 *figueroa wrote:*   

> What I mainly notice is that "CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y" is force Y in 5.10.76-r1.

 I have this option enabled and scaling driver is pstate at the same time:

```
# for i in scaling_driver scaling_available_governors scaling_governor; do echo -n "$i: "; cat /sys/devices/system/cpu/cpu0/cpufreq/$i; done

scaling_driver: intel_pstate

scaling_available_governors: performance powersave

scaling_governor: powersave

# zgrep -iE '^[^#]+(freq|pstate)' /proc/config.gz | sort

CONFIG_ACPI_CPU_FREQ_PSS=y

CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL=y

CONFIG_CPU_FREQ_GOV_ATTR_SET=y

CONFIG_CPU_FREQ_GOV_COMMON=y

CONFIG_CPU_FREQ_GOV_ONDEMAND=y

CONFIG_CPU_FREQ_GOV_PERFORMANCE=y

CONFIG_CPU_FREQ_GOV_POWERSAVE=y

CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y

CONFIG_CPU_FREQ_GOV_USERSPACE=y

CONFIG_CPU_FREQ_STAT=y

CONFIG_CPU_FREQ=y

CONFIG_X86_ACPI_CPUFREQ=y

CONFIG_X86_INTEL_PSTATE=y

CONFIG_X86_PCC_CPUFREQ=m
```

----------

## pietinger

P-State is using only "powersave" and "performance" (I recommend "performance" for a desktop and "powersave" for notebooks").

P-State is recommended by Intel for all newer processors. See more here in this thread: https://forums.gentoo.org/viewtopic-t-1144881-highlight-pstate.html

----------

## figueroa

Thank you both for replying.

I followed the kernel config advice offered by spica, but I don't get P-State, rather driver: intel_cpufreq, and schedutil as the default governor. It's not what I was looking for but it does seem to be responsive, well modulated, and fast when necessary.

```
# cpupower frequency-info

analyzing CPU 0:

  driver: intel_cpufreq

  CPUs which run at the same hardware frequency: 0

  CPUs which need to have their frequency coordinated by software: 0

  maximum transition latency: 20.0 us

  hardware limits: 1.60 GHz - 3.80 GHz

  available cpufreq governors: ondemand userspace powersave performance schedutil

  current policy: frequency should be within 1.60 GHz and 3.80 GHz.

                  The governor "schedutil" may decide which speed to use

                  within this range.

  current CPU frequency: Unable to call hardware

  current CPU frequency: 1.60 GHz (asserted by call to kernel)

  boost state support:

    Supported: yes

    Active: yes

    3500 MHz max turbo 4 active cores

    3600 MHz max turbo 3 active cores

    3700 MHz max turbo 2 active cores

    3800 MHz max turbo 1 active cores
```

```
# ls /sys/devices/system/cpu/cpu0/cpufreq/*

/sys/devices/system/cpu/cpu0/cpufreq/affected_cpus

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

/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq

/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_transition_latency

/sys/devices/system/cpu/cpu0/cpufreq/related_cpus

/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors

/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver

/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq

/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
```

```
#  for i in scaling_driver scaling_available_governors scaling_governor; do echo -n "$i: "; cat /sys/devices/system/cpu/cpu0/cpufreq/$i; done

scaling_driver: intel_cpufreq

scaling_available_governors: ondemand userspace powersave performance schedutil 

scaling_governor: schedutil
```

As a test, I did emerge -1 imagemagick, and it built in 2'39" (expected range) today, versus 3'06" yesterday with 5.4.156 (slower than normal).

My relevant 5.10.76-r1 kernel config is as follows, and I think matches what spica put up:

```
# grep -iE '^[^#]+(freq|pstate)' /usr/src/linux/.config

CONFIG_ACPI_CPU_FREQ_PSS=y

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_SCHEDUTIL=y

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_SCHEDUTIL=y

CONFIG_X86_INTEL_PSTATE=y

CONFIG_X86_PCC_CPUFREQ=m

CONFIG_X86_ACPI_CPUFREQ=y
```

Should I WANT P-State driver? According to what I've read I think I should want P-State. How would I get it?

----------

## pietinger

 *figueroa wrote:*   

> Should I WANT P-State driver? According to what I've read I think I should want P-State. How would I get it?

 

figueroa,

may I ask you which CPU you have ? I ask, because AFAIK (=I can be wrong here) IF you enable P-State (you did: "CONFIG_X86_INTEL_PSTATE=y") THEN the kernel will use it at first (even if you set some ACPI with yes), BUT ONLY for some newer CPUs (Sandy Bridge and later generations).

So, if you have an old Core2Duo (I dont hink so) then you can not use it. For a newer CPU I am surprised that P-State is not used by your kernel ...

----------

## figueroa

Thank you for replying pietinger. As noted in my signature, my CPU is:

```
i7-2600 @ 3.40GHz
```

Under 5.4 kernel series it was actively using P-State driver. After updating to 5.10.76-r1, it wasn't using P-State and wasn't managing CPU frequency at all.

I followed spica's configuration to get to where I'm at. It seems like it's working well, but not using P-State driver. The changes in kernel configuration are noted in this thread above.

----------

## pietinger

 *figueroa wrote:*   

> As noted in my signature, my CPU is:
> 
> ```
> i7-2600 @ 3.40GHz
> ```
> ...

 

Thanks for your answer and sorry for I didnt read your signature. My only (logical) explanation at the moment is: There must be some changes in the kernel with P-state (possibly only first timer processors like sandy bridge itself); it would be very interesting what happens when using the next LTS kernel series (5.15). I am sorry I dont know more for your cpu and cant help.

----------

## figueroa

pietinger -- Thank you for engaging. I'm hoping someone will pass through and provide a good clue.

ADDING: I found: https://www.phoronix.com/scan.php?page=news_item&px=Linux-5.7-Schedutil-P-State that reads, in part:

 *Quote:*   

> On top of all the other changes in Linux 5.7 so far, a secondary set of power management updates were sent in today for this next version of the kernel and includes now using the Schedutil governor by default for Intel P-State and Arm big.LITTLE systems. 

 

For my "just a user" background, it's clear as mud, but maybe what I've got now is as it should be. I'll keep looking, but this combination seems very responsive as I can see CPU frequency bouncing around in conky responding to every little demand, and during emerges I get some turbo range frequencies too.

ADDING2: Also: https://www.phoronix.com/scan.php?page=article&item=linux50-pstate-cpufreq&num=1

----------

## pietinger

figueroa - Thanks a lot for the links. I believe the second one I have seen before (long, long ago; but I cant remember exactly). The first link is very interesting and I didnt knew that.

I have only this with my 5.10.78 kernel:

```
/usr/src/linux $ zgrep -iE '^[^#]+(freq|pstate)' .config | sort

CONFIG_ACPI_CPU_FREQ_PSS=y

CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y

CONFIG_CPU_FREQ_GOV_ATTR_SET=y

CONFIG_CPU_FREQ_GOV_PERFORMANCE=y

CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y

CONFIG_CPU_FREQ_STAT=y

CONFIG_CPU_FREQ=y

CONFIG_X86_INTEL_PSTATE=y
```

This leads to:

```
$ LC_ALL=C cpupower frequency-info

analyzing CPU 0:

  driver: intel_pstate

  CPUs which run at the same hardware frequency: 0

  CPUs which need to have their frequency coordinated by software: 0

  maximum transition latency:  Cannot determine or is not supported.

  hardware limits: 800 MHz - 4.00 GHz

  available cpufreq governors: performance powersave

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

                  The governor "performance" may decide which speed to use

                  within this range.

  current CPU frequency: Unable to call hardware

  current CPU frequency: 3.95 GHz (asserted by call to kernel)

  boost state support:

    Supported: yes

    Active: yes
```

----------

## smartding

I have a Intel i5-4460S and running 5.10.76-r1 kernel with CONFIG_X86_INTEL_PSTATE=y.

"cat /sys/devices/system/cpu/intel_pstate/status" shows p-state is in "passive" mode

"cat /sys/devices/system/cpu/cpufreq/policy0/scaling_driver" shows the driver is intel_cpufreq.

So I guess p-state isn't working.

I tried some new kernels in arch Linux (arch linux is my platform to try new stuff, because I don't have to compile anything), 5.14.16 and 5.15.2, same issue.

----------

## pietinger

What happens if you disable: "CONFIG_X86_ACPI_CPUFREQ=y" ?

----------

## smartding

 *pietinger wrote:*   

> What happens if you disable: "CONFIG_X86_ACPI_CPUFREQ=y" ?

 

I disabled CONFIG_X86_ACPI_CPUFREQ, but nothing changed.

Running "zgrep -iE '^[^#]+(freq|pstate)' .config | sort" now shows:

```

CONFIG_ACPI_CPU_FREQ_PSS=y

CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y

CONFIG_CPU_FREQ_GOV_ATTR_SET=y

CONFIG_CPU_FREQ_GOV_COMMON=y

CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y

CONFIG_CPU_FREQ_GOV_ONDEMAND=y

CONFIG_CPU_FREQ_GOV_PERFORMANCE=y

CONFIG_CPU_FREQ_GOV_POWERSAVE=y

CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y

CONFIG_CPU_FREQ_GOV_USERSPACE=y

CONFIG_CPU_FREQ_STAT=y

CONFIG_CPU_FREQ=y

CONFIG_X86_INTEL_PSTATE=y

```

----------

## spica

figueroa,

What's in dmesg?

This is for reference from my laptop:

```
# dmesg | grep pstate

[    0.697590] intel_pstate: Intel P-state driver initializing

[    0.698461] intel_pstate: Disabling energy efficiency optimization

[    0.698462] intel_pstate: HWP enabled
```

The first line is printed here https://github.com/torvalds/linux/blob/v5.10/drivers/cpufreq/intel_pstate.c#L3072 (not sure if this is the right commit in git, who knows better, please correct me). If we have no other options then we need to dig the source...

----------

## smartding

 *spica wrote:*   

> What's in dmesg?
> 
> This is for reference:
> 
> ```
> ...

 

dmesg shows:

```

[    0.282861] intel_pstate: Intel P-state driver initializing

```

then nothing.

----------

## spica

smartding,

For your case, you can try experimenting with intel_pstate=active or intel_pstate=force in kernel command string.

This documentation should help you.

Available param values in source code (not sure if this is the proper commit in git, may differ from files in /usr/src/linux)

----------

## smartding

 *spica wrote:*   

> smartding,
> 
> For your case, you can try experimenting with intel_pstate=active or intel_pstate=force in kernel command string.
> 
> This documentation should help you.
> ...

 

Setting intel_pstate=active does make p-state active for me, although intel_pstate=force doesn't.

I found this reddit article, which says Linux kernel 5.8 defaults to passive mode for intel_pstate driver for cpu before skylake, maybe this is still the case for newer kernels.

It explains why I have to pass the intel_pstate=active kernel command string for my i5-4460S CPU to activate p-state, but not for my new tiger lake CPU.

https://www.reddit.com/r/linux/comments/ihdozd/linux_kernel_58_defaults_to_passive_mode_for/

----------

## pietinger

 *smartding wrote:*   

> https://www.reddit.com/r/linux/comments/ihdozd/linux_kernel_58_defaults_to_passive_mode_for/

 

Also a great link, thank you.

Its funny, I have an Intel i7-6700 ... Skylake ... able to do HWP:

```
# dmesg | grep pstate

[    2.228213] intel_pstate: Intel P-state driver initializing

[    2.228807] intel_pstate: HWP enabled
```

----------

## smartding

 *pietinger wrote:*   

> 
> 
> Its funny, I have an Intel i7-6700 ... Skylake ... able to do HWP:
> 
> ```
> ...

 

The reddit article means there's HWP for Skylake and above.

----------

## figueroa

I too have only:

```
$ dmesg | grep -i pstat

[Mon Nov 15 11:56:34 2021] intel_pstate: Intel P-state driver initializing
```

ADDED: From redit link: https://www.reddit.com/r/linux/comments/ihdozd/linux_kernel_58_defaults_to_passive_mode_for/

```
# echo active > /sys/devices/system/cpu/intel_pstate/status
```

and that just works:

```
# cpupower frequency-info

analyzing CPU 0:

  driver: intel_pstate

  CPUs which run at the same hardware frequency: 0

  CPUs which need to have their frequency coordinated by software: 0

  maximum transition latency:  Cannot determine or is not supported.

  hardware limits: 1.60 GHz - 3.80 GHz

  available cpufreq governors: performance powersave

  current policy: frequency should be within 1.60 GHz and 3.80 GHz.

                  The governor "powersave" may decide which speed to use

                  within this range.

  current CPU frequency: Unable to call hardware

  current CPU frequency: 1.60 GHz (asserted by call to kernel)

  boost state support:

    Supported: yes

    Active: yes

    3500 MHz max turbo 4 active cores

    3600 MHz max turbo 3 active cores

    3700 MHz max turbo 2 active cores

    3800 MHz max turbo 1 active cores
```

Now to figure out if there is a kernel configuration setting to just make that work.

----------

## spica

figueroa,

I found this commit and this - these changes appear in v5.8.

According to code, by default, if CPU has no HWP, then the default driver is cpufreq.

It seems, there's no kernel configuration parameter. kernel cmd is the only possible way to force it, see /usr/src/linux/drivers/cpufreq/intel_pstate.c

```
static int __init intel_pstate_setup(char *str)

{

   if (!str)

      return -EINVAL;

   if (!strcmp(str, "disable"))

      no_load = 1;

   else if (!strcmp(str, "active"))

      default_driver = &intel_pstate;

   else if (!strcmp(str, "passive"))

      default_driver = &intel_cpufreq;

   if (!strcmp(str, "no_hwp"))

      no_hwp = 1;

   if (!strcmp(str, "force"))

      force_load = 1;

   if (!strcmp(str, "hwp_only"))

      hwp_only = 1;

   if (!strcmp(str, "per_cpu_perf_limits"))

      per_cpu_limits = true;

#ifdef CONFIG_ACPI

   if (!strcmp(str, "support_acpi_ppc"))

      acpi_ppc = true;

#endif

   return 0;

}

early_param("intel_pstate", intel_pstate_setup);
```

Last edited by spica on Tue Nov 16, 2021 10:01 pm; edited 1 time in total

----------

## figueroa

Seems to be up-in-the-air which state is better and not everybody agrees. It's really hard to compare going from 5.4 series to 5.10 while changing cpu frequency scaling at the same time. I don't have an opinion, yet if ever. But, I'm glad I started this thread.

ADDED: The Arch wiki has a good section explaining the selection of CPU frequency driver based on Intel CPU generation and kernel version.

https://wiki.archlinux.org/title/CPU_frequency_scaling#CPU_frequency_driver

According to this, p-state passive is selected purposefully which results in use of intel_cpufreq driver for 5th generation and lower from kernel 5.7 and up. After a couple of days, I can report that cpu frequencies appear to be well modulated, change quickly, over the full range of speed including turbo. I still can't comment objectively on performance. Desktop user apparent performance remains excellent.

----------

