Set CPU powersave at boot in LinuxMint18

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
sofiasmith

Set CPU powersave at boot in LinuxMint18

Post by sofiasmith »

This tutorial is only for LinuxMint 18 and laters, because systemd init system starts on Sarah version.
To increase your laptop life is important to reduce cpu temperature. Temperature reduction CPU is possible setting cpu governor scaling to POWERSAVE.
The first thing I do after a system installation of Linux Mint 18 Sarah (Cinnamon-Mate-XFCE-KDE) is configure CPU governor to powersave and set it at system boot with systemd.
Install cpupower utility:

Code: Select all

$ sudo apt-get install linux-tools-common linux-tools-$(uname -r)
Verify CPU governors and current policy:

Code: Select all

$ cpupower -c all frequency-info
Set CPU governor to powersave:

Code: Select all

$ sudo cpupower -c all frequency-set -g powersave
Verify that the change is in effect:

Code: Select all

$ cpupower -c all frequency-info
And finally, set CPU governor to powersave, PERSISTENT at SYSTEM BOOT.
Create systemd service file to set CPU governor to powersave at system boot:

Code: Select all

$ cat << EOF | sudo tee /etc/systemd/system/cpupower.service

[Unit]

Description=CPU powersave

[Service]

Type=oneshot

ExecStart=/usr/bin/cpupower -c all frequency-set -g powersave

[Install]

WantedBy=multi-user.target

EOF
Reload systemd manager configuration:

Code: Select all

$ sudo systemctl daemon-reload
Enable service at boot time

Code: Select all

$ sudo systemctl enable cpupower.service
And that's all, every time you start your laptop (on AC / battery) your governor will be POWERSAVE, and the laptop cpu temperature as low as possible.
If you want to speed up your laptop and reduce his life, change your governor to PERFORMANCE with the same procedure changing powersave to performance.
PS.: Remember this is not valid LinuxMint 17.3 and previous versions, cause of systemd init system.
Jojje

Re: Set CPU powersave at boot in LinuxMint18

Post by Jojje »

Hi,

Thanks for the tutorial!
I tried it out on my Linux Mint 19 on a Lennovo Thinkpad T400.
It did not work at first but I discovered that there is a systemd service called ondemand.service which override the cpupower.service rule.
I added a After command to the service file under the [Unit] section.

Code: Select all

[Unit]
Description=CPU powersave
After=ondemand.service


It still did not work. I might have done something wrong or missed something, I am no expert at all on Linux. When I looked at the status of both ondemand and cpupower services it seemed as if ondemand started before cpupower but the executed its argument (starting cpu-freq setting the ondemand governors) after the cpupower service had run.
It may have to do with that the ondemand.service have Type=idle in the [Service] section which if I understand the systemd.service man page correctly means that the service starts but the execution of commands is delayed until other active jobs are done. After 5s delay it is executed, or something like that.
That would mean I guess that the ondemand service will start which then will make the cpupower start and execute, then after some seconds the ondemand service will execute its commands and hence overwrite the cpupower with setting the governors to ondemand again.

The solution I used was to just disable the ondemand service. Then it worked and the governors were set to powersave.

Hope that help someone. If anyone have another solution it would be interesting to see.

Best,
gm10

Re: Set CPU powersave at boot in LinuxMint18

Post by gm10 »

Jojje wrote: Mon Oct 15, 2018 8:49 amThe solution I used was to just disable the ondemand service. Then it worked and the governors were set to powersave.

Hope that help someone. If anyone have another solution it would be interesting to see.
I do insofar as the whole point of the ondemand.service is to set the governor to interactive/ondemand/powersave (in that priority, depending on availability), so I'm not sure what you or the thread's author (I'm pretty sure this was the same 2 years ago) are actually trying to achieve? If anything you could just modify that service.

You can check your current governor like this:

Code: Select all

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
and your available governors like this:

Code: Select all

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
Jojje

Re: Set CPU powersave at boot in LinuxMint18

Post by Jojje »

gm10 wrote: Mon Oct 15, 2018 9:18 am
I do insofar as the whole point of the ondemand.service is to set the governor to interactive/ondemand/powersave (in that priority, depending on availability), so I'm not sure what you or the thread's author (I'm pretty sure this was the same 2 years ago) are actually trying to achieve? If anything you could just modify that service.
Hi,
Yes I noticed that the ondemand service starts the set-cpufreq script which set the first governor available of the three. I am not sure either how much you gain in saving hardware in setting the powersave compared to ondemand or shedutils etc, which was the idea of the author as I understood it.

In modifying the original service or script, I usually avoid that as it can be overwritten by an update etc.
gm10

Re: Set CPU powersave at boot in LinuxMint18

Post by gm10 »

Jojje wrote: Mon Oct 15, 2018 9:49 am Yes I noticed that the ondemand service starts the set-cpufreq script which set the first governor available of the three. I am not sure either how much you gain in saving hardware in setting the powersave compared to ondemand or shedutils etc, which was the idea of the author as I understood it.

In modifying the original service or script, I usually avoid that as it can be overwritten by an update etc.
Fair enough. Depends what CPU you're using I suppose. The original powersave is simply about setting the CPU to the minimum supported frequency, but on recent intel CPUs there's only powersave and performance, and they're both scaling, with powersave being the default. I believe with AMD you still get the original static powersave, as on old intels, but I don't think that's a desirable setting.
Jojje

Re: Set CPU powersave at boot in LinuxMint18

Post by Jojje »

gm10 wrote: Mon Oct 15, 2018 10:23 am ...on recent intel CPUs there's only powersave and performance, and they're both scaling, with powersave being the default. I believe with AMD you still get the original static powersave, as on old intels, but I don't think that's a desirable setting.
Ok, thanks!
How about the conservative and schedutil? I have them too.
gm10

Re: Set CPU powersave at boot in LinuxMint18

Post by gm10 »

Jojje wrote: Mon Oct 15, 2018 10:33 am How about the conservative and schedutil? I have them too.
Very generally speaking, conservative scales slower (in both directions) while schedutil scales faster (but there is more to the latter). For more details I'll refer you to the kernel documentation, which also has the parameters you can pass to the governors to further tweak them: https://www.kernel.org/doc/Documentatio ... ernors.txt
User avatar
thx-1138
Level 8
Level 8
Posts: 2092
Joined: Fri Mar 10, 2017 12:15 pm
Location: Athens, Greece

Re: Set CPU powersave at boot in LinuxMint18

Post by thx-1138 »

...and...why not simply...
Jojje

Re: Set CPU powersave at boot in LinuxMint18

Post by Jojje »

Ok,
Thank you!
Post Reply

Return to “Tutorials”