How to turn off all power-saving features to be sure everything runs at full speed?

Continuing the discussion from Librem 5 Wi-Fi performance:

While I understand that some effort has gone into reducing the power consumption to increase battery life and avoid overheating, for testing purposes it would be good to be able to turn all that off.

Suppose my battery is fully charged, the charging cable is plugged in, and I am not worried about overheating, at my own risk. Is there a way to tell the Librem 5 to skip any attempts at power saving and just let everything run at full speed?

Related question: which power saving features exist, and how can we check if they are currently being used? (For example, if the CPU is running at a reduced frequency, how to check that, and which policy is used to control it?)

4 Likes

This is what I answered in the other thread:

1 Like

The DRAM clock drops from 800MHz to 25MHz when the screen is off.

This will make it run at full speed all the time:

echo performance | sudo tee /sys/class/devfreq/3d400000.memory-controller/governor
echo performance | sudo tee /sys/class/devfreq/32700000.interconnect//governor

There’s a patchset that implements simple_ondemand governor support so the frequency scales with used bandwidth automatically, but it’s experimental and not merged: https://source.puri.sm/Librem5/linux-next/-/merge_requests/149

There’s also CPU frequency scaling (with two values - 1.0GHz and 1.5GHz), but this one scales automatically on demand already (and can be adjusted with standard cpufreq tools if needed).

4 Likes

Thanks! I tested powertop now, it shows the following “Tunables” that can be toggled between “Good” and “Bad” which I think mean “good for reducing power consumption” and “bad for reducing power consumption”:

PowerTOP 2.8      Overview   Idle stats   Frequency stats   Device stats   Device Freq stats   Tunables

   Bad           Wireless Power Saving for interface wlan0
   Bad           VM writeback timeout
   Good          Bluetooth device interface status
   Good          Autosuspend for USB device Qualcomm CDMA Technologies MSM [Qualcomm, Incorporated]
   Good          Autosuspend for USB device xHCI Host Controller [usb1]
   Good          Autosuspend for USB device Ultra Fast Media Reader [Generic]
   Good          Autosuspend for unknown USB device 1-1 (0424:2640)
   Good          Autosuspend for USB device xHCI Host Controller [usb2]
   Good          I2C Device 2-001a has no runtime power management
   Good          Runtime PM for I2C Adapter i2c-2 (30a40000.i2c)
   Good          Runtime PM for I2C Adapter i2c-3 (30a50000.i2c)
   Good          Runtime PM for I2C Adapter i2c-0 (30a20000.i2c)
   Good          Runtime PM for I2C Adapter i2c-1 (30a30000.i2c)
   Good          I2C Device 3-0010 has no runtime power management
   Good          I2C Device 1-0060 has no runtime power management
   Good          Wake-on-lan status for device wlan0
   Good          Wake-on-lan status for device wwan0
   Good          Wake-on-lan status for device usb0

I tried setting all of them to “Bad” (which should be good for performance) but so far I did not see any clear effect. Setting the top one, “Wireless Power Saving for interface wlan0” to “Good” seemed to stop WiFi totally, hanging my ssh session. :slight_smile:

1 Like

Thanks @dos – just tried those commands for the DRAM clock and that seems to work, the difference can be seen using powertop.

This, however, does not seem to be working for me. Seems like the CPU us always at 1.0GHz no matter what I do.

The cpufreq-info command shows the following:

analyzing CPU 0:
  driver: cpufreq-dt
  CPUs which run at the same hardware frequency: 0 1 2 3
  CPUs which need to have their frequency coordinated by software: 0 1 2 3
  maximum transition latency: 230 us.
  hardware limits: 1000 MHz - 1.50 GHz
  available frequency steps: 1000 MHz, 1.50 GHz
  available cpufreq governors: ondemand, userspace, powersave, performance, schedutil
  current policy: frequency should be within 1000 MHz and 1000 MHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 1000 MHz.
  cpufreq stats: 1000 MHz:100.00%, 1.50 GHz:0.00%  (2)

So that “available frequency steps: 1000 MHz, 1.50 GHz” agrees with what you say, but I failed to change to the 1.50 GHz setting. Tried the cpufreq-set in various ways including setting “governor” to different things but it seems whatever I do the frequency stays at 1000 MHz. Does anyone know the exact commands that should be used to change the current CPU frequency to 1.50 GHz?

Edit: another question: if the CPU frequency is supposed to be scaled automatically by default, what could I do to trigger that, to see it happen? Should it be enough to have one CPU-intensive process running a single thread for a few seconds, or it needs to be several processes/threads and/or longer time to make the CPU scaling kick in?

Check the CPU temperature - there’s a threshold where 1.5GHz gets disabled (50°C IIRC), and then another one where idle injection gets triggered (55°C IIRC, can be checked in the device tree).

5 Likes

Ah, that explains it. Thanks!

After having it turned off for a while to cool off, now I did see it running at 1.50 GHz:

purism@pureos:~$ cpufreq-info | grep current
  current policy: frequency should be within 1.50 GHz and 1.50 GHz.
  current CPU frequency is 1.50 GHz.
  current policy: frequency should be within 1.50 GHz and 1.50 GHz.
  current CPU frequency is 1.50 GHz.
  current policy: frequency should be within 1.50 GHz and 1.50 GHz.
  current CPU frequency is 1.50 GHz.
  current policy: frequency should be within 1.50 GHz and 1.50 GHz.
  current CPU frequency is 1.50 GHz.

and then after a while when it got warm again, it was down to 1000 MHz again, so that makes sense.

1 Like

Talk to Scotty, he may get you ten percent more power from those dilithium crystals!

1 Like

It may have already been mentioned but there are CPU 5, 6 that are disabled, i imagine those are two low power cores that arent used / supported currently?

Activating those and letting them run all the background daemons and services would speed up CPU 1-4 because it would free up their resources to do important # crunching.

The N-class HP3000 had 8 CPU slots, two of which were disabled. It took a firmware hack to enable them. Albeit they still went to the main CPU pool. They received instructions as as a process found them.

1 Like

@Skalman could you describe how you installed cpufreq all my tries failed due to dependency issues libc6 2.32 and other dependency issues. I downloaded packages from debian repository.

I’m not sure what you’re talking about. There are only 4 CPU cores (plus 1 Cortex-M4 core, but that’s not a kind of core you’d use in Linux).

All you need to install cpufreq on PureOS is sudo apt install cpufrequtils - but beware that having it installed switches the governor in use from schedutil to ondemand by default, so I’d rather recommend looking at contents of /sys/devices/system/cpu/cpufreq/policy0/ instead. You could also do sudo systemctl disable --now cpufrequtils.service after installation.

2 Likes

Worked perfectly, enabled cpufrequtils with powersave with no ill effects so far:

added /etc/default/cpufrequtils
#content
GOVERNOR=“powersave”
MAX_SPEED=“1.3GHz”
MIN_SPEED=“1.0GHz”
Not sure what all the other options are, but so far i can tell the cpufreq service is running with CPUs running at 1.0GHz (all 4 cores), without any issues.

Regarding this thread i imagine setting the min frequency to 1.5GHz would then give you the max speed (but probably burn a hole in the pocket).

1 Like

Now @dos already answered this but I can add the way I found out which package to install. If you think there is a command X that belongs to some package you have not installed, and the command is not exactly the same as the package name, then you can use some other Debian machine and there you install apt-file, then run apt update and then use apt-file find X and it will show you a list of packages that contain the file X.

In this case, for the cpufreq-info command:

$ apt-file find cpufreq-info 
cpufrequtils: /usr/bin/cpufreq-info       
cpufrequtils: /usr/share/man/man1/cpufreq-info.1.gz

Sometimes the list is long, then it helps to write the full path to the file you are looking for:

$ apt-file find /usr/bin/cpufreq-info
cpufrequtils: /usr/bin/cpufreq-info

Unfortunately apt-file does not seem to work on PureOS, but that does not matter so much because the package you are looking for is most likely the same on PureOS so it works fine to use another Debian-based system for that. That is, if you are like me and have machines running variants of Debian lying around in every room of the house. :wink:

Are you sure that is working? There is no governor named “powersafe”, only “powersave”.

Per my previous, each chip (had to buy extras) had a heat sink tower 5 inches tall, bolted down.

your correct bad typo i fixed it