[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Issue with disabling Intel turbo boost via systemd



Hi,

I have frequent warning/4 entries in my journalctl like this one (dozens/day):
kernel: mce: CPU[X]: Package temperature above threshold, cpu clock throttled

So I decided some time ago to create the following systemd service (/etc/systemd/system/disable-turbo-boost.service) in order to deactivate my Intel processor turbo boost:
[Unit]
Description=Disable turbo boost on Intel CPU

[Service]
ExecStart=/bin/sh -c "/usr/bin/echo 1 >/sys/devices/system/cpu/intel_pstate/no_turbo"
ExecStop=/bin/sh -c "/usr/bin/echo 0 >/sys/devices/system/cpu/intel_pstate/no_turbo"
RemainAfterExit=yes

[Install]
WantedBy=sysinit.target

I enabled this service:
systemctl enable disable-turbo-boost.service

After some tests, I thought everything was ok with this service but today I've just discovered that my warning/4 are always triggered. Here are 2 interesting outputs:

systemctl status disable-turbo-boost.service 
disable-turbo-boost.service - Disable turbo boost on Intel CPU
   Loaded: loaded (/etc/systemd/system/disable-turbo-boost.service; enabled; vendor preset: enabled)
   Active: active (exited) since Mon 2020-05-25 10:26:20 CEST; 1 weeks 5 days ago
Main PID: 5428 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   Memory: 0B
   CGroup: /system.slice/disable-turbo-boost.service <http://system.slice/disable-turbo-boost.service>
may 25 10:26:20 systemd[1]: Started Disable turbo boost on Intel CPU.

cat /sys/devices/system/cpu/intel_pstate/no_turbo
0

As you can see, turbo boost is still active (no no_turbo) despite disable-turbo-boost.service being active as well!

However, if I stop/start/status the same service, I get the following:

systemctl stop disable-turbo-boost.service

systemctl start disable-turbo-boost.service

systemctl status disable-turbo-boost.service
disable-turbo-boost.service - Disable turbo boost on Intel CPU
   Loaded: loaded (/etc/systemd/system/disable-turbo-boost.service; enabled; vendor preset: enabled)
   Active: active (exited) since Sat 2020-06-06 16:34:08 CEST; 3s ago
  Process: 23659 ExecStart=/bin/sh -c /usr/bin/echo 1 >/sys/devices/system/cpu/intel_pstate/no_turbo (code=exited, status=0/SUCCESS)
Main PID: 23659 (code=exited, status=0/SUCCESS)
jun 06 16:34:08 systemd[1]: Started Disable turbo boost on Intel CPU.

cat /sys/devices/system/cpu/intel_pstate/no_turbo
1

Now my turbo boost is deactivated as intended while my service is active...

Do you have an idea why my turbo boost was not active anymore please?
Is it possible that another prcess put the "0" value after my service was launched the last time? If so, how to know which one?
Lastly, why don't my 2 systemctl status commands  show the exact same kinds of outputs (the first one mentions "Tasks", "Memory" and "CGroup" while the 2nd one tells us about "Process")?

NB: I run Debian 10 (kernel 5.4.8-1~bpo10+1) on a Lenovo ThinkPad X390 Quad Core i7-8565U.

Thank you in advance :)
Best regards,
l0f4r0


Reply to: