Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
cpupower - unable to set performance governor at boot
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
MorgothSauron
Tux's lil' helper
Tux's lil' helper


Joined: 24 Sep 2020
Posts: 77

PostPosted: Thu Jun 27, 2024 4:54 pm    Post subject: cpupower - unable to set performance governor at boot Reply with quote

Hello,
I'm trying to use sys-power/cpupower to change the CPU scaling governor from 'powersave' to 'performance' at boot, but I always end up with 'powersave'. At least this is my conclusion based on everything I verified.

I have cpupower 6.2.0 installed

Code:
root@morgoth:~ # eix sys-power/cpupower
[I] sys-power/cpupower
     Available versions:  5.18(0/0) 6.2(0/0) {nls}
     Installed versions:  6.2(0/0)(06:36:24 PM 06/05/2024)(nls)
     Homepage:            https://www.kernel.org/
     Description:         Shows and sets processor power related values

root@morgoth:~ # cpupower --version
cpupower 6.2.0
Report errors and bugs to linux-pm@vger.kernel.org, please.
root@morgoth:~ #


I changed the START_OPTS value in /etc/conf.d/cpupower to set governor to 'performance' instead of the default (ondemand). This is the only change I made to this file.

Code:
root@morgoth:~ # grep START_OPTS /etc/conf.d/cpupower
##START_OPTS="--governor ondemand"
START_OPTS="--governor performance"
root@morgoth:~ #


Finally, I added the cpupower service to start at boot

Code:
rc-update add cpupower default


I can see in /var/log/rc.log that the cpupower command is executed at boot with the option I set in the configuration:

Code:

 * Running cpupower -c all frequency-set --governor performance ...
 [ ok ]


However, the governor is set to 'powersave':

Code:
# cpupower frequency-info
analyzing CPU 7:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 7
  CPUs which need to have their frequency coordinated by software: 7
  maximum transition latency:  Cannot determine or is not supported.
  hardware limits: 800 MHz - 4.90 GHz
  available cpufreq governors: performance powersave
  current policy: frequency should be within 800 MHz and 4.90 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 4.69 GHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes


Running the command manually using the command from rc.log seems to work:

Code:
root@morgoth:~ # cpupower -c all frequency-set --governor performance
Setting cpu: 0
Setting cpu: 1
Setting cpu: 2
Setting cpu: 3
Setting cpu: 4
Setting cpu: 5
Setting cpu: 6
Setting cpu: 7
root@morgoth:~ # cpupower frequency-info
analyzing CPU 2:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 2
  CPUs which need to have their frequency coordinated by software: 2
  maximum transition latency:  Cannot determine or is not supported.
  hardware limits: 800 MHz - 4.90 GHz
  available cpufreq governors: performance powersave
  current policy: frequency should be within 800 MHz and 4.90 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 4.79 GHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes
root@morgoth:~ #


The performance governor is normally the one set as the default in the kernel configuration:

Code:
-*- CPU Frequency scaling
[*]   CPU frequency transition statistics
      Default CPUFreq governor (performance)  --->
-*-   'performance' governor
<M>   'powersave' governor
<*>   'userspace' governor for userspace frequency scaling
< >   'ondemand' cpufreq policy governor
< >   'conservative' cpufreq governor

root@morgoth:~ # zcat /proc/config.gz | grep CPU_FREQ_GOV_PERFORMANCE
CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
root@morgoth:~ #


I could not find anything else that could explain this behavior

Any idea why 'powersave' seems to be the "active" governor at boot although the cpupower service is executed with the right parameter to set it to 'performance' ?

Am I missing something important here ?

Thanks
Back to top
View user's profile Send private message
Pearlseattle
Apprentice
Apprentice


Joined: 04 Oct 2007
Posts: 164
Location: Switzerland

PostPosted: Fri Jun 28, 2024 5:16 pm    Post subject: Reply with quote

That's weird! :o
(but I never used "cpupower" so I don't know anything specific about it)

Extreme wild guess:
maybe it happens because you compile "powersave" as module but "performance" as embedded in the kernel?
Therefore maaaybe "performance" is set right when the kernel is loaded, but then when your modules-directory is mounted the kernel sees a compatible governor that is available ("powersave") and therefore loads it? And/or then maybe there is a race condition with the start of "cpupower" vs. load of available modules and what I wrote in my previous sentence happens after "cpupower" is started?

Therefore, here is my proposal #1:
compile "powersave" as well embedded (not as a module) and see if that changes anything?


Otherwise, just to be 200% sure: whenever you check then check all vCPUs, just to be sure that they're all the same:
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

Maybe you could try to write your own (as "root") "/etc/init.d/mycustom-cpu_governor" like for example...
Code:
#!/sbin/openrc-run

start() {
        echo "performance" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor >/dev/null
        }
stop() {
        echo nothing2do
        }

...then "chmod 700 /etc/init.d/mycustom-cpu_governor", then test it with "/etc/init.d/mycustom-cpu_governor start" and if that works then add it to the boot sequence with "rc-update add mycustom-cpu_governor default" and then reboot and then finally check the result with "cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor"?
If this would not work (you would still see "powersave" being used, but when executing "/etc/init.d/mycustom-cpu_governor start" then it works, then I'd guess that you most probably have "something else" that is executed later in the boot sequence that makes you use "powersave"...?


Cheers
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4520
Location: Bavaria

PostPosted: Fri Jun 28, 2024 5:55 pm    Post subject: Re: cpupower - unable to set performance governor at boot Reply with quote

MorgothSauron wrote:
The performance governor is normally the one set as the default in the kernel configuration:

Code:
-*- CPU Frequency scaling
[*]   CPU frequency transition statistics
      Default CPUFreq governor (performance)  --->
-*-   'performance' governor
<M>   'powersave' governor
<*>   'userspace' governor for userspace frequency scaling
< >   'ondemand' cpufreq policy governor
< >   'conservative' cpufreq governor

root@morgoth:~ # zcat /proc/config.gz | grep CPU_FREQ_GOV_PERFORMANCE
CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
root@morgoth:~ #

This means you are configuring your kernel yourself - this is an advantage. NOW ...

... usually you dont need cpupower at all, because the DEFAULT kernel setting decides which governor is used - this one:
Code:
...
      Default CPUFreq governor (performance)  --->
...

and this will not be changed ... IF ... if there is no rc-script which is doing this ... so, I suggest to remove cpupower completely from your runlevel AND then check if the governor is changed after a fresh reboot. IF YES, THEN some other rc-script OR some application in your DE or WM is doing it !

I configure my kernel also myself and have set the default to "schedutil" - "performance" is enabled automatially because of "Selected by [y]: - X86_INTEL_PSTATE [=y] && CPU_FREQ [=y] && X86 [=y]" - all others are disabled.
Code:
      Default CPUFreq governor (schedutil)  --->
-*-   'performance' governor
-*-   'schedutil' cpufreq policy governor

_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2044

PostPosted: Fri Jun 28, 2024 6:51 pm    Post subject: Reply with quote

I probably missed it above, but I don't see what sort of PC you have. So, making a wild guess, it's a laptop or equivalent (otherwise you might not be too concerned about power managers). In which case there might be some packages such as laptop-mode-tools that will play with cpu power settings. I think if you install KDE powerdevil, that too will alter settings without telling you. Such packages do this as a matter of course, as it's their primary function.
_________________
Greybeard
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4520
Location: Bavaria

PostPosted: Sat Jun 29, 2024 12:56 am    Post subject: Reply with quote

The whole thing gave me no peace and I tested it myself today (as I don't normally use the rc-script "cpupower"). Result: The rc-script is not able to change the governor (*) and is therefore faulty for me. Manually I can change from "powersave" to "performance" (and back) with "cpupower" (Intel's P-State only recognizes this two).

*) I didnt changed the file /etc/conf.d/cpupower (default is there: START_OPTS="--governor powersave") and started my machine with my default from kernel "performance" ... It was still performance after starting this rc-script.

I then also looked at how the power preference changes:
Code:
 /sys/devices/system/cpu/cpu0/cpufreq # cpupower -c all frequency-set --governor powersave
CPU einstellen: 0
...
CPU einstellen: 31
 /sys/devices/system/cpu/cpu0/cpufreq # cat scaling_governor
powersave
 /sys/devices/system/cpu/cpu0/cpufreq # cat energy_performance_preference
balance_performance
 /sys/devices/system/cpu/cpu0/cpufreq # cpupower -c all frequency-set --governor performance
...
 /sys/devices/system/cpu/cpu0/cpufreq # cat scaling_governor
performance
 /sys/devices/system/cpu/cpu0/cpufreq # cat energy_performance_preference
performance

I have also checked with which setting P-State starts if you set "performance" as default in the kernel configuration: Yes, it is/was "performance".
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum