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

Thomas HUMMEL thomas.hummel at pasteur.fr
Tue Jul 12 16:55:14 UTC 2022


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


More information about the systemd-devel mailing list