Cpupower.service can't set governor on boot?

Hello all. I’ve been using a cpupower.service for years now and suddenly it’s failing in a fresh install, but I haven’t had a computer for a while so it may have failed for a few months now without my being aware.

When I start the service with

sudo systemctl start cpupower.service

it works fine and also works when I start it with

sudo systemctl enable --now cpupower.service

I use my config in different ways as per my need. My current laptop has only 2 governors: Performance and Powersave. It always boots with governor powersave, even when plugged in, and I always use it plugged in, so I set the config to start with performance governor in my usual way and enable the service and reboot. When I then run

sudo cpupower frequency-info

I see that it’s set to powersave. I then run

sudo systemctl status cpupower.service 

and see something strange…take a look…

╭─user@zbook in ~ as 🧙 took 223ms
[🔴] × ╭─user@zbook in ~ as 🧙 took 2s
╰─λ sudo systemctl status cpupower.service
○ cpupower.service - Set all cores to performance
Loaded: loaded (/etc/systemd/system/cpupower.service; enabled; preset: disabled)
Active: inactive (dead) since Sat 2024-02-10 03:12:02 CST; 53s ago
Process: 642 ExecStart=cpupower -c all frequency-set -g performance (code=exited, status=0/SUCCESS)
Process: 657 ExecStart=cpupower -c all frequency-set -g performance (code=exited, status=0/SUCCESS)
Main PID: 657 (code=exited, status=0/SUCCESS)
CPU: 18ms

Feb 10 03:12:02 zbook cpupower[657]: Setting cpu: 3
Feb 10 03:12:02 zbook cpupower[657]: Setting cpu: 4
Feb 10 03:12:02 zbook cpupower[657]: Setting cpu: 5
Feb 10 03:12:02 zbook cpupower[657]: Setting cpu: 6
Feb 10 03:12:02 zbook cpupower[657]: Setting cpu: 7
Feb 10 03:12:02 zbook systemd[1]: cpupower.service: Deactivated successfully.
Feb 10 03:12:02 zbook systemd[1]: Finished Set all cores to performance.
Feb 10 03:12:56 zbook systemd[1]: /etc/systemd/system/cpupower.service:8: Missing '=', ignoring line.
Feb 10 03:12:56 zbook systemd[1]: /etc/systemd/system/cpupower.service:9: Unknown key name 'Description' in section 'Install', ignoring.
Feb 10 03:12:56 zbook systemd[1]: /etc/systemd/system/cpupower.service:15: Missing '=', ignoring line.

I’m not worried about the lines at the bottom that say a line was ignored. It may have said that for years and I never noticed because it always worked before so I had no reason to even look at the status. And besides, as you can see, it exited with 0/SUCCESS and set the governor to performance, just like it was supposed to. What I’m wondering about is the line that says

Feb 10 03:12:02 zbook systemd[1]: cpupower.service: Deactivated successfully.

Is it normal for a service to be deactivated after it runs? It seems that when it deactivates it unsets the governor to go back to it’s default: powersave. But when I then run

sudo systemctl enable --now cpupower.service

then I get this

╭─user@zbook in ~ as 🧙 took 359ms
╰─λ sudo 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 - 3.60 GHz
available cpufreq governors: performance powersave
current policy: frequency should be within 800 MHz and 3.60 GHz.
The governor "performance" may decide which speed to use
within this range.
current CPU frequency: Unable to call hardware
current CPU frequency: 3.27 GHz (asserted by call to kernel)
boost state support:
Supported: yes
Active: yes

It was successfully set to performance and will stay that way from what I can tell so far.

This is the config. It’s short so I’ll just paste it here. I realize there are 2 sections and sometimes, if I want it to do more than one thing, the 2 sections will be different, but if I just want one thing I put both sections to do the same thing so that it’s easy to change to 2 or more actions without much work.

The file is located at /etc/systemd/system/cpupower.service

[Unit]
Description=Set all cores to performance
[Service]
Type=oneshot
ExecStart=cpupower -c all frequency-set -g performance
[Install]
WantedBy=multi-user.target
EOF[Unit]
Description=Set all cores to performance
[Service]
Type=oneshot
ExecStart=cpupower -c all frequency-set -g performance
[Install]
WantedBy=multi-user.target
EOF

Does anyone see why it’s being deactivated after running at boot? Any help will be greatly appreciated.

EDIT: I just ran

sudo systemctl status cpupower.service

again and look at the output.

╭─user@zbook in ~ as 🧙 took 29ms
╰─λ sudo systemctl status cpupower.service
[sudo] password for user:
○ cpupower.service - Set all cores to performance
Loaded: loaded (/etc/systemd/system/cpupower.service; enabled; preset: disabled)
Active: inactive (dead) since Sat 2024-02-10 03:33:31 CST; 13min ago
Process: 50204 ExecStart=cpupower -c all frequency-set -g performance (code=exited, status=0/SUCCESS)
Process: 50205 ExecStart=cpupower -c all frequency-set -g performance (code=exited, status=0/SUCCESS)
Main PID: 50205 (code=exited, status=0/SUCCESS)
CPU: 9ms

Feb 10 03:33:31 zbook cpupower[50205]: Setting cpu: 3
Feb 10 03:33:31 zbook cpupower[50205]: Setting cpu: 4
Feb 10 03:33:31 zbook cpupower[50205]: Setting cpu: 5
Feb 10 03:33:31 zbook cpupower[50205]: Setting cpu: 6
Feb 10 03:33:31 zbook cpupower[50205]: Setting cpu: 7
Feb 10 03:33:31 zbook systemd[1]: cpupower.service: Deactivated successfully.
Feb 10 03:33:31 zbook systemd[1]: Finished Set all cores to performance.
Feb 10 03:47:06 zbook systemd[1]: /etc/systemd/system/cpupower.service:8: Missing '=', ignoring line.
Feb 10 03:47:06 zbook systemd[1]: /etc/systemd/system/cpupower.service:9: Unknown key name 'Description' in section 'Install', ignoring.
Feb 10 03:47:06 zbook systemd[1]: /etc/systemd/system/cpupower.service:15: Missing '=', ignoring line.

It was deactivated again, yet the governor remained set to performance. So, it works fine when it’s started after the system is running but when started at boot it doesn’t persist.

EDIT 2: I just went to see the symlink and it appears to not be linked correctly, but it must be linked correctly if it works for a second. Right?

╭─user@zbook in /etc/systemd/system🔒
╰─λ ls -l
drwxr-xr-x   - root 29 Oct  2023  basic.target.wants
drwxr-xr-x   - root 29 Oct  2023  bluetooth.target.wants
drwxr-xr-x   - root 29 Oct  2023  getty.target.wants
drwxr-xr-x   - root  9 Feb 16:34  graphical.target.wants
drwxr-xr-x   - root 29 Oct  2023  local-fs.target.wants
drwxr-xr-x   - root 10 Feb 03:04  multi-user.target.wants
drwxr-xr-x   - root  9 Feb 15:34  network-online.target.wants
drwxr-xr-x   - root  9 Feb 15:34  sockets.target.wants
drwxr-xr-x   - root  9 Feb 15:34  sysinit.target.wants
drwxr-xr-x   - root  9 Feb 16:20  timers.target.wants
.rw-r--r-- 333 root 10 Feb 01:59  cpupower.service
lrwxrwxrwx   - root 29 Oct  2023  dbus-org.bluez.service -> /usr/lib/systemd/system/bluetooth.service
lrwxrwxrwx   - root  9 Feb 15:34  dbus-org.freedesktop.Avahi.service -> /usr/lib/systemd/system/avahi-daemon.service
lrwxrwxrwx   - root  9 Feb 15:34  dbus-org.freedesktop.ModemManager1.service -> /usr/lib/systemd/system/ModemManager.service
lrwxrwxrwx   - root  9 Feb 15:34  dbus-org.freedesktop.nm-dispatcher.service -> /usr/lib/systemd/system/NetworkManager-dispatcher.service
lrwxrwxrwx   - root 29 Oct  2023  dbus-org.freedesktop.oom1.service -> /usr/lib/systemd/system/systemd-oomd.service
lrwxrwxrwx   - root  9 Feb 15:34  dbus-org.freedesktop.timesync1.service -> /usr/lib/systemd/system/systemd-timesyncd.service
lrwxrwxrwx   - root  9 Feb 15:34  default.target -> /usr/lib/systemd/system/graphical.target
lrwxrwxrwx   - root  9 Feb 15:34  display-manager.service -> /usr/lib/systemd/system/sddm.service
.rw-r--r-- 178 root 20 Oct  2023  [email protected]

This is the output when I disable and re-enable it. It appears to link correctly.

╭─user@zbook in /etc/systemd/system🔒 took 9ms
╰─λ sudo systemctl disable cpupower.service
[sudo] password for user:
Removed "/etc/systemd/system/multi-user.target.wants/cpupower.service".

╭─user@zbook in /etc/systemd/system🔒 as 🧙 took 9s
╰─λ sudo systemctl enable cpupower.service
Created symlink /etc/systemd/system/multi-user.target.wants/cpupower.service → /etc/systemd/system/cpupower.service.

As you can see, I’m quite confused. I’m missing something here. Please help…lol.

Here’s my inxi:

╭─user@zbook in ~ as 🧙 took 30ms
╰─λ garuda-inxi
System:
Kernel: 6.7.4-zen1-1-zen arch: x86_64 bits: 64 compiler: gcc v: 13.2.1
clocksource: tsc available: hpet,acpi_pm
parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
root=UUID=19e87336-1cd6-4729-b046-8694f8d96d13 rw rootflags=subvol=@
quiet loglevel=3 ibt=off
Desktop: KDE Plasma v: 5.27.10 tk: Qt v: 5.15.12 wm: kwin_x11 vt: 2
dm: SDDM Distro: Garuda Linux base: Arch Linux
Machine:
Type: Laptop System: HP product: HP ZBook 15 G3 v: N/A
serial: <superuser required> Chassis: type: 10 serial: <superuser required>
Mobo: HP model: 80D5 v: KBC Version 10.75 serial: <superuser required>
UEFI: HP v: N81 Ver. 01.52 date: 10/28/2020
Battery:
ID-1: BAT0 charge: 62.2 Wh (76.6%) condition: 81.2/90.0 Wh (90.3%)
volts: 11.8 min: 11.1 model: Hewlett-Packard Primary type: Li-ion
serial: <filter> status: not charging cycles: 24
CPU:
Info: model: Intel Core i7-6820HQ bits: 64 type: MT MCP arch: Skylake-S
gen: core 6 level: v3 note: check built: 2015 process: Intel 14nm family: 6
model-id: 0x5E (94) stepping: 3 microcode: 0xF0
Topology: cpus: 1x cores: 4 tpc: 2 threads: 8 smt: enabled cache:
L1: 256 KiB desc: d-4x32 KiB; i-4x32 KiB L2: 1024 KiB desc: 4x256 KiB
L3: 8 MiB desc: 1x8 MiB
Speed (MHz): avg: 1803 high: 3504 min/max: 800/3600 scaling:
driver: intel_pstate governor: performance cores: 1: 3488 2: 800 3: 800
4: 800 5: 800 6: 3504 7: 3436 8: 800 bogomips: 43198
Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
Vulnerabilities: <filter>
Graphics:
Device-1: Intel HD Graphics 530 vendor: Hewlett-Packard driver: i915
v: kernel arch: Gen-9 process: Intel 14n built: 2015-16 ports: active: eDP-1
empty: DP-1, DP-2, DP-3, HDMI-A-1, HDMI-A-2, HDMI-A-3 bus-ID: 00:02.0
chip-ID: 8086:191b class-ID: 0300
Device-2: NVIDIA GM107GLM [Quadro M2000M] vendor: Hewlett-Packard
driver: nvidia v: 545.29.06 alternate: nouveau,nvidia_drm non-free: 545.xx+
status: current (as of 2023-10; EOL~2026-12-xx) arch: Maxwell code: GMxxx
process: TSMC 28nm built: 2014-2019 pcie: gen: 3 speed: 8 GT/s lanes: 16
ports: active: none empty: DP-4,DP-5,DP-6 bus-ID: 01:00.0
chip-ID: 10de:13b0 class-ID: 0300
Display: x11 server: X.Org v: 21.1.11 with: Xwayland v: 23.2.4
compositor: kwin_x11 driver: X: loaded: modesetting,nvidia dri: iris
gpu: i915 display-ID: :0 screens: 1
Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x285mm (20.00x11.22")
s-diag: 582mm (22.93")
Monitor-1: eDP-1 mapped: eDP-1-1 model: LG Display 0x046f built: 2014
res: 1920x1080 hz: 60 dpi: 141 gamma: 1.2 size: 345x194mm (13.58x7.64")
diag: 396mm (15.6") ratio: 16:9 modes: 1920x1080
API: EGL v: 1.5 hw: drv: intel iris drv: nvidia platforms: device: 0
drv: nvidia device: 1 drv: iris device: 3 drv: swrast surfaceless:
drv: nvidia x11: drv: nvidia inactive: gbm,wayland,device-2
API: OpenGL v: 4.6.0 compat-v: 4.5 vendor: nvidia mesa v: 545.29.06
glx-v: 1.4 direct-render: yes renderer: Quadro M2000M/PCIe/SSE2
memory: 3.91 GiB
API: Vulkan v: 1.3.276 layers: 7 device: 0 type: discrete-gpu
name: Quadro M2000M driver: nvidia v: 545.29.06 device-ID: 10de:13b0
surfaces: xcb,xlib
Audio:
Device-1: Intel 100 Series/C230 Series Family HD Audio
vendor: Hewlett-Packard driver: snd_hda_intel v: kernel
alternate: snd_soc_avs bus-ID: 00:1f.3 chip-ID: 8086:a170 class-ID: 0403
Device-2: NVIDIA GM107 High Definition Audio [GeForce 940MX]
vendor: Hewlett-Packard driver: snd_hda_intel v: kernel pcie: gen: 3
speed: 8 GT/s lanes: 16 bus-ID: 01:00.1 chip-ID: 10de:0fbc class-ID: 0403
API: ALSA v: k6.7.4-zen1-1-zen status: kernel-api with: aoss
type: oss-emulator tools: N/A
Server-1: sndiod v: N/A status: off tools: aucat,midicat,sndioctl
Server-2: PipeWire v: 1.0.3 status: active with: 1: pipewire-pulse
status: active 2: wireplumber status: active 3: pipewire-alsa type: plugin
4: pw-jack type: plugin tools: pactl,pw-cat,pw-cli,wpctl
Network:
Device-1: Intel Wireless 8260 driver: iwlwifi v: kernel pcie: gen: 1
speed: 2.5 GT/s lanes: 1 bus-ID: 02:00.0 chip-ID: 8086:24f3 class-ID: 0280
IF: wlp2s0 state: up mac: <filter>
Bluetooth:
Device-1: Intel Bluetooth wireless interface driver: btusb v: 0.8 type: USB
rev: 2.0 speed: 12 Mb/s lanes: 1 mode: 1.1 bus-ID: 1-12:3 chip-ID: 8087:0a2b
class-ID: e001
Report: btmgmt ID: hci0 rfk-id: 0 state: down bt-service: enabled,running
rfk-block: hardware: no software: no address: <filter> bt-v: 4.2 lmp-v: 8
status: discoverable: no pairing: no
Drives:
Local Storage: total: 476.94 GiB used: 160.51 GiB (33.7%)
SMART Message: Unable to run smartctl. Root privileges required.
ID-1: /dev/sda maj-min: 8:0 vendor: Fanxiang model: S101Q 512GB
size: 476.94 GiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s
tech: SSD serial: <filter> fw-rev: 4A0 scheme: GPT
Partition:
ID-1: / raw-size: 64 GiB size: 64 GiB (100.00%) used: 24.58 GiB (38.4%)
fs: btrfs dev: /dev/sda2 maj-min: 8:2
ID-2: /boot/efi raw-size: 300 MiB size: 299.4 MiB (99.80%)
used: 584 KiB (0.2%) fs: vfat dev: /dev/sda1 maj-min: 8:1
ID-3: /home raw-size: 284.65 GiB size: 284.65 GiB (100.00%)
used: 135.93 GiB (47.8%) fs: btrfs dev: /dev/sda3 maj-min: 8:3
ID-4: /var/log raw-size: 64 GiB size: 64 GiB (100.00%)
used: 24.58 GiB (38.4%) fs: btrfs dev: /dev/sda2 maj-min: 8:2
ID-5: /var/tmp raw-size: 64 GiB size: 64 GiB (100.00%)
used: 24.58 GiB (38.4%) fs: btrfs dev: /dev/sda2 maj-min: 8:2
Swap:
Kernel: swappiness: 1 (default 60) cache-pressure: 100 (default) zswap: no
ID-1: swap-1 type: zram size: 46.84 GiB used: 1.5 MiB (0.0%) priority: 100
comp: zstd avail: lzo,lzo-rle,lz4,lz4hc,842 max-streams: 8 dev: /dev/zram0
Sensors:
System Temperatures: cpu: 46.0 C pch: 43.5 C mobo: N/A gpu: nvidia
temp: 41 C
Fan Speeds (rpm): N/A
Info:
Processes: 283 Uptime: 48m wakeups: 0 Memory: total: 48 GiB note: est.
available: 46.84 GiB used: 3.85 GiB (8.2%) Init: systemd v: 255
default: graphical tool: systemctl Compilers: gcc: 13.2.1 Packages:
pm: pacman pkgs: 1889 libs: 545 tools: octopi,pamac,paru Shell: fish
v: 3.7.0 running-in: konsole inxi: 3.3.31
Garuda (2.6.23-1):
System install date:     2024-02-09
Last full system update: 2024-02-09
Is partially upgraded:   No
Relevant software:       snapper NetworkManager dracut nvidia-dkms
Windows dual boot:       No/Undetected
Failed units:

It is normal for a oneshot service. A oneshot should perform a specific task and then exit, rather than running continuously in the background. After completion it will be deactivated until it is triggered or otherwise restarted again.

For this task, I think a oneshot service is appropriate so this all looks fine to me. :+1:

1 Like

Hey there Dave. :wave:

Perhaps you might want to add a 5 second sleep interval in the service file. Sometimes adding a delay before the service is fully executed is enough to get things working properly.

See the sections regarding the usage of ExecStartPre= in a service:

https://wiki.archlinux.org/title/systemd

https://man.archlinux.org/man/systemd.service.5

1 Like

It looks fine to me too, but it doesn’t work fine. I’m thinking maybe it’s starting up too soon or something because after it sets the governor and exits the governor returns to powersave.

Wow I had just typed that when you messaged. That’s exactly what I wanted to ask about. Lol. I was wondering if a sleep timer was allowed in systemd services.

Read the documentation it’s very simple, add this line to the service:

ExecStartPre=/usr/bin/sleep 5

Actually I just found the answer on another distros forum. It was the power-profiles-daemon.service changing it after cpupower.service did. It said it was important and some features wouldn’t work without it, so they suggested to mask it instead of disable it, which I did, and rebooted. Cpupower.service is working fine now. Would it be proper etiquette to link to another distro’s forum as the solution I found? It was our kinfolk over in the EndeavorOS forum that had posted the solution I found.

That’s not to say a sleep timer wouldn’t have worked too. I bet it would have. I may do that instead that way I’ve still got power-profiles-daemon.service running and the desired result too. I’m going to try it.

1 Like

Sure, as long as it’s forum has been around as longs as ours, and it is not in the habit of depracating their forum on a regular basis.

We don’t need our forum full of dead links.

lol, somehow I did not pick up on that specific detail. :face_with_hand_over_mouth:

If you want to keep the power-profiles-daemon.service running but want it to use the performance governor instead of power save, I believe that is supported. Check in the config, it may be at /etc/power-profiles-daemon.conf. Do you have a section like this?

[RuntimeProfileSelection]
DefaultOnACPower=powersave
DefaultOnBatteryPower=powersave

Change the AC one to “performance” and restart the service.

1 Like

Ah…I see what you mean. Well, it’s EndeavourOS which I’d bet many here are fond of, and I think it’s been around longer than Garuda, but I’d have to look it up to be sure. I’ll link it as a courtesy and a thanks, but also spell out the solution here just in case. I hope that will do.

I tried a sleep timer of 5 and 10 and neither worked without power-profiles-daemon.service being masked.

I simply ran

sudo systemctl mask power-profiles-daemon.service

and rebooted and cpupower.service was then able to successfully set the governor.

If I want to go back to letting power-profiles-daemon.service set the governor I’d run

sudo systemctl disable --now cpupower.service
sudo systemctl unmask power-profiles-daemon.service
sudo systemctl enable --now  power-profiles-daemon.service

I found the answer here in the EndeavourOS Forum:

Thank you. That’s good to know, but after I get my new battery I will probably want to boot with 2 cores on performance and the other 6 on powersave, so I think I’ll stick with cpupower, at least for now.

2 Likes

Thank you for your help, @BluishHumility and @tbg . I learned a lot from this one.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.