Systemd timer: better investigation/ battery saving with Xperia 10 III (4.5.0.19)

Hi together,
concerning → standby-battery-high-drain-on-xperia-10-iii
I try to use timer-function (instead of crontab) to disable

  1. Android app support
  2. some cpu’s
  3. perhaps further processes
    over night.

What I’ve done so far:

  • save script phone-sleep:
[root@Xperia10III defaultuser]# vi /usr/local/bin/phone-sleep
#!/bin/bash                                                                                                                                                                                                 
# Datei /usr/local/bin/phone-sleep                                                                                                                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                         # energy saving cpus      
echo 0 > /sys/devices/system/cpu/cpu1/online                                                                                                                                                                                                                                                                                                                                                  
echo 0 > /sys/devices/system/cpu/cpu2/online                                                                                                                                                                
echo 0 > /sys/devices/system/cpu/cpu3/online                                                                                                                                                                
echo 0 > /sys/devices/system/cpu/cpu4/online                                                                                                                                                                
echo 0 > /sys/devices/system/cpu/cpu5/online                                                                                                                                                                
echo 0 > /sys/devices/system/cpu/cpu6/online                                                                                                                                                                
echo 0 > /sys/devices/system/cpu/cpu7/online 

# Stop Android App Support   (after cpu's, otherwise they are still busy)                                                                                                                                                                        
dbus-send --system --dest=com.jolla.apkd.control --print-reply /com/jolla/apkd com.jolla.apkd.control.controlService boolean:false  
  • make executable:
[root@Xperia10III defaultuser]# chmod a+x /usr/local/bin/phone-sleep 
  • save .service-file:
[root@Xperia10III system]# vi /etc/systemd/system/phone-sleep.service
#Datei /etc/systemd/system/phone-sleep.service
[Unit]
Description=save battery by deactivating things
[Service]
ExecStart=/usr/local/bin/phone-sleep
  • save .timer file:
[root@Xperia10III system]# vi /etc/systemd/system/phone-sleep.timer
[Unit]
Description=phone-sleep timer

[Timer]
# OnActiveSec=3s
OnCalendar=22:00
Persistent=true

[Install]
WantedBy=basic.target
  • start job with:
[root@Xperia10III system]# systemctl reenable --now phone-sleep.timer
Removed /etc/systemd/system/basic.target.wants/phone-sleep.timer.
Created symlink /etc/systemd/system/basic.target.wants/phone-sleep.timer → /etc/systemd/system/phone-sleep.timer.

But: the commands aren’t done and I don’t know, why.
Can someone help me please to get this working?

I followed the example of → kofler.info and information of → archlinux.org.

What’s the status log of service/timer after failure?
Does the script work when executed manually?

In my first steps → “display down” with Situations the scripts worked (bash situations-sleep).

Here with systemd, I get the following outputs:

[root@Xperia10III system]# phone-sleep 
Error org.freedesktop.DBus.Error.ServiceUnknown: The name pcom.jolla.apkd.control was not provided by any .service files

[root@Xperia10III system]# systemctl status phone-sleep.timer 
● phone-sleep.timer - phone-sleep timer
   Loaded: loaded (/etc/systemd/system/phone-sleep.timer; enabled; vendor preset: enabled)
   Active: inactive (dead)
  Trigger: n/a

I know very few about systemd but for my hourly backup script, I use systemctl enable then systemctl start.

Typo. It’s com.jolla not pcom.jolla.

Hi nephros, it was really a typo, thanks.
Using systemctl enable --now phone-sleep.timer, everything works; systemctl list-timers shows my new timer, too.
I’ll try to get new measures with that in the next days.

EDIT:
In the same way, I created files for “phone-wake-up” for the morning, which enable things again.

I don’t know if ypur approach is a good idea. Disabling all except 1 core does not mean that you save energy. I think a better approach would be to limit the maximum frequency off all cores or switch to conservative governor. You also could use core_ctl to switch cores on and off depending on load.

But all thesestuff doesn’t change much on the battery drain, the best way would just to switch the phone off :wink:

Which is what zgovernor does, plus a couple of other things.
One could look at its example .ini files and do similar things with the timer/script (or just use zgovernonr itself).

1 Like

As expected by manual deactivating some time ago, it didn’t save more battery.
But now I do restart daily Situations and situations-sonar with the existing timer for a higher reliability ;-).
Miau, could you tell me, what command lines I could use to limit the max. frequencies (I’ve no experience with that)?
Edit: With htop I see “/vendor/bin/hw/android.hardware.sensor@2.1-service.multihal” consumes 0.6 -1,3% all the time. Could I disable that overnight, too - which command would that be?

For 6 small cores
echo some value > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

For two big cores
echo some value > /sys/devices/system/cpu/cpu7/cpufreq/scaling_max_freq

Available frequencies for either of those cores can be checked in scaling_available_frequencies file.

“some values”, what would you suggest for a low value?

Do I have to set up 6 lines for the small cores:
echo some value > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo some value > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
echo some value > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq

Or are the two lines you mentioned all I need?

Only those two lines are needed because setting the value for cpu0 sets it for all small cores, i.e. cpu0 - cpu5, and similarly setting a value for one of the big cores also sets it for the other one.

You can check which cpus are bound in cpufreq/affected_cpus file.

As for the right value, well, you’ll need to experiment with it. Just make sure to use one of the supported frequencies as listed in scaling_available_frequencies file. Note that they are different for small and big cores.

Also note that you can similarly modify mimimum frequencies using scaling_min_ freq files. This way you can allow cpus to slow down even more when idling, e.g. to 300 MHz instead of 576 MHz for the small cores and 300 instead of 787 MHz for the big ones.

Values for the little cores are

300000 576000 768000 1017600 1248000 1324800 1516800 1612800 1708800

and the 2 gold cores are

300000 787200 979200 1036800 1248000 1401600 1555200 1766400 1900800 2073600

I would try 1248000 on both cores as a starting point.

@nephros

Thanks, i didn’t know about this governor. I’ll have a look at it.

Have you ever see schedutil using the 300000mhz frequency when it is set? With ondemand governor the frequency drops down to 300000.

I couldn’t find a good documentary about schedutils governor tunables, so i don’t know what pl and rtg freq do.

But i also gave up investigating on this, because fiddling around with this stuff is nit worth it on the 10iii. The drain is somewhere else.

Thanks for your hints, I’ll try it out.

No, schedutil doesn’t seem to use 300 MHz even if it is set as min frequency. But ondemand does, and it generally tends to use lower frequencies when there’s no need to wind up the clocks…

1 Like

From what I tested myself and read in other forum articles: The high power drain of the Xperia 10 III (compared with the standard Android) is in general not significantly improved by:

  • disabling singles cores
  • limiting the maximum frequency off all cores
  • disabling Android app support or fingerprint-service

So if we can’t see any tasks with crest, which consume too much battery, we can rule out apps as the cause, too. And as assumed by others, that the problem lies in the AOSP, perhaps it would be worth a last try to disable some “vendor”-services at times. E.g. could be “/vendor/bin/hw/android.hardware.sensor@2.1-service.multihal” or similar things.
But I don’t know, what services exists and how they could be disabled with terminal-commands.