linrunner / TLP

TLP - Optimize Linux Laptop Battery Life
https://linrunner.de/tlp
GNU General Public License v2.0
2.67k stars 128 forks source link

CPU Frequency Management Issues #710

Closed Taurinz359 closed 1 year ago

Taurinz359 commented 1 year ago

Short backstory: I've been facing an overheating issue on my ASUS Vivobook 14 M1402IA-AM173 laptop running Manjaro (kernel 6.5.3-1-MANJARO) with 16GB of RAM and a Ryzen 7 4800Hs processor. Every time I launch applications like PHPStorm (project indexing) or run PHP unit tests (Paratest), all CPU cores max out their frequency to the maximum value. According to htop, it reaches 4300 MHz, and even when the processor heats up, it doesn't reduce the frequency to prevent overheating. Eventually, it hits a critical temperature of 105 degrees, and the laptop shuts down.

I found your program, and it indeed helps with battery charging management. Thank you for that! However, I would like to control the max_freq of my CPU. After reading the documentation, I've followed all the steps, and my scaling driver falls under the criteria for manually controlling the processor frequency. However, nothing changes. Here's my configuration and the summary of tlp-stat:

--- TLP 1.6.0 --------------------------------------------

+++ Configured Settings:
defaults.conf L0006: TLP_ENABLE="1"
defaults.conf L0007: TLP_WARN_LEVEL="3"
defaults.conf L0008: TLP_PERSISTENT_DEFAULT="0"
defaults.conf L0009: DISK_IDLE_SECS_ON_AC="0"
defaults.conf L0010: DISK_IDLE_SECS_ON_BAT="2"
defaults.conf L0011: MAX_LOST_WORK_SECS_ON_AC="15"
defaults.conf L0012: MAX_LOST_WORK_SECS_ON_BAT="60"
defaults.conf L0013: CPU_ENERGY_PERF_POLICY_ON_AC="balance_performance"
defaults.conf L0014: CPU_ENERGY_PERF_POLICY_ON_BAT="balance_power"
defaults.conf L0015: NMI_WATCHDOG="0"
defaults.conf L0016: DISK_DEVICES="nvme0n1 sda"
defaults.conf L0017: DISK_APM_LEVEL_ON_AC="254 254"
defaults.conf L0018: DISK_APM_LEVEL_ON_BAT="128 128"
defaults.conf L0019: DISK_APM_CLASS_DENYLIST="usb ieee1394"
defaults.conf L0020: DISK_IOSCHED="keep keep"
defaults.conf L0021: SATA_LINKPWR_ON_AC="med_power_with_dipm"
defaults.conf L0022: SATA_LINKPWR_ON_BAT="med_power_with_dipm"
defaults.conf L0023: AHCI_RUNTIME_PM_ON_AC="on"
defaults.conf L0024: AHCI_RUNTIME_PM_ON_BAT="auto"
defaults.conf L0025: AHCI_RUNTIME_PM_TIMEOUT="15"
defaults.conf L0026: PCIE_ASPM_ON_AC="default"
defaults.conf L0027: PCIE_ASPM_ON_BAT="default"
defaults.conf L0028: RADEON_DPM_PERF_LEVEL_ON_AC="auto"
defaults.conf L0029: RADEON_DPM_PERF_LEVEL_ON_BAT="auto"
defaults.conf L0030: RADEON_POWER_PROFILE_ON_AC="default"
defaults.conf L0031: RADEON_POWER_PROFILE_ON_BAT="default"
defaults.conf L0032: WIFI_PWR_ON_AC="off"
defaults.conf L0033: WIFI_PWR_ON_BAT="on"
defaults.conf L0034: WOL_DISABLE="Y"
defaults.conf L0035: SOUND_POWER_SAVE_ON_AC="1"
defaults.conf L0036: SOUND_POWER_SAVE_ON_BAT="1"
defaults.conf L0037: SOUND_POWER_SAVE_CONTROLLER="Y"
defaults.conf L0038: BAY_POWEROFF_ON_AC="0"
defaults.conf L0039: BAY_POWEROFF_ON_BAT="0"
defaults.conf L0040: BAY_DEVICE="sr0"
defaults.conf L0041: RUNTIME_PM_ON_AC="on"
defaults.conf L0042: RUNTIME_PM_ON_BAT="auto"
defaults.conf L0043: RUNTIME_PM_DRIVER_DENYLIST="mei_me nouveau radeon"
defaults.conf L0044: USB_AUTOSUSPEND="1"
defaults.conf L0045: USB_EXCLUDE_AUDIO="1"
defaults.conf L0046: USB_EXCLUDE_BTUSB="0"
defaults.conf L0047: USB_EXCLUDE_PHONE="0"
defaults.conf L0048: USB_EXCLUDE_PRINTER="1"
defaults.conf L0049: USB_EXCLUDE_WWAN="0"
defaults.conf L0050: RESTORE_DEVICE_STATE_ON_STARTUP="0"
defaults.conf L0051: RESTORE_THRESHOLDS_ON_BAT="0"
defaults.conf L0052: NATACPI_ENABLE="1"
defaults.conf L0053: TPACPI_ENABLE="1"
defaults.conf L0054: TPSMAPI_ENABLE="1"
/etc/tlp.conf L0084: CPU_DRIVER_OPMODE_ON_AC="guided"
/etc/tlp.conf L0085: CPU_DRIVER_OPMODE_ON_BAT="passive"
/etc/tlp.conf L0103: CPU_SCALING_GOVERNOR_ON_AC="ondemand"
/etc/tlp.conf L0104: CPU_SCALING_GOVERNOR_ON_BAT="ondemand"
/etc/tlp.conf L0115: CPU_SCALING_MIN_FREQ_ON_AC="400000"
/etc/tlp.conf L0116: CPU_SCALING_MAX_FREQ_ON_AC="3900000"
/etc/tlp.conf L0117: CPU_SCALING_MIN_FREQ_ON_BAT="400000"
/etc/tlp.conf L0118: CPU_SCALING_MAX_FREQ_ON_BAT="2900000"
/etc/tlp.conf L0533: START_CHARGE_THRESH_BAT0="55"
/etc/tlp.conf L0535: STOP_CHARGE_THRESH_BAT0="60"

+++ System Info
System         = ASUSTeK COMPUTER INC. 1.0        Vivobook_ASUSLaptop M1402IA_M1402IA
BIOS           = M1402IA.310
OS Release     = Manjaro Linux
Kernel         = 6.5.3-1-MANJARO #1 SMP PREEMPT_DYNAMIC Wed Sep 13 12:21:35 UTC 2023 x86_64
/proc/cmdline  = BOOT_IMAGE=/boot/vmlinuz-6.5-x86_64 root=UUID=e460ee6c-8315-41c1-9a37-2b118c464f13 rw quiet splash udev.log_priority=3
Init system    = systemd 
Boot mode      = UEFI
Suspend mode   = [s2idle]

+++ TLP Status
State          = enabled
RDW state      = enabled
Last run       = 12:11:02,     21 sec(s) ago
Mode           = AC
Power source   = AC

+++ Processor
CPU model      = AMD Ryzen 7 4800HS with Radeon Graphics

/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver    = amd-pstate
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor  = ondemand
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors = conservative ondemand userspace powersave performance schedutil 
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq  =   400000 [kHz]
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq  =  3900000 [kHz]
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq  =   400000 [kHz]
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq  =  4300000 [kHz]

/sys/devices/system/cpu/cpu1..cpu15: omitted for clarity, use -v to show all

/sys/devices/system/cpu/amd_pstate/status              = guided
/sys/devices/system/cpu/amd_pstate/cppc_dynamic_boost  = (not available)
/sys/devices/system/cpu/cpufreq/boost                  = 1
/sys/module/workqueue/parameters/power_efficient       = Y
/proc/sys/kernel/nmi_watchdog                          = 0

+++ Platform Profile
/sys/firmware/acpi/platform_profile                    = (not available)
/sys/firmware/acpi/platform_profile_choices            = (not available)

+++ Temperatures
Fan speed (fan1)       =     0 [/min]

+++ File System
/proc/sys/vm/laptop_mode               =     0
/proc/sys/vm/dirty_writeback_centisecs =  1500
/proc/sys/vm/dirty_expire_centisecs    =  1500
/proc/sys/vm/dirty_ratio               =    20
/proc/sys/vm/dirty_background_ratio    =    10

+++ Disks
Devices = nvme0n1 sda

/dev/nvme0n1:
  Type       = NVMe
  Disk ID    = nvme-INTEL_SSDPEKNU512GZ_BTKA246605PJ512A
  Model      = INTEL SSDPEKNU512GZ                     
  Firmware   = 002C    
  Temp       = 29 °C
  Scheduler  = [none] mq-deadline kyber bfq (multi queue)

  Runtime PM:
    /sys/block/nvme0n1/device/power/control = on, autosuspend_delay_ms = (not available)

/dev/sda: not present.

+++ AMD Radeon Graphics
/sys/class/drm/card1/device/driver                                = amdgpu

/sys/class/drm/card1/device/power_dpm_force_performance_level     = auto

+++ Wireless
bluetooth = on
nfc       = none (no device)
wifi      = on
wwan      = none (no device)

hci0(btusb)                   : bluetooth, not connected
wlp2s0(rtw89_8852be)          : wifi, connected, power management = off

+++ Audio
/sys/module/snd_hda_intel/parameters/power_save            = 1
/sys/module/snd_hda_intel/parameters/power_save_controller = Y

+++ PCIe Active State Power Management
/sys/module/pcie_aspm/parameters/policy = [default] performance powersave powersupersave (using BIOS preferences)

+++ PCIe Runtime Power Management
Enable devices    = (disabled)
Disable devices   = (disabled)
Device denylist   = (disabled)
Driver denylist   = mei_me nouveau radeon

/sys/bus/pci/devices/0000:00:00.0/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:00.2/power/control = on   (0x080600, IOMMU, no driver)
/sys/bus/pci/devices/0000:00:01.0/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:01.3/power/control = on   (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:02.0/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:02.2/power/control = on   (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:02.4/power/control = on   (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:08.0/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:08.1/power/control = on   (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:14.0/power/control = on   (0x0c0500, SMBus, piix4_smbus)
/sys/bus/pci/devices/0000:00:14.3/power/control = on   (0x060100, ISA bridge, no driver)
/sys/bus/pci/devices/0000:00:18.0/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.1/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.2/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.3/power/control = on   (0x060000, Host bridge, k10temp)
/sys/bus/pci/devices/0000:00:18.4/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.5/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.6/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.7/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:02:00.0/power/control = on   (0x028000, Network controller, rtw89_8852be)
/sys/bus/pci/devices/0000:03:00.0/power/control = on   (0x010802, Non-Volatile memory controller, nvme)
/sys/bus/pci/devices/0000:04:00.0/power/control = on   (0x030000, VGA compatible controller, amdgpu)
/sys/bus/pci/devices/0000:04:00.1/power/control = on   (0x040300, Audio device, snd_hda_intel)
/sys/bus/pci/devices/0000:04:00.2/power/control = on   (0x108000, Encryption controller, ccp)
/sys/bus/pci/devices/0000:04:00.3/power/control = on   (0x0c0330, USB controller, xhci_hcd)
/sys/bus/pci/devices/0000:04:00.4/power/control = on   (0x0c0330, USB controller, xhci_hcd)
/sys/bus/pci/devices/0000:04:00.5/power/control = on   (0x048000, Multimedia controller, no driver)
/sys/bus/pci/devices/0000:04:00.6/power/control = on   (0x040300, Audio device, snd_hda_intel)

+++ USB
Autosuspend       = enabled
Device allowlist  = (not configured)
Device denylist   = (not configured)
Exclude audio     = enabled
Exclude bluetooth = disabled
Exclude phones    = disabled
Exclude printers  = enabled
Exclude WWAN      = disabled

Bus 004 Device 001 ID 1d6b:0003 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 3.0 root hub (hub)
Bus 003 Device 003 ID 3277:0029 control = auto, autosuspend_delay_ms = 2000 -- Shine-optics USB2.0 HD UVC WebCam (uvcvideo)
Bus 003 Device 002 ID 13d3:3571 control = auto, autosuspend_delay_ms = 2000 -- IMC Networks Bluetooth Radio (btusb)
Bus 003 Device 001 ID 1d6b:0002 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 2.0 root hub (hub)
Bus 002 Device 001 ID 1d6b:0003 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 3.0 root hub (hub)
Bus 001 Device 002 ID 046d:c53f control = on,   autosuspend_delay_ms = 2000 -- Logitech, Inc. USB Receiver (usbhid)
Bus 001 Device 001 ID 1d6b:0002 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 2.0 root hub (hub)

+++ Battery Care
Plugin: asus
Supported features: charge threshold
Driver usage:
* natacpi (asus_wmi) = active (charge threshold)
Parameter value range:
* STOP_CHARGE_THRESH_BAT0/1: 0(off)..100(default)

+++ Battery Status: BAT0
/sys/class/power_supply/BAT0/manufacturer                   = ASUSTeK
/sys/class/power_supply/BAT0/model_name                     = ASUS Battery
/sys/class/power_supply/BAT0/cycle_count                    =     29
/sys/class/power_supply/BAT0/energy_full_design             =  42067 [mWh]
/sys/class/power_supply/BAT0/energy_full                    =  41842 [mWh]
/sys/class/power_supply/BAT0/energy_now                     =  40420 [mWh]
/sys/class/power_supply/BAT0/power_now                      =      0 [mW]
/sys/class/power_supply/BAT0/status                         = Not charging

/sys/class/power_supply/BAT0/charge_control_end_threshold   =     60 [%]

Charge                                                      =   96.6 [%]
Capacity                                                    =   99.5 [%]

+++ Recommendations
* Install ethtool to disable Wake-on-LAN
* Install smartmontools for disk drive health info

tlp.conf:

CPU_DRIVER_OPMODE_ON_AC=guided
CPU_DRIVER_OPMODE_ON_BAT=passive

CPU_SCALING_GOVERNOR_ON_AC=ondemand
CPU_SCALING_GOVERNOR_ON_BAT=ondemand

CPU_SCALING_MIN_FREQ_ON_AC=400000
CPU_SCALING_MAX_FREQ_ON_AC=3900000
CPU_SCALING_MIN_FREQ_ON_BAT=400000
CPU_SCALING_MAX_FREQ_ON_BAT=2900000
linrunner commented 1 year ago

The output of tlp-stat shows that all your settings have been accepted by the driver:

/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver    = amd-pstate
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor  = ondemand
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq  =   400000 [kHz]
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq  =  3900000 [kHz]
/sys/devices/system/cpu/amd_pstate/status              = guided

Which means TLP has performed its task correctly (I assume that it is the same on battery).

my scaling driver falls under the criteria for manually controlling the processor frequency.

You said it yourself: the kernel driver does not do what it should or what you expect. Please contact its developers.