Improving battery life, TLP and Intel pstate

I have been trying to improve the battery life on my thinkpad. I have been getting on average about 2 hours. The battery is 57Wh. I have installed TLP on all templates including dom0. In the tlp.conf file I have (in all templates):


# ------------------------------------------------------------------------------
# /etc/tlp.conf - TLP user configuration (version 1.4)
# See full explanation: https://linrunner.de/tlp/settings
#
# Settings are read in the following order:

#
# 1. Intrinsic defaults
# 2. /etc/tlp.d/*.conf - Drop-in customization snippets
# 3. /etc/tlp.conf     - User configuration (this file)
#
# Notes:
# - In case of identical parameters, the last occurence has precedence
# - This also means, parameters enabled here will override anything else
# - However you may append values to a parameter already defined as intrinsic
#   default or in a previously read file: use PARAMETER+="add values"
# - IMPORTANT: all parameters here are disabled; remove the leading '#' if you
#   like to enable a feature without default or have a value different from the
#   default
# - Default *: intrinsic default that is effective when the parameter is missing
#     or disabled by a leading '#'; use PARAM="" to disable an intrinsic default
# - Default <none>: do nothing or use kernel/hardware defaults
# -
# ------------------------------------------------------------------------------
# tlp - Parameters for power saving

# Set to 0 to disable, 1 to enable TLP.
# Default: 1

TLP_ENABLE=1

# Control how warnings about invalid settings are issued:
#   0=disabled,
#   1=background tasks (boot, resume, change of power source) report to syslog,
#   2=shell commands report to the terminal (stderr),
#   3=combination of 1 and 2
# Default: 3

TLP_WARN_LEVEL=3

# Operation mode when no power supply can be detected: AC, BAT.
# Concerns some desktop and embedded hardware only.
# Default: <none>

#TLP_DEFAULT_MODE=AC

# Operation mode select: 0=depend on power source, 1=always use TLP_DEFAULT_MODE
# Note: use in conjunction with TLP_DEFAULT_MODE=BAT for BAT settings on AC.
# Default: 0

TLP_PERSISTENT_DEFAULT=0

# Power supply classes to ignore when determining operation mode: AC, USB, BAT.
# Separate multiple classes with spaces.
# Note: try on laptops where operation mode AC/BAT is incorrectly detected.
# Default: <none>

#TLP_PS_IGNORE="BAT"

# Seconds laptop mode has to wait after the disk goes idle before doing a sync.
# Non-zero value enables, zero disables laptop mode.
# Default: 0 (AC), 2 (BAT)
#DISK_IDLE_SECS_ON_AC=0
#DISK_IDLE_SECS_ON_BAT=2

# Dirty page values (timeouts in secs).
# Default: 15 (AC), 60 (BAT)

#MAX_LOST_WORK_SECS_ON_AC=15
#MAX_LOST_WORK_SECS_ON_BAT=60

# Select a CPU frequency scaling governor.
# Intel processor with intel_pstate driver:
#   performance, powersave(*).
# Intel processor with intel_cpufreq driver (aka intel_pstate passive mode):
#   conservative, ondemand, userspace, powersave, performance, schedutil(*).
# Intel and other processor brands with acpi-cpufreq driver:
#   conservative, ondemand(*), userspace, powersave, performance, schedutil(*).
# Use tlp-stat -p to show the active driver and available governors.
# Important:
#   Governors marked (*) above are power efficient for *almost all* workloads
#   and therefore kernel and most distributions have chosen them as defaults.
#   You should have done your research about advantages/disadvantages *before*
#   changing the governor.
# Default: <none>
CPU_SCALING_GOVERNOR_ON_AC=performance
CPU_SCALING_GOVERNOR_ON_BAT=powersave

# Set the min/max frequency available for the scaling governor.
# Possible values depend on your CPU. For available frequencies see
# the output of tlp-stat -p.
# Notes:
# - Min/max frequencies must always be specified for both AC *and* BAT
# - Not recommended for use with the intel_pstate scaling driver, use
#   CPU_MIN/MAX_PERF_ON_AC/BAT below instead
# Default: <none>

#CPU_SCALING_MIN_FREQ_ON_AC=0
#CPU_SCALING_MAX_FREQ_ON_AC=0
#CPU_SCALING_MIN_FREQ_ON_BAT=0
#CPU_SCALING_MAX_FREQ_ON_BAT=0

# Set Intel CPU energy/performance policies HWP.EPP and EPB:
#   performance, balance_performance, default, balance_power, power.
# Values are given in order of increasing power saving.
# Notes:
# - HWP.EPP: requires kernel 4.10, intel_pstate scaling driver and Intel Core i
#   6th gen. or newer CPU
# - EPB: requires kernel 5.2 or module msr and x86_energy_perf_policy from
#   linux-tools, intel_pstate or intel_cpufreq scaling driver and Intel Core i
#   2nd gen. or newer CPU
# - When HWP.EPP is available, EPB is not set
# Default: balance_performance (AC), balance_power (BAT)

CPU_ENERGY_PERF_POLICY_ON_AC=performance
CPU_ENERGY_PERF_POLICY_ON_BAT=power

# Set Intel CPU P-state performance: 0..100 (%).
# Limit the max/min P-state to control the power dissipation of the CPU.
# Values are stated as a percentage of the available performance.
# Requires intel_pstate or intel_cpufreq driver and Intel Core i 2nd gen. or
# newer CPU.
# Default: <none>

CPU_MIN_PERF_ON_AC=0
CPU_MAX_PERF_ON_AC=100
CPU_MIN_PERF_ON_BAT=0
CPU_MAX_PERF_ON_BAT=30

# Set the CPU "turbo boost" (Intel) or "turbo core" (AMD) feature:
#   0=disable, 1=allow.
# Note: a value of 1 does *not* activate boosting, it just allows it.
# Default: <none>

CPU_BOOST_ON_AC=1
CPU_BOOST_ON_BAT=0

# Set the Intel CPU HWP dynamic boost feature:
#   0=disable, 1=enable.
# Requires intel_pstate scaling driver in 'active' mode and Intel Core i
# 6th gen. or newer CPU.
# Default: <none>

CPU_HWP_DYN_BOOST_ON_AC=1
CPU_HWP_DYN_BOOST_ON_BAT=0

# Minimize number of used CPU cores/hyper-threads under light load conditions:
#   0=disable, 1=enable.
# Default: 0 (AC), 1 (BAT)

SCHED_POWERSAVE_ON_AC=0
SCHED_POWERSAVE_ON_BAT=1

# Kernel NMI Watchdog:
#   0=disable (default, saves power), 1=enable (for kernel debugging only).
# Default: 0

NMI_WATCHDOG=0

# Select platform profile:
#   performance, balanced, low-power.
# Controls system operating characteristics around power/performance levels,
# thermal and fan speed. Values are given in order of increasing power saving.
# Note: check the output of tlp-stat -p to determine availability on your
# hardware and additional profiles such as: balanced-performance, quiet, cool.
# Default: <none>

PLATFORM_PROFILE_ON_AC=performance
PLATFORM_PROFILE_ON_BAT=low-power

# Define disk devices on which the following DISK/AHCI_RUNTIME parameters act.
# Separate multiple devices with spaces.
# Devices can be specified by disk ID also (lookup with: tlp diskid).
# Default: "nvme0n1 sda"

#DISK_DEVICES="nvme0n1 sda"

# Disk advanced power management level: 1..254, 255 (max saving, min, off).
# Levels 1..127 may spin down the disk; 255 allowable on most drives.
# Separate values for multiple disks with spaces. Use the special value 'keep'
# to keep the hardware default for the particular disk.
# Default: 254 (AC), 128 (BAT)

#DISK_APM_LEVEL_ON_AC="254 254"
#DISK_APM_LEVEL_ON_BAT="128 128"

# Exclude disk classes from advanced power management (APM):
#   sata, ata, usb, ieee1394.
# Separate multiple classes with spaces.
# CAUTION: USB and IEEE1394 disks may fail to mount or data may get corrupted
# with APM enabled. Be careful and make sure you have backups of all affected
# media before removing 'usb' or 'ieee1394' from the denylist!
# Default: "usb ieee1394"

#DISK_APM_CLASS_DENYLIST="usb ieee1394"

And the rest is all standard.

The settings I changed in this was:

TLP_ENABLE=1
TLP_WARN_LEVEL=3
TLP_PERSISTENT_DEFAULT=0
CPU_SCALING_GOVERNOR_ON_AC=performance
CPU_SCALING_GOVERNOR_ON_BAT=powersave
CPU_ENERGY_PERF_POLICY_ON_AC=performance
CPU_ENERGY_PERF_POLICY_ON_BAT=power
CPU_MIN_PERF_ON_AC=0
CPU_MAX_PERF_ON_AC=100
CPU_MIN_PERF_ON_BAT=0
CPU_MAX_PERF_ON_BAT=30
CPU_BOOST_ON_AC=1
CPU_BOOST_ON_BAT=0
CPU_HWP_DYN_BOOST_ON_AC=1
CPU_HWP_DYN_BOOST_ON_BAT=0
SCHED_POWERSAVE_ON_AC=0
SCHED_POWERSAVE_ON_BAT=1
NMI_WATCHDOG=0
PLATFORM_PROFILE_ON_AC=performance
PLATFORM_PROFILE_ON_BAT=low-power

However, it is still outputting 12w while doing basic stuff like having one appvm open browsing on a few tabs. When I do sudo tlp-stat -p it says

BAT0-acpi-0
Adapter: ACPI interface
in0:                  10.83 V
power1:           12.15 W

For a i5 1235U, I would have expected less.

Now, I was looking into the intel pstate, but when I typed into terminal

sudo dmesg | grep intel_pstate

I got back

[ 3.895872] intel_pstate: CPU model not supported

This is a fairly new cpu and I would have expected it to be supported by intel pstate.

The reason I ask this is because to help battery life I wanted to limit the CPU frequency in tlp, but the settings for this states that it shouldn’t be done if the CPU can use intel pstate here:

# Set the min/max frequency available for the scaling governor.
# Possible values depend on your CPU. For available frequencies see
# the output of tlp-stat -p.
# Notes:
# - Min/max frequencies must always be specified for both AC *and* BAT
# - **Not recommended for use with the intel_pstate scaling driver**, use
#   CPU_MIN/MAX_PERF_ON_AC/BAT below instead
# Default: <none>

#CPU_SCALING_MIN_FREQ_ON_AC=0
#CPU_SCALING_MAX_FREQ_ON_AC=0
#CPU_SCALING_MIN_FREQ_ON_BAT=0
#CPU_SCALING_MAX_FREQ_ON_BAT=0

Another strange thing is that when I sudo tlp-stat -p it doesn’t tell me what frequencies are available. Instead I get this

--- TLP 1.5.0 --------------------------------------------

+++ Processor
CPU model      = 12th Gen Intel(R) Core(TM) i5-1235U

/sys/devices/system/cpu/cpufreq/boost                  = (not available)

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

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

Do you have any ideas on this? It is quite confusing and I really want to improve the battery life to be better than 2 hours!

1 Like

intel_pstate don’t work because patch for xen wasn’t committed for few years now

3 Likes

thanks Kitsune. So I guess then that I should limit the max cpu frequency then on tlp when using battery. The problem here is that tlp-stat -p isn’t showing me the frequencies that my CPU can be underclocked to. How would I find this information out?

xenpm get-cpufreq-para will give you base and turbo frequency for every core

it’s for mine:

[root@dom0]# xenpm get-cpufreq-para
cpu id               : 0
affected_cpus        : 0
cpuinfo frequency    : base [2500000] turbo [4400000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [6]
                     : guaranteed [21] highest [56]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 1
affected_cpus        : 1
cpuinfo frequency    : base [2500000] turbo [4400000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [6]
                     : guaranteed [21] highest [56]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 2
affected_cpus        : 2
cpuinfo frequency    : base [2500000] turbo [3300000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [4]
                     : guaranteed [12] highest [33]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 3
affected_cpus        : 3
cpuinfo frequency    : base [2500000] turbo [3300000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [4]
                     : guaranteed [12] highest [33]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 4
affected_cpus        : 4
cpuinfo frequency    : base [2500000] turbo [3300000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [4]
                     : guaranteed [12] highest [33]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 5
affected_cpus        : 5
cpuinfo frequency    : base [2500000] turbo [3300000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [4]
                     : guaranteed [12] highest [33]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 6
affected_cpus        : 6
cpuinfo frequency    : base [2500000] turbo [3300000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [4]
                     : guaranteed [12] highest [33]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 7
affected_cpus        : 7
cpuinfo frequency    : base [2500000] turbo [3300000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [4]
                     : guaranteed [12] highest [33]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 8
affected_cpus        : 8
cpuinfo frequency    : base [2500000] turbo [3300000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [4]
                     : guaranteed [12] highest [33]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 9
affected_cpus        : 9
cpuinfo frequency    : base [2500000] turbo [3300000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [4]
                     : guaranteed [12] highest [33]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

xenpm get-cpufreq-stat will give you some false p-states but there you will se your CPU minimal frequency

current frequency you can read by xenpm get-cpufreq-average (every singe core, you can add number to read one core only)

you can change behavior of HWP scaling driver by setting it’s variables either per core or for all of them at once

my settings are

xenpm set-cpufreq-hwp minimum:0 maximum:255 energy-perf:64

it gets p-cores as high as 3.9GHz (it max all cores easy) and all cores as low as 1.4-1.6GHz

but with energy-perf:128 it gets p-cores to max 3.6-3.7 (it balances frequency more) and all cores as low as 0.8-1.2

you can use presets: performance, balance and powersave

xenpm set-cpufreq-hwp performance

performance: min-33 max-33 energy-0
balance: min-1 max-33 energy-128
powersave: min-1 max-1 energy-255

2 Likes

Clip showing how frequency behave with min:0 max:255 energy:128 when YT starts playing

1 Like

thank you Kitsune.

My readings from xenpm get-cpufreq-para

[user@dom0 Desktop]$ xenpm get-cpufreq-para
cpu id               : 0
affected_cpus        : 0
cpuinfo frequency    : base [2500000] turbo [4400000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [6]
                     : guaranteed [17] highest [56]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 1
affected_cpus        : 1
cpuinfo frequency    : base [2500000] turbo [4400000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [6]
                     : guaranteed [17] highest [56]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 2
affected_cpus        : 2
cpuinfo frequency    : base [2500000] turbo [3300000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [4]
                     : guaranteed [9] highest [33]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 3
affected_cpus        : 3
cpuinfo frequency    : base [2500000] turbo [3300000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [4]
                     : guaranteed [9] highest [33]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 4
affected_cpus        : 4
cpuinfo frequency    : base [2500000] turbo [3300000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [4]
                     : guaranteed [9] highest [33]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 5
affected_cpus        : 5
cpuinfo frequency    : base [2500000] turbo [3300000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [4]
                     : guaranteed [9] highest [33]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 6
affected_cpus        : 6
cpuinfo frequency    : base [2500000] turbo [3300000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [4]
                     : guaranteed [9] highest [33]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 7
affected_cpus        : 7
cpuinfo frequency    : base [2500000] turbo [3300000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [4]
                     : guaranteed [9] highest [33]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 8
affected_cpus        : 8
cpuinfo frequency    : base [2500000] turbo [3300000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [13]
                     : guaranteed [9] highest [33]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

cpu id               : 9
affected_cpus        : 9
cpuinfo frequency    : base [2500000] turbo [3300000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [13]
                     : guaranteed [9] highest [33]
  configured limits  : min [1] max [255] energy_perf [128]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

My readings from xenpm get-cpufreq-stat

[user@dom0 Desktop]$ xenpm get-cpufreq-stat
cpu id               : 0
total P-states       : 23
usable P-states      : 15
current frequency    : 2501 MHz
*P0        [2501 MHz]: transition [                   0]
                       residency  [               56447 ms]
P1         [2500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P2         [2400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P3         [2300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P4         [2200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P5         [2100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P6         [2000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P7         [1900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P8         [1800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P9         [1700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P10        [1600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P11        [1500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P12        [1400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P13        [1300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P14        [1200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P15        [1100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P16        [1000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P17        [ 900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P18        [ 800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P19        [ 700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P20        [ 600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P21        [ 500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P22        [ 400 MHz]: transition [                   0]
                       residency  [                   0 ms]

cpu id               : 1
total P-states       : 23
usable P-states      : 15
current frequency    : 2501 MHz
*P0        [2501 MHz]: transition [                   0]
                       residency  [               55880 ms]
P1         [2500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P2         [2400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P3         [2300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P4         [2200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P5         [2100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P6         [2000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P7         [1900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P8         [1800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P9         [1700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P10        [1600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P11        [1500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P12        [1400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P13        [1300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P14        [1200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P15        [1100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P16        [1000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P17        [ 900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P18        [ 800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P19        [ 700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P20        [ 600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P21        [ 500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P22        [ 400 MHz]: transition [                   0]
                       residency  [                   0 ms]

cpu id               : 2
total P-states       : 23
usable P-states      : 15
current frequency    : 2501 MHz
*P0        [2501 MHz]: transition [                   0]
                       residency  [               65850 ms]
P1         [2500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P2         [2400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P3         [2300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P4         [2200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P5         [2100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P6         [2000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P7         [1900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P8         [1800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P9         [1700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P10        [1600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P11        [1500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P12        [1400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P13        [1300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P14        [1200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P15        [1100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P16        [1000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P17        [ 900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P18        [ 800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P19        [ 700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P20        [ 600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P21        [ 500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P22        [ 400 MHz]: transition [                   0]
                       residency  [                   0 ms]

cpu id               : 3
total P-states       : 23
usable P-states      : 15
current frequency    : 2501 MHz
*P0        [2501 MHz]: transition [                   0]
                       residency  [               65209 ms]
P1         [2500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P2         [2400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P3         [2300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P4         [2200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P5         [2100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P6         [2000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P7         [1900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P8         [1800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P9         [1700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P10        [1600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P11        [1500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P12        [1400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P13        [1300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P14        [1200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P15        [1100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P16        [1000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P17        [ 900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P18        [ 800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P19        [ 700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P20        [ 600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P21        [ 500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P22        [ 400 MHz]: transition [                   0]
                       residency  [                   0 ms]

cpu id               : 4
total P-states       : 23
usable P-states      : 15
current frequency    : 2501 MHz
*P0        [2501 MHz]: transition [                   0]
                       residency  [               65212 ms]
P1         [2500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P2         [2400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P3         [2300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P4         [2200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P5         [2100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P6         [2000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P7         [1900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P8         [1800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P9         [1700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P10        [1600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P11        [1500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P12        [1400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P13        [1300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P14        [1200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P15        [1100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P16        [1000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P17        [ 900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P18        [ 800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P19        [ 700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P20        [ 600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P21        [ 500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P22        [ 400 MHz]: transition [                   0]
                       residency  [                   0 ms]

cpu id               : 5
total P-states       : 23
usable P-states      : 15
current frequency    : 2501 MHz
*P0        [2501 MHz]: transition [                   0]
                       residency  [               60811 ms]
P1         [2500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P2         [2400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P3         [2300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P4         [2200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P5         [2100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P6         [2000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P7         [1900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P8         [1800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P9         [1700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P10        [1600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P11        [1500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P12        [1400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P13        [1300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P14        [1200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P15        [1100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P16        [1000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P17        [ 900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P18        [ 800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P19        [ 700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P20        [ 600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P21        [ 500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P22        [ 400 MHz]: transition [                   0]
                       residency  [                   0 ms]

cpu id               : 6
total P-states       : 23
usable P-states      : 15
current frequency    : 2501 MHz
*P0        [2501 MHz]: transition [                   0]
                       residency  [               63781 ms]
P1         [2500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P2         [2400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P3         [2300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P4         [2200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P5         [2100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P6         [2000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P7         [1900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P8         [1800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P9         [1700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P10        [1600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P11        [1500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P12        [1400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P13        [1300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P14        [1200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P15        [1100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P16        [1000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P17        [ 900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P18        [ 800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P19        [ 700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P20        [ 600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P21        [ 500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P22        [ 400 MHz]: transition [                   0]
                       residency  [                   0 ms]

cpu id               : 7
total P-states       : 23
usable P-states      : 15
current frequency    : 2501 MHz
*P0        [2501 MHz]: transition [                   0]
                       residency  [               65734 ms]
P1         [2500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P2         [2400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P3         [2300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P4         [2200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P5         [2100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P6         [2000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P7         [1900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P8         [1800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P9         [1700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P10        [1600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P11        [1500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P12        [1400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P13        [1300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P14        [1200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P15        [1100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P16        [1000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P17        [ 900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P18        [ 800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P19        [ 700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P20        [ 600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P21        [ 500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P22        [ 400 MHz]: transition [                   0]
                       residency  [                   0 ms]

cpu id               : 8
total P-states       : 23
usable P-states      : 15
current frequency    : 2501 MHz
*P0        [2501 MHz]: transition [                   0]
                       residency  [               63420 ms]
P1         [2500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P2         [2400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P3         [2300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P4         [2200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P5         [2100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P6         [2000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P7         [1900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P8         [1800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P9         [1700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P10        [1600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P11        [1500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P12        [1400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P13        [1300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P14        [1200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P15        [1100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P16        [1000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P17        [ 900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P18        [ 800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P19        [ 700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P20        [ 600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P21        [ 500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P22        [ 400 MHz]: transition [                   0]
                       residency  [                   0 ms]

cpu id               : 9
total P-states       : 23
usable P-states      : 15
current frequency    : 2501 MHz
*P0        [2501 MHz]: transition [                   0]
                       residency  [               64739 ms]
P1         [2500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P2         [2400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P3         [2300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P4         [2200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P5         [2100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P6         [2000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P7         [1900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P8         [1800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P9         [1700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P10        [1600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P11        [1500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P12        [1400 MHz]: transition [                   0]
                       residency  [                   0 ms]
P13        [1300 MHz]: transition [                   0]
                       residency  [                   0 ms]
P14        [1200 MHz]: transition [                   0]
                       residency  [                   0 ms]
P15        [1100 MHz]: transition [                   0]
                       residency  [                   0 ms]
P16        [1000 MHz]: transition [                   0]
                       residency  [                   0 ms]
P17        [ 900 MHz]: transition [                   0]
                       residency  [                   0 ms]
P18        [ 800 MHz]: transition [                   0]
                       residency  [                   0 ms]
P19        [ 700 MHz]: transition [                   0]
                       residency  [                   0 ms]
P20        [ 600 MHz]: transition [                   0]
                       residency  [                   0 ms]
P21        [ 500 MHz]: transition [                   0]
                       residency  [                   0 ms]
P22        [ 400 MHz]: transition [                   0]
                       residency  [                   0 ms]

And xenpm -get-cpufreq-average (while on battery)

[user@dom0 Desktop]$ xenpm get-cpufreq-average
cpu id               : 0
average cpu frequency: 900000

cpu id               : 1
average cpu frequency: 900000

cpu id               : 2
average cpu frequency: 975000

cpu id               : 3
average cpu frequency: 975000

cpu id               : 4
average cpu frequency: 975000

cpu id               : 5
average cpu frequency: 975000

cpu id               : 6
average cpu frequency: 950000

cpu id               : 7
average cpu frequency: 975000

cpu id               : 8
average cpu frequency: 975000

cpu id               : 9
average cpu frequency: 975000

[user@dom0 Desktop]$

my settings are

xenpm set-cpufreq-hwp minimum:0 maximum:255 energy-perf:64

Is that a setting in tlp or a command you are running in the terminal? I only want powersaving on battery. Sorry if this question seems silly! Are you using xenpm instead of tlp? From my understanding of the cpu specsheet, the lowest clockspeed (baseclock) of the i5-1235U was 900mhz, and the highest 4.4Ghz so I have changed in the tlp.conf file


CPU_SCALING_MIN_FREQ_ON_AC=0
CPU_SCALING_MAX_FREQ_ON_AC=4400000
CPU_SCALING_MIN_FREQ_ON_BAT=0
CPU_SCALING_MAX_FREQ_ON_BAT=900000

Yet the power is still showing around 15w on tlp-stat -p.

but now from xenpm get-cpufreq-stat is seems that the lowest is 400mhz?

Also all these readings are from dom0. I have done the tlp settings on each template as well as dom0 but is that necessary or overkill?

Unfortunatelly tlp is working in dom0 and as such can’t manipulate xen scaling driver so it won’t do you much. It can manipulate p-state of dom0 driver but it don’t works as of now.

Starting tlp in templates is doing nothing for you - domU qubes aren’t ThinkPad’s, they are Xen machines. They are isolated from CPU.

The only thing is to make some service that detects whenever you work on AC or on battery and then change HWP driver variables with command xenpm

xenpm set-cpufreq-hwp minimum:0 maximum:255 energy-perf:64 for AC
xenpm set-cpufreq-hwp minimum:1 maximum:12 energy-perf:255 for battery

clip with xenpm for battery work and YT starts playing

1 Like

Ok thank you Kitsune. So should I try and uninstall tlp or doesn’t it do any harm? As far as setting xenpm, does it have a configuration file or when you say service, would I have to make scripts for systemd to detect ac or battery with the xenpm set-cpufreq-hwp minimum:0 maximum:255 energy-perf:64 for AC and xenpm set-cpufreq-hwp minimum:1 maximum:12 energy-perf:255 for battery?

1 Like

Over here tlp does something when installed in dom0 (as a service). You could do some measurements and compare with powertop.

1 Like

Yes, you can trigger kernel laptopmode with tlp which limits your cpu and power consumption.

As with xenpm I need to correct myself.
Proper HWP variables for minimum and maximum power states if set to 0 it will be handled automatically so it needs to be set to non zero values.

So, getting back.
UDEV rules for on battery and on ac HWP variables in dom0:

/etc/udev/rules.d/90-on-ac.rules

SUBSYSTEM=="power_supply", \
   ENV{POWER_SUPPLY_TYPE}=="Mains", \
   ENV{POWER_SUPPLY_ONLINE}=="1", \
   RUN+="/usr/sbin/xenpm set-cpufreq-hwp minimum:1 maximum:255 energy-perf:64"

/etc/udev/rules.d/90-on-battery.rules

SUBSYSTEM=="power_supply", \
   ENV{POWER_SUPPLY_TYPE}=="Battery", \
   ENV{POWER_SUPPLY_STATUS}=="Discharging", \
   RUN+="/usr/sbin/xenpm set-cpufreq-hwp minimum:1 maximum:9 energy-perf:255"

After making those files you need to reboot - you can’t remove battery live from laptop for rules to update.

edit: correction in ENV{POWER_SUPPLY_ONLINE} in on AC rules

3 Likes

Thank you Kitsune
After making those files in dom0 do I need to make then executable?

And does the maximum:9 mean 900mhz? Is there any documentation out there so I could have a better understanding of what it all means?

Thank you again

No.
It seems like with min/max you can chose some number that refer to power states but not 1:1 and with energy-perf you can chose you energy savings preference. And then processor internal hardware p-state engine will calculate what to do with available resources.

https://lists.xenproject.org/archives/html/xen-devel/2021-05/msg00068.html

Ok thanks for that Kitsune.
I have done the config text files (from rules.d) as you said but I think I have noticed a performance dip even on AC (and a bit of weird graphic glitching on startup), and sudo sensors is still showing around 15w usage on battery? Could this be because tlp (which I have not uninstalled) could be confusing the system?

My original idea was to have max performance while on AC, but “extreme” power savings while on battery. As I am using a i5-1235U, the base clock is 900mhz so I wanted to disable any kind of turbo boost above that. I am still unsure of what the numbers on minimum, maximum, and energy-perf (in the config files of rules.d) actually mean?

min/max is for setting power states - lower the number then lower power state

with minimum:1 my 1245U can go as low as 400MHz (lowest possible power state)

with maximum:1 my 1245U goes as high as 400MHz (highest possible power state)

with maximum:33 my 1245U goes no higher than 3300MHz

so it looks like it have some frequency correlations

on xen mailing list they claim that other scaling governors don’t work with p-state processors because they set cpu frequency which don’t work with p-state, so they made dummy hwp-internal governor with which you can have some amount of internal p-state engine settings
and what? those min/max limits are frequency settings - consistency is high with them

energy-perf have range of 0-255
with 128 it’s balanced - cpu is equalizing usage of high and low p-states depending on load
with 0 it’s high p-states and high frequency preference
with 255 it’s low p-states and frequencies preference

and there’s one interesting thing, min/max frequency correlation breaks above value of 33
if I set

xenpm set-cpufreq-hwp min:1 max:44 energy-perf:0

then cpu goes no higher than 3400MHz - it should go 4400
between 34 and 43 it stays on 3300MHz
max:45 - 3500MHz
max:46 - 3600MHz
max:47 - 3700MHz
max:49 - 3800MHz
max:50 - 3900MHz
with max:51 it goes to 4000MHz and any higher values don’t give anything more

but, with min:1 max:255 energy-perf:0, as the cpu is almost always above 2600MHz, TDP and thermal throttle kicks in really fast

PS: cpu was stress tested with command

stress -c 10 -t 5s

and throttling was observed with

stress -c 10 -t 60s
1 Like

Ok that makes a lot of sense now as far as what the numbers mean.
But since I made the config files in /etc/udev/rules.d I have been getting some instability issues such as program crashes, task bar disappearing, slow boot, graphic glitches on boot (after login, for about 10 seconds). Do you have any idea why this is the case?

Could it be because I still have tlp installed, and it is making the system confused if it should be using tlp or xenpm? Should I uninstall tlp?

And also, it takes longer now to open any programs up or appvm’s (even on AC). Could this be because the energy-perf on the 90-on-ac.rules is 64 which is slower than setting it to 0?

And why, when on battery, is sudo sensors still showing the same 15w usage even after I made the /etc/udev/rules.d/90-on-battery.rules file?

So all in all, it hasn’t improved battery life, it has made the system slower (even on AC), and has caused instability issues.

No. I have no idea. I have no problem. And I’m running tlp too and as I’m looking at your config, only difference is that I don’t set SCHED_POWERSAVE_ON_BAT=1 but 0 instead.
I’m using tlp mainly for charge control, but configured cpu settings as well because YT was choppy and I searched how to mitigate it.
But tlp wasn’t solution for that. But it still runs with this setting no problem.

As for slow working - check what have set for you both on battery and on ac

xenpm get-cpufreq-para 0

it might be that UDEV isn’t working properly for you - I’m working with energy-perf:128

1 Like

this is my output from xenpm get-cpufreq-para 0 for both battery and AC (as both give the same output)

[user@dom0 Desktop]$ xenpm get-cpufreq-para 0
cpu id               : 0
affected_cpus        : 0
cpuinfo frequency    : base [2500000] turbo [4400000]
scaling_driver       : hwp-cpufreq
scaling_avail_gov    : hwp-internal
current_governor     : hwp-internal
hwp variables        :
  hardware limits    : lowest [1] most_efficient [6]
                     : guaranteed [17] highest [56]
  configured limits  : min [1] max [9] energy_perf [255]
                     : activity_window [0 hardware selected]
                     : desired [0 hw autonomous]
turbo mode           : enabled

[user@dom0 Desktop]$

This seems weird because it is a mash up of taking the min and max from the battery file (90-on-battery.rules) and the energy-perf from AC (90-on-ac.rules). And it also says that turbo is on while on battery (and AC), but I don’t want turbo on battery.

I don’t have SCHED_POWERSAVE_ON_BAT=1 on the config file as it wasn’t on the one you posted here (for 90-on-battery.rules)

SUBSYSTEM=="power_supply", \
   ENV{POWER_SUPPLY_TYPE}=="Battery", \
   ENV{POWER_SUPPLY_STATUS}=="Discharging", \
   RUN+="/usr/sbin/xenpm set-cpufreq-hwp minimum:1 maximum:9 energy-perf:255"

What would changing SCHED_POWERSAVE_ON_BAT=1 to SCHED_POWERSAVE_ON_BAT=0 do? I just want to ask before I try it.

And how do I make sure UDEV is running correctly?

No, you have “on-battery” settings only - energy-perf:255 means very low energy, lowest possible. It looks like UDEV rules don’t mach your AC plugin. Will back at it a moment.

SCHED_POWERSAVE_ON_BAT=1 is from tlp which disables cpu cores when not used - I think it wont work with Xen/QubesOS, but it didn’t make any difference on my system during testing.

Back at UDEV rules.
Unplug your laptop from AC and in terminal run command:

sudo udevadm monitor -p

then plug AC in, wait 30s and post result in here

PS: you can manually override settings from udev for laptop to run better by

xenpm set-cpufreq-hwp min:1 max:255 energy-perf:128
1 Like

Thanks Kitsune.
Yes I can see now that the SCHED_POWERSAVE_ON_BAT=1 is from tlp - my brain misfired there!

The output from sudo udevadm monitor -p

[user@dom0 Desktop]$ sudo udevadm monitor -p
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[5776.473766] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
ACTION=change
DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/PNP0C0A:00/power_supply/BAT0
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Not charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-poly
POWER_SUPPLY_CYCLE_COUNT=115
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11520000
POWER_SUPPLY_VOLTAGE_NOW=11644000
POWER_SUPPLY_POWER_NOW=0
POWER_SUPPLY_ENERGY_FULL_DESIGN=57000000
POWER_SUPPLY_ENERGY_FULL=53120000
POWER_SUPPLY_ENERGY_NOW=33880000
POWER_SUPPLY_CAPACITY=63
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_MODEL_NAME=5B11H56342
POWER_SUPPLY_MANUFACTURER=Sunwoda
POWER_SUPPLY_SERIAL_NUMBER=20278
SEQNUM=5884

KERNEL[5776.483434] add      /devices/platform/USBC000:00/typec/port1/port1-partner (typec)
ACTION=add
DEVPATH=/devices/platform/USBC000:00/typec/port1/port1-partner
SUBSYSTEM=typec
DEVTYPE=typec_partner
SEQNUM=5885

KERNEL[5776.483696] change   /devices/platform/USBC000:00/typec/port1 (typec)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/typec/port1
SUBSYSTEM=typec
DEVTYPE=typec_port
TYPEC_PORT=port1
SEQNUM=5886

KERNEL[5776.483962] change   /devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002 (power_supply)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=ucsi-source-psy-USBC000:002
POWER_SUPPLY_TYPE=USB
POWER_SUPPLY_CHARGE_TYPE=N/A
POWER_SUPPLY_USB_TYPE=[C] PD PD_PPS
POWER_SUPPLY_ONLINE=1
POWER_SUPPLY_VOLTAGE_MIN=5000000
POWER_SUPPLY_VOLTAGE_MAX=5000000
POWER_SUPPLY_VOLTAGE_NOW=5000000
POWER_SUPPLY_CURRENT_MAX=3000000
POWER_SUPPLY_CURRENT_NOW=0
POWER_SUPPLY_SCOPE=System
SEQNUM=5887

UDEV  [5776.523235] add      /devices/platform/USBC000:00/typec/port1/port1-partner (typec)
ACTION=add
DEVPATH=/devices/platform/USBC000:00/typec/port1/port1-partner
SUBSYSTEM=typec
DEVTYPE=typec_partner
SEQNUM=5885
USEC_INITIALIZED=5776498489

UDEV  [5776.549931] change   /devices/platform/USBC000:00/typec/port1 (typec)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/typec/port1
SUBSYSTEM=typec
DEVTYPE=typec_port
TYPEC_PORT=port1
SEQNUM=5886
USEC_INITIALIZED=5776527352

KERNEL[5776.754677] change   /devices/platform/USBC000:00/typec/port1 (typec)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/typec/port1
SUBSYSTEM=typec
DEVTYPE=typec_port
TYPEC_PORT=port1
SEQNUM=5888

KERNEL[5776.754944] change   /devices/platform/USBC000:00/typec/port1/port1-partner (typec)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/typec/port1/port1-partner
SUBSYSTEM=typec
DEVTYPE=typec_partner
SEQNUM=5889

KERNEL[5776.755269] change   /devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002 (power_supply)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=ucsi-source-psy-USBC000:002
POWER_SUPPLY_TYPE=USB
POWER_SUPPLY_CHARGE_TYPE=N/A
POWER_SUPPLY_USB_TYPE=C [PD] PD_PPS
POWER_SUPPLY_ONLINE=1
POWER_SUPPLY_VOLTAGE_MIN=0
POWER_SUPPLY_VOLTAGE_MAX=0
POWER_SUPPLY_VOLTAGE_NOW=0
POWER_SUPPLY_CURRENT_MAX=0
POWER_SUPPLY_CURRENT_NOW=3000000
POWER_SUPPLY_SCOPE=System
SEQNUM=5890

UDEV  [5776.784388] change   /devices/platform/USBC000:00/typec/port1 (typec)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/typec/port1
SUBSYSTEM=typec
DEVTYPE=typec_port
TYPEC_PORT=port1
SEQNUM=5888
USEC_INITIALIZED=5776758815

UDEV  [5776.812273] change   /devices/platform/USBC000:00/typec/port1/port1-partner (typec)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/typec/port1/port1-partner
SUBSYSTEM=typec
DEVTYPE=typec_partner
SEQNUM=5889
USEC_INITIALIZED=5776788538

KERNEL[5776.954546] change   /devices/pci0000:00/0000:00:1f.0/PNP0C09:00/ACPI0003:00/power_supply/AC (power_supply)
ACTION=change
DEVPATH=/devices/pci0000:00/0000:00:1f.0/PNP0C09:00/ACPI0003:00/power_supply/AC
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=AC
POWER_SUPPLY_TYPE=Mains
POWER_SUPPLY_ONLINE=1
SEQNUM=5891

UDEV  [5777.053203] change   /devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002 (power_supply)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=ucsi-source-psy-USBC000:002
POWER_SUPPLY_TYPE=USB
POWER_SUPPLY_CHARGE_TYPE=N/A
POWER_SUPPLY_USB_TYPE=[C] PD PD_PPS
POWER_SUPPLY_ONLINE=1
POWER_SUPPLY_VOLTAGE_MIN=5000000
POWER_SUPPLY_VOLTAGE_MAX=5000000
POWER_SUPPLY_VOLTAGE_NOW=5000000
POWER_SUPPLY_CURRENT_MAX=3000000
POWER_SUPPLY_CURRENT_NOW=0
POWER_SUPPLY_SCOPE=System
SEQNUM=5887
USEC_INITIALIZED=5776503761

KERNEL[5777.418685] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
ACTION=change
DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/PNP0C0A:00/power_supply/BAT0
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Not charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-poly
POWER_SUPPLY_CYCLE_COUNT=115
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11520000
POWER_SUPPLY_VOLTAGE_NOW=11644000
POWER_SUPPLY_POWER_NOW=0
POWER_SUPPLY_ENERGY_FULL_DESIGN=57000000
POWER_SUPPLY_ENERGY_FULL=53120000
POWER_SUPPLY_ENERGY_NOW=33880000
POWER_SUPPLY_CAPACITY=63
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_MODEL_NAME=5B11H56342
POWER_SUPPLY_MANUFACTURER=Sunwoda
POWER_SUPPLY_SERIAL_NUMBER=20278
SEQNUM=5892

KERNEL[5777.573817] change   /devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002 (power_supply)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=ucsi-source-psy-USBC000:002
POWER_SUPPLY_TYPE=USB
POWER_SUPPLY_CHARGE_TYPE=N/A
POWER_SUPPLY_USB_TYPE=C [PD] PD_PPS
POWER_SUPPLY_ONLINE=1
POWER_SUPPLY_VOLTAGE_MIN=0
POWER_SUPPLY_VOLTAGE_MAX=0
POWER_SUPPLY_VOLTAGE_NOW=0
POWER_SUPPLY_CURRENT_MAX=0
POWER_SUPPLY_CURRENT_NOW=3000000
POWER_SUPPLY_SCOPE=System
SEQNUM=5893

UDEV  [5777.582555] change   /devices/pci0000:00/0000:00:1f.0/PNP0C09:00/ACPI0003:00/power_supply/AC (power_supply)
ACTION=change
DEVPATH=/devices/pci0000:00/0000:00:1f.0/PNP0C09:00/ACPI0003:00/power_supply/AC
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=AC
POWER_SUPPLY_TYPE=Mains
POWER_SUPPLY_ONLINE=1
SEQNUM=5891
USEC_INITIALIZED=5776961439

UDEV  [5777.687455] change   /devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002 (power_supply)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=ucsi-source-psy-USBC000:002
POWER_SUPPLY_TYPE=USB
POWER_SUPPLY_CHARGE_TYPE=N/A
POWER_SUPPLY_USB_TYPE=C [PD] PD_PPS
POWER_SUPPLY_ONLINE=1
POWER_SUPPLY_VOLTAGE_MIN=0
POWER_SUPPLY_VOLTAGE_MAX=0
POWER_SUPPLY_VOLTAGE_NOW=0
POWER_SUPPLY_CURRENT_MAX=0
POWER_SUPPLY_CURRENT_NOW=3000000
POWER_SUPPLY_SCOPE=System
SEQNUM=5890
USEC_INITIALIZED=5777058191

KERNEL[5777.807576] add      /devices/platform/USBC000:00/typec/port1/port1-partner/pd2 (usb_power_delivery)
ACTION=add
DEVPATH=/devices/platform/USBC000:00/typec/port1/port1-partner/pd2
SUBSYSTEM=usb_power_delivery
DEVTYPE=usb_power_delivery
SEQNUM=5894

UDEV  [5777.853182] add      /devices/platform/USBC000:00/typec/port1/port1-partner/pd2 (usb_power_delivery)
ACTION=add
DEVPATH=/devices/platform/USBC000:00/typec/port1/port1-partner/pd2
SUBSYSTEM=usb_power_delivery
DEVTYPE=usb_power_delivery
SEQNUM=5894
USEC_INITIALIZED=5777817620

KERNEL[5777.886785] change   /devices/platform/USBC000:00/typec/port1/port1-partner (typec)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/typec/port1/port1-partner
SUBSYSTEM=typec
DEVTYPE=typec_partner
SEQNUM=5895

UDEV  [5777.915371] change   /devices/platform/USBC000:00/typec/port1/port1-partner (typec)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/typec/port1/port1-partner
SUBSYSTEM=typec
DEVTYPE=typec_partner
SEQNUM=5895
USEC_INITIALIZED=5777890746

UDEV  [5778.087452] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
ACTION=change
DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/PNP0C0A:00/power_supply/BAT0
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Not charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-poly
POWER_SUPPLY_CYCLE_COUNT=115
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11520000
POWER_SUPPLY_VOLTAGE_NOW=11644000
POWER_SUPPLY_POWER_NOW=0
POWER_SUPPLY_ENERGY_FULL_DESIGN=57000000
POWER_SUPPLY_ENERGY_FULL=53120000
POWER_SUPPLY_ENERGY_NOW=33880000
POWER_SUPPLY_CAPACITY=63
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_MODEL_NAME=5B11H56342
POWER_SUPPLY_MANUFACTURER=Sunwoda
POWER_SUPPLY_SERIAL_NUMBER=20278
SEQNUM=5884
USEC_INITIALIZED=5776492852

UDEV  [5778.257745] change   /devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002 (power_supply)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=ucsi-source-psy-USBC000:002
POWER_SUPPLY_TYPE=USB
POWER_SUPPLY_CHARGE_TYPE=N/A
POWER_SUPPLY_USB_TYPE=C [PD] PD_PPS
POWER_SUPPLY_ONLINE=1
POWER_SUPPLY_VOLTAGE_MIN=0
POWER_SUPPLY_VOLTAGE_MAX=0
POWER_SUPPLY_VOLTAGE_NOW=0
POWER_SUPPLY_CURRENT_MAX=0
POWER_SUPPLY_CURRENT_NOW=3000000
POWER_SUPPLY_SCOPE=System
SEQNUM=5893
USEC_INITIALIZED=5777691443

KERNEL[5778.671936] change   /devices/platform/USBC000:00/typec/port1/port1-partner (typec)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/typec/port1/port1-partner
SUBSYSTEM=typec
DEVTYPE=typec_partner
SEQNUM=5896

UDEV  [5778.693278] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
ACTION=change
DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/PNP0C0A:00/power_supply/BAT0
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Not charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-poly
POWER_SUPPLY_CYCLE_COUNT=115
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11520000
POWER_SUPPLY_VOLTAGE_NOW=11644000
POWER_SUPPLY_POWER_NOW=0
POWER_SUPPLY_ENERGY_FULL_DESIGN=57000000
POWER_SUPPLY_ENERGY_FULL=53120000
POWER_SUPPLY_ENERGY_NOW=33880000
POWER_SUPPLY_CAPACITY=63
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_MODEL_NAME=5B11H56342
POWER_SUPPLY_MANUFACTURER=Sunwoda
POWER_SUPPLY_SERIAL_NUMBER=20278
SEQNUM=5892
USEC_INITIALIZED=5778094275

UDEV  [5778.705216] change   /devices/platform/USBC000:00/typec/port1/port1-partner (typec)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/typec/port1/port1-partner
SUBSYSTEM=typec
DEVTYPE=typec_partner
SEQNUM=5896
USEC_INITIALIZED=5778677216

KERNEL[5778.753860] change   /devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002 (power_supply)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=ucsi-source-psy-USBC000:002
POWER_SUPPLY_TYPE=USB
POWER_SUPPLY_CHARGE_TYPE=Standard
POWER_SUPPLY_USB_TYPE=C [PD] PD_PPS
POWER_SUPPLY_ONLINE=1
POWER_SUPPLY_VOLTAGE_MIN=0
POWER_SUPPLY_VOLTAGE_MAX=0
POWER_SUPPLY_VOLTAGE_NOW=0
POWER_SUPPLY_CURRENT_MAX=0
POWER_SUPPLY_CURRENT_NOW=3000000
POWER_SUPPLY_SCOPE=System
SEQNUM=5897

UDEV  [5779.334929] change   /devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002 (power_supply)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=ucsi-source-psy-USBC000:002
POWER_SUPPLY_TYPE=USB
POWER_SUPPLY_CHARGE_TYPE=Standard
POWER_SUPPLY_USB_TYPE=C [PD] PD_PPS
POWER_SUPPLY_ONLINE=1
POWER_SUPPLY_VOLTAGE_MIN=0
POWER_SUPPLY_VOLTAGE_MAX=0
POWER_SUPPLY_VOLTAGE_NOW=0
POWER_SUPPLY_CURRENT_MAX=0
POWER_SUPPLY_CURRENT_NOW=3000000
POWER_SUPPLY_SCOPE=System
SEQNUM=5897
USEC_INITIALIZED=5778758322

These are the results by typing in sudo udevadm monitor -p into dom0 terminal while the AC is unattached (on battery), and then plugging in the AC, which then I waited 30 seconds.

And this is what I get when I do it the other way around (inputting sudo udevadm monitor -p while the AC is plugged in, and then removing AC cable - I know you didn’t ask for this but just thought I would include it anyway in case it was useful)

[user@dom0 Desktop]$ sudo udevadm monitor -p
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[6670.519479] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
ACTION=change
DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/PNP0C0A:00/power_supply/BAT0
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Not charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-poly
POWER_SUPPLY_CYCLE_COUNT=115
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11520000
POWER_SUPPLY_VOLTAGE_NOW=12961000
POWER_SUPPLY_POWER_NOW=0
POWER_SUPPLY_ENERGY_FULL_DESIGN=57000000
POWER_SUPPLY_ENERGY_FULL=53120000
POWER_SUPPLY_ENERGY_NOW=41290000
POWER_SUPPLY_CAPACITY=77
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_MODEL_NAME=5B11H56342
POWER_SUPPLY_MANUFACTURER=Sunwoda
POWER_SUPPLY_SERIAL_NUMBER=20278
SEQNUM=5964

KERNEL[6670.963564] change   /devices/pci0000:00/0000:00:1f.0/PNP0C09:00/ACPI0003:00/power_supply/AC (power_supply)
ACTION=change
DEVPATH=/devices/pci0000:00/0000:00:1f.0/PNP0C09:00/ACPI0003:00/power_supply/AC
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=AC
POWER_SUPPLY_TYPE=Mains
POWER_SUPPLY_ONLINE=0
SEQNUM=5965

KERNEL[6671.335967] remove   /devices/platform/USBC000:00/typec/port1/port1-partner/pd2 (usb_power_delivery)
ACTION=remove
DEVPATH=/devices/platform/USBC000:00/typec/port1/port1-partner/pd2
SUBSYSTEM=usb_power_delivery
DEVTYPE=usb_power_delivery
SEQNUM=5966

KERNEL[6671.336443] remove   /devices/platform/USBC000:00/typec/port1/port1-partner (typec)
ACTION=remove
DEVPATH=/devices/platform/USBC000:00/typec/port1/port1-partner
SUBSYSTEM=typec
DEVTYPE=typec_partner
SEQNUM=5967

KERNEL[6671.336692] change   /devices/platform/USBC000:00/typec/port1 (typec)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/typec/port1
SUBSYSTEM=typec
DEVTYPE=typec_port
TYPEC_PORT=port1
SEQNUM=5968

KERNEL[6671.337138] change   /devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002 (power_supply)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=ucsi-source-psy-USBC000:002
POWER_SUPPLY_TYPE=USB
POWER_SUPPLY_CHARGE_TYPE=N/A
POWER_SUPPLY_USB_TYPE=[C] PD PD_PPS
POWER_SUPPLY_ONLINE=0
POWER_SUPPLY_VOLTAGE_MIN=0
POWER_SUPPLY_VOLTAGE_MAX=0
POWER_SUPPLY_VOLTAGE_NOW=0
POWER_SUPPLY_CURRENT_MAX=0
POWER_SUPPLY_CURRENT_NOW=0
POWER_SUPPLY_SCOPE=System
SEQNUM=5969

UDEV  [6671.374928] remove   /devices/platform/USBC000:00/typec/port1/port1-partner/pd2 (usb_power_delivery)
ACTION=remove
DEVPATH=/devices/platform/USBC000:00/typec/port1/port1-partner/pd2
SUBSYSTEM=usb_power_delivery
DEVTYPE=usb_power_delivery
SEQNUM=5966
USEC_INITIALIZED=6671336282

UDEV  [6671.405965] remove   /devices/platform/USBC000:00/typec/port1/port1-partner (typec)
ACTION=remove
DEVPATH=/devices/platform/USBC000:00/typec/port1/port1-partner
SUBSYSTEM=typec
DEVTYPE=typec_partner
SEQNUM=5967
USEC_INITIALIZED=6671342347

UDEV  [6671.442184] change   /devices/platform/USBC000:00/typec/port1 (typec)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/typec/port1
SUBSYSTEM=typec
DEVTYPE=typec_port
TYPEC_PORT=port1
SEQNUM=5968
USEC_INITIALIZED=6671411662

UDEV  [6671.570604] change   /devices/pci0000:00/0000:00:1f.0/PNP0C09:00/ACPI0003:00/power_supply/AC (power_supply)
ACTION=change
DEVPATH=/devices/pci0000:00/0000:00:1f.0/PNP0C09:00/ACPI0003:00/power_supply/AC
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=AC
POWER_SUPPLY_TYPE=Mains
POWER_SUPPLY_ONLINE=0
SEQNUM=5965
USEC_INITIALIZED=6670981963

UDEV  [6671.883216] change   /devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002 (power_supply)
ACTION=change
DEVPATH=/devices/platform/USBC000:00/power_supply/ucsi-source-psy-USBC000:002
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=ucsi-source-psy-USBC000:002
POWER_SUPPLY_TYPE=USB
POWER_SUPPLY_CHARGE_TYPE=N/A
POWER_SUPPLY_USB_TYPE=[C] PD PD_PPS
POWER_SUPPLY_ONLINE=0
POWER_SUPPLY_VOLTAGE_MIN=0
POWER_SUPPLY_VOLTAGE_MAX=0
POWER_SUPPLY_VOLTAGE_NOW=0
POWER_SUPPLY_CURRENT_MAX=0
POWER_SUPPLY_CURRENT_NOW=0
POWER_SUPPLY_SCOPE=System
SEQNUM=5969
USEC_INITIALIZED=6671357976

UDEV  [6672.012272] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
ACTION=change
DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/PNP0C0A:00/power_supply/BAT0
SUBSYSTEM=power_supply
DEVTYPE=power_supply
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Not charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-poly
POWER_SUPPLY_CYCLE_COUNT=115
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11520000
POWER_SUPPLY_VOLTAGE_NOW=12961000
POWER_SUPPLY_POWER_NOW=0
POWER_SUPPLY_ENERGY_FULL_DESIGN=57000000
POWER_SUPPLY_ENERGY_FULL=53120000
POWER_SUPPLY_ENERGY_NOW=41290000
POWER_SUPPLY_CAPACITY=77
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_MODEL_NAME=5B11H56342
POWER_SUPPLY_MANUFACTURER=Sunwoda
POWER_SUPPLY_SERIAL_NUMBER=20278
SEQNUM=5964
USEC_INITIALIZED=6670537819

It’s exactly as mine so udev rules should work. When AC is removed then udev event is

SUBSYSTEM=power_supply
POWER_SUPPLY_TYPE=Mains
POWER_SUPPLY_ONLINE=0

and when AC is being attached udev event is

SUBSYSTEM=power_supply
POWER_SUPPLY_TYPE=Mains
POWER_SUPPLY_ONLINE=1

Maybe you have some typo… issue command

sudo udevadm control --log-level="debug"

then unplug AC and plug it back and then show 10 lines from last boot syslog containing xenpm by issuing command

journalctl -b -g xenpm -n 10
2 Likes