Auto-cpufreq | Thinkpad with Intel Graphics appears to only stay in powersave governor mode when running on battery

Hi,

I thought I might post here for advice as I found two threads where 1 person seem to have the same problem as me.

  • When using only using battery power on my Thinkpad T450 (Ivy Bridge CPU) in EndeavorOS (Arch Linux) I noticed no matter what load I am applying to the laptop (e.g. playing a 4K video) I notice the laptop will stay in “Setting to use: “powersave” governor” and stay at a speed of “798 MHz” where turbo does turn on.

  • When the laptop is plugged into power I will see it switch to “Currently using: performance governor” ramp up to speed of “2195 MHz”.

The problem is the laptop in battery mode with the slower CPU speed will make it unusable under load (where video will just play audio and video just pauses).

I’m not sure if the only solution is to go back to the LTS Kernel 5.4 (previously this was a laptop running Manjaro).

Environment:

System:
  Host: mani Kernel: 5.10.55-1-lts x86_64 bits: 64 Desktop: GNOME 40.3
  Distro: EndeavourOS
Machine:
  Type: Laptop System: LENOVO ThinkPad T450

Battery:
  ID-1: BAT0 charge: 17.2 Wh (87.8%) condition: 19.6/23.2 Wh (84.4%)
  ID-2: BAT1 charge: 14.7 Wh (72.1%) condition: 20.4/23.5 Wh (87.0%)
CPU:
  Info: Dual Core Intel Core i5-5300U [MT MCP] speed: 2195 MHz
  min/max: 500/2200 MHz
Graphics:
  Device-1: Intel HD Graphics 5500 driver: i915 v: kernel
  Device-2: Chicony Integrated Camera type: USB driver: uvcvideo
  Display: wayland server: X.org 1.20.13 driver: loaded: i915
Info:
  Processes: 183 Uptime: 8m Memory: 15.51 GiB used: 1.56 GiB (10.0%) Shell: Zsh
  inxi: 3.3.05

Auto-CPUFreq Debug with Battery Alone

sudo auto-cpufreq --debug

-------------------------------------------------------------------------------

Linux distro: EndeavourOS rolling rolling
Linux kernel: 5.10.55-1-lts
Processor: Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
Cores: 4
Architecture: x86_64
Driver: intel_cpufreq

------------------------------ Current CPU stats ------------------------------

CPU max frequency: 2900 MHz
CPU min frequency: 500 MHz

Core    Usage   Temperature     Frequency
CPU0:     7.8%     46 °C      798 MHz
CPU1:     2.0%     46 °C      798 MHz
CPU2:     4.0%     44 °C      798 MHz
CPU3:     4.0%     44 °C      798 MHz

auto-cpufreq version:
fatal: not a git repository (or any of the parent directories): .git
CalledProcessError(128, ['git', 'describe', '--always'])

Python: 3.9.6
psutil package: 5.8.0
platform package: 1.0.8
click package: 8.0.1
/bin/sh: line 1: pip3: command not found
distro package

Computer type: Notebook
Battery is: discharging

auto-cpufreq system resource consumption:
cpu usage: 0.0 %
memory use: 0.1 %

Total CPU usage: 3.5 %
Total system load: 0.34
Average temp. of all cores: 45.0 °C

Currently using: powersave governor
Currently turbo boost is: off

-------------------------------------------------------------------------------

Auto-CPUFreq Debug with Battery and AC Power

sudo auto-cpufreq --debug
[sudo] password for rsruser:

-------------------------------------------------------------------------------

Linux distro: EndeavourOS rolling rolling
Linux kernel: 5.10.55-1-lts
Processor: Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
Cores: 4
Architecture: x86_64
Driver: intel_cpufreq

------------------------------ Current CPU stats ------------------------------

CPU max frequency: 2200 MHz
CPU min frequency: 500 MHz

Core    Usage   Temperature     Frequency
CPU0:     0.0%     44 °C     2195 MHz
CPU1:     0.0%     44 °C     2195 MHz
CPU2:     1.0%     45 °C     2195 MHz
CPU3:     1.0%     45 °C     2195 MHz

auto-cpufreq version:
fatal: not a git repository (or any of the parent directories): .git
CalledProcessError(128, ['git', 'describe', '--always'])

Python: 3.9.6
psutil package: 5.8.0
platform package: 1.0.8
click package: 8.0.1
/bin/sh: line 1: pip3: command not found
distro package

Computer type: Notebook
Battery is: charging

auto-cpufreq system resource consumption:
cpu usage: 0.0 %
memory use: 0.1 %

Total CPU usage: 1.3 %
Total system load: 0.48
Average temp. of all cores: 44.5 °C

Currently using: performance governor
Currently turbo boost is: off

-------------------------------------------------------------------------------

Source:

https://linrunner.de/tlp/settings/processor.html
https://wiki.archlinux.org/title/CPU_frequency_scaling#Scaling_governors

2 Likes

@Stephane @keybreak @zole052 @pebcak

Thought I would let you know I wrote this thread after reading both your input in the 2020 threads. Maybe you might have a suggestion as my Laptop runs an older Ivy Bridge Intel CPU. Maybe there is a work around to get my CPU to run at the faster speeds in battery mode?

Thank you.

1 Like

I wonder if cpupower could solve your issue.

https://wiki.archlinux.org/title/CPU_frequency_scaling#cpupower

Also:

You might want to experiment with setting the governor to ondemand or performance and see if it works the way you wanted it to.

1 Like

I probably forgot to mention that I am using TLP + Auto-CPUFreq. So are you suggesting that on battery alone that there is no way with this configuration to have the CPU automatically Scale up as the laptop gets more load?

If this is true then does that mean that Auto-CPUFreq will not be able to get the laptop to switch from “powersave govenor” to “performance governor”?

Technically the goal is to have the laptop to auto switch when on battery alone.

What happens when not using tlp if it isn’t even installed?

Hi Rick,

If I want to disable TLP … is the best way to just disable the service

E.g.
sudo systemctl stop tlp.service
sudo systemctl disable tlp.service

Then reboot and re-test?

I guess you could try that and see.

I’ve disabled the tlp.service and I can confirm that it is not started after the reboot (plus it normally shutdown the bluetooth radio which it didn’t).

So even when I have the disabled the tlp.service, the governor will only change from powersave to performance if I plug in the AC Adapter.

I was looking at the below article and it suggests switching to acpicpufreq

  • acpi-support
  • acpid
  • acpi

and also add the Kernel Setting “intel_pstate=disable”

The only issue with the suggestion is I do not see a “Acpi-support” package.

https://wiki.archlinux.org/title/CPU_frequency_scaling

https://wiki.archlinux.org/title/Power_management#Processors_with_Intel_HWP_(Intel_Hardware_P-state)_support

To try to implement acpi-cpufreq

The issue is caused because Intel Processors use the intel_pstate driver (Sandy Bridge and newer) which will force you to either the powersave or performance states.

To address this limitation and allow for tuning you can switch to “acpi-cpufreq” by disabling “intel_pstate” via a kernel switch

(1) Install ACPI packages

sudo pacman -S acpid acpi

Note: no ‘acpi-support’ package

(2) Edit the Grub boot configuration

sudo nano /etc/default/grub

(3) Add the “intel_pstate=disable” to the “GRUB_CMDLINE_LINUX_DEFAULT” configuration line.

FROM:
GRUB_CMDLINE_LINUX_DEFAULT=“resume=UUID=715c2972-1a51-4d73-89a0-86ea7bb5aa7f resume_offset=3127296… apparmor=1 lsm=lockdown,yama,apparmor”

TO:
GRUB_CMDLINE_LINUX_DEFAULT=“resume=UUID=715c2972-1a51-4d73-89a0-86ea7bb5aa7f resume_offset=3127296… apparmor=1 lsm=lockdown,yama,apparmor intel_pstate=disable”

(4) Update Grub Configuration

sudo grub-mkconfig -o /boot/grub/grub.cfg

(5) Reboot and test

(a) Make sure system switched to acpi-cpufreq

sudo tlp-stat -p
--- TLP 1.3.1 --------------------------------------------

+++ Processor
CPU model      = Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz

/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver    = acpi-cpufreq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor  = powersave
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors = conservative ondemand userspace powersave performance schedutil
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq  =   500000 [kHz]
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq  =  2300000 [kHz]
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies = 2301000 2300000 2200000 2000000 1900000 1800000 1700000 1500000 1400000 1300000 1100000 1000000 900000 800000 600000 500000 [kHz]

/sys/devices/system/cpu/cpu1/cpufreq/scaling_driver    = acpi-cpufreq
/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor  = powersave
/sys/devices/system/cpu/cpu1/cpufreq/scaling_available_governors = conservative ondemand userspace powersave performance schedutil
/sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq  =   500000 [kHz]
/sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq  =  2300000 [kHz]
/sys/devices/system/cpu/cpu1/cpufreq/scaling_available_frequencies = 2301000 2300000 2200000 2000000 1900000 1800000 1700000 1500000 1400000 1300000 1100000 1000000 900000 800000 600000 500000 [kHz]

/sys/devices/system/cpu/cpu2/cpufreq/scaling_driver    = acpi-cpufreq
/sys/devices/system/cpu/cpu2/cpufreq/scaling_governor  = powersave
/sys/devices/system/cpu/cpu2/cpufreq/scaling_available_governors = conservative ondemand userspace powersave performance schedutil
/sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq  =   500000 [kHz]
/sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq  =  2300000 [kHz]
/sys/devices/system/cpu/cpu2/cpufreq/scaling_available_frequencies = 2301000 2300000 2200000 2000000 1900000 1800000 1700000 1500000 1400000 1300000 1100000 1000000 900000 800000 600000 500000 [kHz]

/sys/devices/system/cpu/cpu3/cpufreq/scaling_driver    = acpi-cpufreq
/sys/devices/system/cpu/cpu3/cpufreq/scaling_governor  = powersave
/sys/devices/system/cpu/cpu3/cpufreq/scaling_available_governors = conservative ondemand userspace powersave performance schedutil
/sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq  =   500000 [kHz]
/sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq  =  2300000 [kHz]
/sys/devices/system/cpu/cpu3/cpufreq/scaling_available_frequencies = 2301000 2300000 2200000 2000000 1900000 1800000 1700000 1500000 1400000 1300000 1100000 1000000 900000 800000 600000 500000 [kHz]

/sys/devices/system/cpu/cpufreq/boost                  = 0

/sys/devices/system/cpu/cpu0/power/energy_perf_bias    =  8 (balance_power) [EPB]
/sys/devices/system/cpu/cpu1/power/energy_perf_bias    =  8 (balance_power) [EPB]
/sys/devices/system/cpu/cpu2/power/energy_perf_bias    =  8 (balance_power) [EPB]
/sys/devices/system/cpu/cpu3/power/energy_perf_bias    =  8 (balance_power) [EPB]

/sys/module/workqueue/parameters/power_efficient       = Y
/proc/sys/kernel/nmi_watchdog                          = 0

(b) Check Auto-CPUFreq debug output:

sudo auto-cpufreq --debug

-------------------------------------------------------------------------------

Linux distro: EndeavourOS rolling rolling
Linux kernel: 5.13.7-zen1-1-zen
Processor: Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
Cores: 4
Architecture: x86_64
Driver: acpi-cpufreq

------------------------------ Current CPU stats ------------------------------

CPU max frequency: 2300 MHz
CPU min frequency: 500 MHz

Core    Usage   Temperature     Frequency
CPU0:     7.0%     41 °C      798 MHz
CPU1:    11.0%     41 °C      500 MHz
CPU2:     8.0%     41 °C      500 MHz
CPU3:     4.0%     41 °C      500 MHz

auto-cpufreq version:
fatal: not a git repository (or any of the parent directories): .git
CalledProcessError(128, ['git', 'describe', '--always'])

Python: 3.9.6
psutil package: 5.8.0
platform package: 1.0.8
click package: 8.0.1
/bin/sh: line 1: pip3: command not found
distro package

Computer type: Notebook
Battery is: discharging

auto-cpufreq system resource consumption:
cpu usage: 0.0 %
memory use: 0.1 %

Total CPU usage: 7.3 %
Total system load: 0.84
Average temp. of all cores: 41.0 °C

Currently using: powersave governor
Currently turbo boost is: off

-------------------------------------------------------------------------------

So far the CPU speed is still held at 798Mhz when under a high load (TLP and CPU Freq are on).

I don’t know that, to be honest. But it is not working in practice as shown by your outputs. :thinking:

I understood the whole thing as if you wanted to have the governer set to performance both on AC and DC. Since you get that with auto-cpufreq when on AC, then the issue is to get that on DC as well? So if you just do away with auto-cpufreq and try the cpupower, won’t that resolve the issue?

When on DC try:
sudo cpupower frequency-set -g performance
and see if that works.

some other cpupower commands

detailed information about the CPU(s) can be displayed by running

$ cpupower frequency-info

Setting maximum and minimum frequencies

In some cases, it may be necessary to manually set maximum and minimum frequencies.

To set the maximum clock frequency (clock_freq is a clock frequency with units: GHz, MHz):

cpupower frequency-set -u clock_freq

To set the minimum clock frequency:

cpupower frequency-set -d clock_freq

To set the CPU to run at a specified frequency:

cpupower frequency-set -f clock_freq

@ricklinux @pebcak

I thought I might provide you with an update of my testing:

(1) Auto-CPUFreq alone with TLP and CPUPower shut off

Pretty much this tool will switch my systems governors settings at:

  • powersave on battery usage
  • performance on AC Power
  • I’ve tested this with both the Kernels 5.10 LTS and the latest Linux-Zen
  • Using the acpi-cpufreq vs intel_cpufreq does not change the result of being able to automatically switch governor settings when battery is the power source.
  • Using the Zen Kernel on Battery mode I notice the CPU switch between running at 500 Mhz and topping out at 798Mhz
  • My guess here is either something is changed\broken after Kernel 5.7 or Auto-CPUFreq needs to be updated to take int account the Intel processors behavior like the Ivy Bridge generation.
  • I’ve chosen to disable this service for now (sudo systemctl disable auto-cpufreq.service).

(2) TLP Alone

  • The advantage here are the advance battery management in Thinkpads and being able to control the other devices on the laptop(e.g. auto shutoff WAN and Bluetooth radios).
  • Whether you are using Battery or AC the CPU will always use the lower setting of 798 Mhz with the Governor policy of powersave.
  • I have this service enabled for now.

(3) CPU Power with TLP and Auto-CPUFreq disabled.

I can use cpupower to change the govenor settings

  • Governor to Conservative (sudo cpupower frequency-set -g conservative)
  • Governor to Ondemand ( sudo cpupower frequency-set -g ondemand)
  • I also installed the cpupower-gui so I can switch the governor settings in demand or create a profile.

Remaining Problem to this work around:

  • I created a profile called 'Conservative" via the GUI.
  • I’ve enabled the cpupower.service (sudo systemctl enable cpupower.service)

Even though the cpupower.service starts correctly, it does not pick the Conservative profile I created automatically.

sudo systemctl status cpupower.service
● cpupower.service - Apply cpupower configuration
     Loaded: loaded (/usr/lib/systemd/system/cpupower.service; enabled; vendor preset: >
     Active: active (exited) since Fri 2021-08-06 19:30:31 EDT; 47min ago
    Process: 647 ExecStart=/usr/lib/systemd/scripts/cpupower (code=exited, status=0/SUC>
   Main PID: 647 (code=exited, status=0/SUCCESS)
        CPU: 5ms


Aug 06 19:30:31 mani systemd[1]: Starting Apply cpupower configuration…
Aug 06 19:30:31 mani systemd[1]: Finished Apply cpupower configuration.


So I am trying to read through the documentation to figure out why the profile I set is not loading at boot.

![image|588x384](upload://8KHdTP5UbtldTLlTQgqdGTmdvXu.png)

cpupower frequency-info
analyzing CPU 0:
  driver: intel_cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 20.0 us
  hardware limits: 500 MHz - 2.90 GHz
  available cpufreq governors: conservative ondemand userspace powersave performance schedutil
  current policy: frequency should be within 500 MHz and 2.90 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 798 MHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes
1 Like

Does the GUI save the profile somewhere?

cpupower.service

[Unit]
Description=Apply cpupower configuration
ConditionVirtualization=!container

[Service]
Type=oneshot
EnvironmentFile=/etc/default/cpupower
ExecStart=/usr/lib/systemd/scripts/cpupower
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

The configuration file for cpupower is located in /etc/default/cpupower. This configuration file is read by a bash script in /usr/lib/systemd/scripts/cpupower which is activated by systemd with cpupower.service. You may want to enable cpupower.service to start at boot.
https://wiki.archlinux.org/title/CPU_frequency_scaling#cpupower

Could you try passing your own profile instead of /etc/default/cpupower?
Rename this one to /etc/default/cpupower.orig for example and then put your own profile in /etc/default and name it cpupower.

I did a looky loo at the cpupower.service and it looks like everything is commented out. So it was doing nothing (LOL). Should we call this an elementary Dear Watson? I will be testing later tonight.

image

I didn’t see your edit when I was writing.

I guess you could just head over to /etc/default/cpupower and set the governor=conservative in that file. Restart the service afterwards and check with cpupower frequency-info

That one is an override file! I don’t know why and when that has been created. You could remove it.

Could you post

cat /usr/lib/systemd/system/cpupower.service

and

cat /etc/default/cpupower

?

cat /usr/lib/systemd/system/cpupower.service


cat /usr/lib/systemd/system/cpupower.service
[Unit]
Description=Apply cpupower configuration
ConditionVirtualization=!container

[Service]
Type=oneshot
EnvironmentFile=/etc/default/cpupower
ExecStart=/usr/lib/systemd/scripts/cpupower
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

and

cat /etc/default/cpupower

cat /etc/default/cpupower
# Define CPUs governor
# valid governors: ondemand, performance, powersave, conservative, userspace.
#governor='ondemand'

# Limit frequency range
# Valid suffixes: Hz, kHz (default), MHz, GHz, THz
#min_freq="2.25GHz"
#max_freq="3GHz"

# Specific frequency to be set.
# Requires userspace governor to be available.
# Do not set governor field if you use this one.
#freq=

# Utilizes cores in one processor package/socket first before processes are
# scheduled to other processor packages/sockets.
# See man (1) CPUPOWER-SET for additional details.
#mc_scheduler=

# Utilizes thread siblings of one processor core first before processes are
# scheduled to other cores. See man (1) CPUPOWER-SET for additional details.
#smp_scheduler=

#  Sets a register on supported Intel processore which allows software to convey
# its policy for the relative importance of performance versus energy savings to
# the  processor. See man (1) CPUPOWER-SET for additional details.
#perf_bias=

# vim:set ts=2 sw=2 ft=sh et:

As per your recommendation I went ahead and edited the cpupower configuration file directly (sudo nano /etc/default/cpupower) and restarted the cpupower.service and now the preferred setting is being applied.

I will have to read more about the GUI tool to see how that is expected to be used to set the boot preferred profile.

1 Like

That’s good news! :slightly_smiling_face:

I suspect that the GUI just performs commands equivalent to

cpupower frequency-set -g governor

etc. and doesn’t write to /etc/default/cpupower but I might be wrong and there might be a way.

1 Like

Looks like cpupower-gui has some systemd srevices of its own since version 0.9.0 ( cpupower-gui.service and cpupower-gui-user.service) that can be started at boot and which will apply the parameters defined in some config files.

https://github.com/vagnum08/cpupower-gui#systemd-units

1 Like

Hi Pebcak,

So did some more testing (after getting a meal in me) and I have come to some interesting conclusions.

The solution is I backed out all the changes I made through the thread went back to TLP alone for power\cpu management. The reasoning is I can use the CPU_SCALING_ GOVENOR to set my governor settings at boot and they will change between conservative and performance when I plug in the AC Adapter

image

Technically CPUPower was doing this as well. But to keep things simple I stuck with TLP as I am on a Lenovo laptop. I would only use CPUPower if I was manually changing my governor settings (which I don’t have a need for).

Auto-CPUFreq will remain disabled till the developer decides to make changes to it. Pretty much if I decided to use this again as is I will have to go back to Kernel LTS 5.4. The general big picture for me is to get my laptop to run as long as possible and not have to go back to Windows.

Besides all this, and being in Endeavor Land I have started using the Zen Kernel to see if I can utilize some optimization out of it (now lovingly known as pulling a @jonathon ) who I feel encourages me to read and read about Arch (you to @dalto ) and its many configurations and tune my brains out. Time will tell whether I can get to a place where I am only patching my daily driver every 2 months.

Thanks for the assistance while I wacked weeds on this one.

2 Likes