Powertop.service is not applying AutoTune

Hi all!

I wanted to optimize battery life on my notebook and installed powertop. I followed the instruction in the Archwiki to setup a system service using powertop that should be able to apply the optimized setting on boot.

sudo systemctl status powertop.service after a start shows the service did run:

● powertop.service - Powertop tunings
     Loaded: loaded (/etc/systemd/system/powertop.service; enabled; vendor pres>
     Active: inactive (dead) since Sat 2021-05-01 13:46:42 CEST; 35s ago
    Process: 1486 ExecStart=/usr/bin/powertop --auto-tune (code=exited, status=>
   Main PID: 1486 (code=exited, status=0/SUCCESS)

Mai 01 13:46:41 computer powertop[1486]: modprobe cpufreq_stats failedLoaded 0>
Mai 01 13:46:41 computer powertop[1486]: RAPL device for cpu 0
Mai 01 13:46:41 computer powertop[1486]: RAPL Using PowerCap Sysfs : Domain Ma>
Mai 01 13:46:41 computer powertop[1486]: RAPL device for cpu 0
Mai 01 13:46:41 computer powertop[1486]: RAPL Using PowerCap Sysfs : Domain Ma>
Mai 01 13:46:41 computer powertop[1486]: Devfreq not enabled
Mai 01 13:46:41 computer powertop[1486]: glob returned GLOB_ABORTED
Mai 01 13:46:42 computer powertop[1486]: Leaving PowerTOP
Mai 01 13:46:42 computer systemd[1]: powertop.service: Succeeded.
Mai 01 13:46:42 computer systemd[1]: Finished Powertop tunings.

However running powertop --html=powerreport.html shows that the optimizations have not been applied! Manually running sudo powertop --auto-tune and generating the power report again shows that the optimizations have been applied.

The question is why is the service unable to apply the optimizations while running the command manually is able to do so?

Thanks for any tips in advance!

As far as I know, in a default installation of Manjaro, another power saving tool is already installed and active.

tlp

check with:

systemctl status tlp.service

It could be that this is still active and interfering with your efforts to do a similar thing with powertop.

2 Likes

I don’t think these are mutually exclusive, since powertop is also preinstalled on Manjaro. While TLP has a myriad of settings, I see none addressing the suggestion powertop has listed me as missing optimizations. TLP seems to do general things like setting schedulers and frequencies, while powertop is suggesting specific flags that need to be set in certain files.

Still it does not really make sense to me how the powertop.service, which is essentially running the powertop --auto-tune command once (Type=oneshot) on startup, has no effect, while at the same time, manually executing the command after startup is working as intended.

It was just a guess, a possible reason.
What is certain is: powertop is not by default ran as a service.
I’d definitely make sure that tlp is disabled.

I don’t know why the command would fail to have the expected result when ran as a oneshot systemd.service
while it works when ran on it’s own.

There is still the possibility to go with the recommended way to apply the settings via module parameters, sysctl …

It’s perhaps a bit of work, but you only need to do it once.

1 Like

By default, powertop is just a tool, no service is running.

Sure, but the service, as used in the link above, is just the systemd way of running a command on startup. However there seems to be something wrong with the way systemd handels things. I tought that maybe there is an issue with powertop so I copied powertop’s suggestions into a script in my home folder, made it executable and changed the service file to run my script instead of the powertop command. systemctl status still says the script was executed successfully, but the changes do not persist when I am logged in. So I figure that there must have been a recent change in how systemd handles things.

the output of your command in the first post says that the service ran successfully …
something else seems to interfere

maybe (probably) there is a “verbose” switch so you’ll have something about what happens in the system log

is tlp disabled?

1 Like

This is the current service:

[Unit]
Description=Powertop tunings

[Service]
Type=oneshot
ExecStart=/home/sapiens/powertop.sh

[Install]
WantedBy=multi-user.target

This is the script:

#!/bin/bash
echo '1' > '/sys/module/snd_hda_intel/parameters/power_save'; 
echo 'auto' > '/sys/bus/i2c/devices/i2c-2/device/power/control';
echo 'auto' > '/sys/bus/i2c/devices/i2c-3/device/power/control'; 
echo 'auto' > '/sys/bus/i2c/devices/i2c-4/device/power/control'; 
echo 'auto' > '/sys/bus/i2c/devices/i2c-5/device/power/control'; 
echo 'auto' > '/sys/bus/usb/devices/1-9/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:00:04.0/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.2/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:00:15.1/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:03:00.0/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.0/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:02:00.0/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:00:1d.6/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.1/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:00:15.0/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:00:14.2/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:04:00.0/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:00:02.0/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:00:14.0/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.4/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.3/power/control'; 
echo 'auto' > '/sys/bus/pci/devices/0000:00:00.0/power/control';

This is systemctl status powertop.service

● powertop.service - Powertop tunings
     Loaded: loaded (/etc/systemd/system/powertop.service; enabled; vendor pres>
     Active: inactive (dead) since Sat 2021-05-01 19:33:06 CEST; 1min 57s ago
    Process: 1458 ExecStart=/home/sapiens/powertop.sh >
   Main PID: 1458 (code=exited, status=0/SUCCESS)

Mai 01 19:33:06 computer systemd[1]: Starting Powertop tunings...
Mai 01 19:33:06 computer systemd[1]: powertop.service: Succeeded.
Mai 01 19:33:06 computer systemd[1]: Finished Powertop tunings.

Seems everything right to me :unamused:

Maybe, I should have listened to you. I will try it out because you might be right. Since I just read “Attempting to run powertop --auto-tune on boot may overwrite TLP’s settings (depending on whether Powertop or TLP is invoked first in the boot order)”

Testing what @Nachlese suggested I can confirm running powertop as a service and TLP at the same time will lead to conflict. TLP will overwrite powertops autotune settings.

Also TLP settings seem plausible and more detailed than what powertop can do. I ran a diagnostic with AC attached and powertop made a lot of suggestions. However TLP is applying settings based on whether the AC is attached or not, so running the diagnostic again after detaching the AC lead to much fewer and different suggestions by powertop. From what I can tell, without diving to deep into specific options, TLP seems to do a decent job and any effort into manual configuration should rather be put into TLP`s config file, than into setting options powertop suggests. For more introduction into the topic I refer you to TLPs FAQ.

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