[systemd-devel] Disabling cpufreq/boost at boot time sometimes fails

Silvio Knizek killermoehre at gmx.net
Tue Jul 12 22:35:14 UTC 2022


Am Dienstag, dem 12.07.2022 um 18:55 +0200 schrieb Thomas HUMMEL:
> Hello,
> 
> I'm using systemd-239-45 on RHEL 8.4 x86_64 AMD nodes on which I disable 
> Turbo Core/Turbo Boost by writing '0' into the following file:
> 
> /sys/devices/system/cpu/cpufreq/boost
> 
> I want it to be disabled automatically at boot. For that matter I tried 
> 3 different ways (only one at a time)
> 
> 1) a service unit configured like this:
> 
> [Unit]
> Description=Disable CPU Turbo Boost
> 
> 
> [Service]
> # using tee here to have an output in journalctl to understand when this 
> service
> # fails to start
> ExecStart=/bin/sh -c "/usr/bin/echo 0 | /bin/tee 
> /sys/devices/system/cpu/cpufreq/boost"
> ExecStop=/bin/sh -c "/usr/bin/echo 1 | /bin/tee 
> /sys/devices/system/cpu/cpufreq/boost"
> RemainAfterExit=yes
> 
> [Install]
> WantedBy=sysinit.target
> 
> 2) adding an entry for systemd-tmpfiles-setup.service like this:
> 
> w /sys/devices/system/cpu/cpufreq/boost - - - - 0
> 
> 3) using modprobe.d like this:
> 
> install acpi_cpufreq  /sbin/modprobe --ignore-install acpi_cpufreq 
> $CMDLINE_OPTS && echo 0 > /sys/devices/system/cpu/cpufreq/boost
> 
> 
> I noticed that *sometimes* using 1) or 2) 
> /sys/devices/system/cpu/cpufreq/boost ended up with '1' instead of '0'
> 
> I didn't see any error in journal for 2) (tmpfiles.d option) and for 1) 
> (systemd service) I saw:
> 
> 
> Jul 04 15:06:25 xxxx systemd[1]: Started Disable CPU Turbo Boost.
> Jul 04 15:06:25 xxxx sh[2788]: /bin/tee: 
> /sys/devices/system/cpu/cpufreq/boost: Permission denied
> Jul 04 15:06:25 xxxx sh[2788]: 0
> Jul 04 15:06:25 xxxx systemd[1]: disable-cpu-turboboost.service: Main 
> process exited, code=exited, status=1/FAILURE
> Jul 04 15:06:25 xxxx systemd[1]: disable-cpu-turboboost.service: Failed 
> with result 'exit-code'.
> 
> I did not manage to find out if there were a race condition and if so 
> what ordering dependencies should be stated.
> I tried to compare a "working" and "not working" systemd-analyse output 
> but I did not find anything obvious (at least for me)
> 
> Besides, /sys is mounted in the fstab (as expected)
> 
> sysfs   /sys     sysfs    defaults       0 0
> 
> is there a corresponding transient .mount unit somewhere ?
> 
> Notes:
> 
> a) SELinux is disabled
> 
> b) I don't think any other service or process is touching the 
> /sys/devices/system/cpu/cpufreq/boost file
> 
> c) in the event the system boot up with the wrong value, manually echo 0 
> into the file (which exists) always work
> 
> Can you help me figuring in what direction I should look, if it is 
> systemd related at all ?
> 
> Thanks for your help
> 
> --
> Thomas HUMMEL

Hi,

first of all, no need for /sys in /etc/fstab. /sys will _always_ be
mounted by systemd.

Second, this sounds really depending on your used driver (acpi, amd, or
intel). Check out the documentation at
https://docs.kernel.org/admin-guide/pm/cpufreq.html and always check
the Arch wiki https://wiki.archlinux.org/title/CPU_frequency_scaling as
well.

Question I have is: why do you want to disable boosting?

BR
Silvio
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20220713/db4f1b44/attachment.sig>


More information about the systemd-devel mailing list