View previous topic :: View next topic |
Author |
Message |
MorgothSauron Tux's lil' helper
Joined: 24 Sep 2020 Posts: 80
|
Posted: Thu Jun 27, 2024 4:54 pm Post subject: cpupower - unable to set performance governor at boot |
|
|
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 |
|
|
Pearlseattle Apprentice
Joined: 04 Oct 2007 Posts: 165 Location: Switzerland
|
Posted: Fri Jun 28, 2024 5:16 pm Post subject: |
|
|
That's weird!
(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 |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5111 Location: Bavaria
|
Posted: Fri Jun 28, 2024 5:55 pm Post subject: Re: cpupower - unable to set performance governor at boot |
|
|
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 |
|
|
Goverp Advocate
Joined: 07 Mar 2007 Posts: 2179
|
Posted: Fri Jun 28, 2024 6:51 pm Post subject: |
|
|
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 |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5111 Location: Bavaria
|
Posted: Sat Jun 29, 2024 12:56 am Post subject: |
|
|
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 |
|
|
MorgothSauron Tux's lil' helper
Joined: 24 Sep 2020 Posts: 80
|
Posted: Tue Jul 02, 2024 6:10 pm Post subject: |
|
|
Goverp wrote: | 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. |
I have a desktop computer with an i7-9700k CPU with a Gigabyte Z390 AORUS PRO motherboard.
I do have kde-plasma/powerdevil installed. The Power management profile option is not enabled, so there might be some default settings involved here. I will try to boot without logging in and check the governor value. It should confirm what is the value before opening a session. I will do this quick test and post back.
On a side note, I didn't have cpupower until few weeks ago. I had powersave before installing and enabling cpupower. I was looking for option to set to performance by default. |
|
Back to top |
|
|
MorgothSauron Tux's lil' helper
Joined: 24 Sep 2020 Posts: 80
|
Posted: Wed Jul 03, 2024 5:36 pm Post subject: |
|
|
I'm not sure I understand what is really going on.
I booted and I didn't login in KDE (my only DE) and switched to a console instead (e.g. Ctrl+Alt+f5). The CPU scaling governor is still set to 'powersave'. I think it is safe to say that it is not related to something with KDE startup (e.g. powerdevil). cpupower service was still configured to start at boot.
In the same console I checked the value directly in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor to be sure. It is 'powersave'.
I removed cpupower from OpenRC startup (rc-update del cpupower default) and rebooted. Still the same.
I checked for all files under /etc. I could not find anything that would set the scaling governor to 'powersave'.
The local service is enabled, but I have nothing in /etc/local.d either.
But I decided to try to put my own script for the local service:
Code: | root@morgoth:~ # cat /etc/local.d/cpufreq-scaling-governor-performance.start
#
echo "performance" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor >/dev/null
#
root@morgoth:~ # |
I rebooted and this time cpupower frequency-info is showing 'performance'.
I have no clue why my script started by the 'local' service can do something that the 'cpupower' service doesn't seem to do. Also, I still don't understand that I end up with 'powersave' when 'performance' is set as the default in the kernel options. I must be missing something, but I don't know it yet.
I'll try to play around with this to see if I can really understand. For now the script started by the 'local' service will do the job. |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5111 Location: Bavaria
|
Posted: Wed Jul 03, 2024 5:43 pm Post subject: |
|
|
MorgothSauron,
IF you have "performance" as default in your kernel configured ... THEN ... check if you really boot the kernel you think you boot ->
Check with "dmesg | grep version" the version AND date of the kernel (it is the first line you will get). The date at the end is the date when this kernel was built (compiled). Usually you will install the kernel some seconds later into /boot ... NOW check also with "ls -l /boot" the timestamps of every kernel you have here ...
Maybe you use grub ? If yes ... the first kernel grub presents (and boots) is not always the last kernel you have compiled ... _________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
|
MorgothSauron Tux's lil' helper
Joined: 24 Sep 2020 Posts: 80
|
Posted: Wed Jul 03, 2024 6:23 pm Post subject: |
|
|
pietinger,
Here are the details about the kernels on my system. It looks good to me.
/boot:
Code: | root@morgoth:~ # date
Wed Jul 3 08:09:52 PM CEST 2024
root@morgoth:~ # ls -al /boot
total 109620
drwxr-xr-x 4 root root 4096 Jun 27 19:24 .
drwxr-xr-x 1 root root 134 Apr 27 12:49 ..
-rw-r--r-- 1 root root 77312 Jun 17 19:10 amd-uc.img
drwxr-xr-x 6 root root 4096 Jun 27 19:24 grub
-rw-r--r-- 1 root root 9054432 Jun 12 19:27 initramfs-6.9.4-gentoo-x86_64.img
-rw-r--r-- 1 root root 9059680 Jun 17 19:24 initramfs-6.9.5-gentoo-x86_64.img
-rw-r--r-- 1 root root 9057256 Jun 25 19:39 initramfs-6.9.6-gentoo-x86_64.img
-rw-r--r-- 1 root root 9060356 Jun 27 19:23 initramfs-6.9.7-gentoo-x86_64.img
-rw-r--r-- 1 root root 534528 Jun 27 18:06 intel-uc.img
-rw-r--r-- 1 root root 0 Nov 18 2020 .keep
drwx------ 2 root root 16384 Nov 21 2020 lost+found
-rw-r--r-- 1 root root 6732898 Jun 12 19:14 System.map-6.9.4-gentoo-x86_64
-rw-r--r-- 1 root root 6733110 Jun 17 19:15 System.map-6.9.5-gentoo-x86_64
-rw-r--r-- 1 root root 6733546 Jun 25 19:29 System.map-6.9.6-gentoo-x86_64
-rw-r--r-- 1 root root 6734861 Jun 27 19:14 System.map-6.9.7-gentoo-x86_64
-rw-r--r-- 1 root root 12100608 Jun 12 19:14 vmlinuz-6.9.4-gentoo-x86_64
-rw-r--r-- 1 root root 12100608 Jun 17 19:15 vmlinuz-6.9.5-gentoo-x86_64
-rw-r--r-- 1 root root 12108800 Jun 25 19:29 vmlinuz-6.9.6-gentoo-x86_64
-rw-r--r-- 1 root root 12108800 Jun 27 19:14 vmlinuz-6.9.7-gentoo-x86_64
root@morgoth:~ # |
I use initramfs because / is on a filesystem encrypted with LUKS. I use genkernel.
Running kernel is 6.9.7. The kernel file date match the build date.
Code: | root@morgoth:/ # dmesg | grep "Linux version"
[ 0.000000] Linux version 6.9.7-gentoo-x86_64 (root@morgoth) (x86_64-pc-linux-gnu-gcc (Gentoo 13.2.1_p20240210 p14) 13.2.1 20240210, GNU ld (Gentoo 2.42 p3) 2.42.0) #1 SMP PREEMPT_DYNAMIC Thu Jun 27 19:14:31 CEST 2024
root@morgoth:/ #
root@morgoth:/ # uname -a
Linux morgoth 6.9.7-gentoo-x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 27 19:14:31 CEST 2024 x86_64 Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz GenuineIntel GNU/Linux
root@morgoth:/ # |
'perfomance' is set as the default in the running kernel configuration
Code: | root@morgoth:~ # zcat /proc/config.gz | grep CPU_FREQ_DEFAULT_GOV_PERFORMANCE
CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
root@morgoth:~ # |
I do use grub. I make sure to run grub-mkconfig -o /boot/grub/grub.cfg every time I make a change in /boot, like removing an old kernel.
The first menuentry in /boot/grub/grub.cfg is 6.9.7 as well.
Code: | ### BEGIN /etc/grub.d/10_linux ###
menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-b7d7d156-3372-40ba-b71c-54542050af8b' {
load_video
if [ "x$grub_platform" = xefi ]; then
set gfxpayload=keep
fi
insmod gzio
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set=root ac315056-593b-4566-94be-209a3f784d10
echo 'Loading Linux 6.9.7-gentoo-x86_64 ...'
linux /vmlinuz-6.9.7-gentoo-x86_64 root=UUID=b7d7d156-3372-40ba-b71c-54542050af8b ro rootflags=subvol=@root init=/sbin/openrc-init keymap=us crypt_root=UUID=ec03044a-df21-4347-a166-49d65a17bf93 root=UUID=b7d7d156-3372-40ba-b71c-545420
50af8b rootflags=subvol=@root delayacct
echo 'Loading initial ramdisk ...'
initrd /intel-uc.img /amd-uc.img /initramfs-6.9.7-gentoo-x86_64.img
} |
|
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5111 Location: Bavaria
|
Posted: Wed Jul 03, 2024 8:40 pm Post subject: |
|
|
MorgothSauron,
yes you are booting with a kernel which setting is "performance" as default ... I am sorry, I must give up ->
I have also a manually configured kernel (also 6.9.7 as you have; but NO initramfs) and had "performance" as default in my kernel configured (for testing) ... even with a KDE/Plasma system I had still "performce" after rebooting active ...
These are my rc-scripts:
Code: | $ rc-update
alsasound | boot
apparmor | boot
binfmt | boot
bootmisc | boot
cgroups | sysinit
chronyd | default
cronie | default
devfs | sysinit
display-manager | default
dmesg | sysinit
elogind | boot
fsck | boot
hostname | boot
iptables | default
keymaps | boot
killprocs | shutdown
kmod-static-nodes | sysinit
local | default nonetwork
localmount | boot
loopback | boot
modules | boot
mount-ro | shutdown
mtab | boot
net.enp2s0 | default
osclock | default
privoxy | default
procfs | boot
root | boot
save-keymaps | boot
save-termencoding | boot
savecache | shutdown
seedrng | boot
swap | boot
sysctl | boot
sysfs | sysinit
sysklogd | default
systemd-tmpfiles-setup | boot
systemd-tmpfiles-setup-dev | sysinit
termencoding | boot
udev | sysinit
udev-trigger | sysinit
unbound | default |
(maybe it helps to check if there is a suspicious script you use)
Maybe extract your initramfs and check what it does ?
( https://wiki.gentoo.org/wiki/Custom_Initramfs#Extracting_the_cpio_archive ) _________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
|
|