powerdxx ineffective on X230? (poor battery life/energy consumption)

Dear community,

I am running FreeBSD 12.1-RELEASE-p1 on a X230 Thinkpad. It's great, even suspend/resume works. However, one thing that keeps bothering me is the power consumption. I can't get the battery to last longer than three hours and change:

Code:
# acpiconf -i 0
Passwort:
Design capacity:    48840 mWh
Last full capacity:    45090 mWh
Technology:        secondary (rechargeable)
Design voltage:        11100 mV
Capacity (warn):    2254 mWh
Capacity (low):        200 mWh
Low/warn granularity:    1 mWh
Warn/full granularity:    1 mWh
Model number:        45N1023
Serial number:        37662
Type:            LION
OEM info:        SANYO
State:            discharging
Remaining capacity:    86%
Remaining time:        2:53
Present rate:        13533 mW
Present voltage:    11567 mV

I'm trying to improve energy efficiency with powerdxx(), but to no avail.



With powerdxx disabled:


Code:
 # service powerdxx stop
# powermon
                  Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz
                       (Arch: Ivy Bridge, Limit: 28W)



   3.65W [========>
     ]



Package:           Uncore:             x86 Cores:          GPU:
Current: 3.65W     Current: 2.50W      Current: 1.12W      Current: 0.04W
Total: 2195.02J    Total: 1476.74J     Total: 694.53J      Total: 23.75J

With powerdxx enabled:

Code:
# powerdxx -b adp -a adp -n adp -vf
Terminal Output
    verbose:               yes
    foreground:            yes
Load Sampling
    load samples:          4
    polling interval:      500 ms
    load average over:     2000 ms
Frequency Limits
    battery:               [0 MHz, 1000000 MHz]
    online:                [0 MHz, 1000000 MHz]
    unknown:               [0 MHz, 1000000 MHz]
CPU Cores
    CPU cores:             4
Core Groups
      0:                   [0, 3]
Core Group Frequency Limits
      0:                   [1200 MHz, 2601 MHz]
Load Targets
    battery power target:  50 % load
    online power target:   50 % load
    unknown power target:  50 % load
Temperature Throttling
    active:                yes
      0:                   [95 C, 105 C]
power: battery, load:  497 MHz,  48 C, cpu.0.freq: 1200 MHz, wanted:  994 MHz
power: battery, load:  398 MHz,  47 C, cpu.0.freq: 1200 MHz, wanted:  796 MHz
power: battery, load:  296 MHz,  49 C, cpu.0.freq: 1200 MHz, wanted:  592 MHz

Enabled, watching powermon():

Code:
                  Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz
                       (Arch: Ivy Bridge, Limit: 28W)



   5.44W [=============>                                                     ]



Package:           Uncore:             x86 Cores:          GPU:
Current: 5.44W     Current: 2.65W      Current: 2.40W      Current: 0.39W
Total: 6845.07J    Total: 4469.26J     Total: 2261.48J     Total: 114.32J

As you can see, the CPU seems to draw more or less the same power. What could be the reason for this strange behaviour? Moreover, the largest energy consumer is "Uncore" rather than the x86 Cores. Is this regulated by powerdxx() as well? I've read that loading drm-next-kmod in /boot/loader.conf reduces power consumption of the GPU. However, according to the statistics above, the GPU uses the least energy; and I also can't find a package or port of this name in my 12.1-RELEASE installation.

Before you ask, switching from powerdxx() to powerd() doesn't help.
 
I've read that loading drm-next-kmod in /boot/loader.conf reduces power consumption of the GPU. However, according to the statistics above, the GPU uses the least energy; and I also can't find a package or port of this name in my 12.1-RELEASE installation.
Code:
20181209:
  AFFECTS: users of DRM ports other than graphics/drm-kmod
  AUTHOR: jmd@FreeBSD.org

  In order to facilitate future porting efforts and help in supporting multiple
  FreeBSD versions, the DRM ports other than drm-kmod (graphics/drm-stable-kmod,
  graphics/drm-next-kmod, graphics/drm-devel-kmod) have been renamed to
  include the FreeBSD version they are designed for.

  drm-stable-kmod is drm-fbsd11.2-kmod
  drm-next-kmod is drm-fbsd12.0-kmod
  drm-devel-kmod is drm-current-kmod
Please read /usr/ports/UPDATING.

I can't comment on the power consumption though, I don't have a FreeBSD laptop and I don't use Intel graphics.
 
Have you had a read through here:
https://forums.freebsd.org/threads/howto-freebsd-cpu-scaling-and-power-saving.172/

The big one for me was:

Code:
# sysctl dev.cpu.0.cx_lowest=C3

for each of my cpus. There is also the kern.hz tunable but it didn't make too much difference for me.
Is any specific part of your laptop hotter than usual (i.e running Windows / Linux)? Perhaps try disabling components in the bios to try to narrow down what causes it.
My Thinkpad had a stupid fingerprint scanner that sucked energy all the time. Even made a hissing noise when the machine was turned off. The other operating systems had a driver that could at least disable it.

There was also a command to disable USB power for unused ports but I cannot find it.
 
The big one for me was:

Code:
# sysctl dev.cpu.0.cx_lowest=C3

for each of my cpus.

Good idea. However, my CPU seems to support an even lower C state, which is apparently enabled by default:

Code:
sysctl dev.cpu | grep cx
dev.cpu.3.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.3.cx_usage_counters: 55628 37455 507658
dev.cpu.3.cx_usage: 9.25% 6.23% 84.50% last 450us
dev.cpu.3.cx_lowest: C8
dev.cpu.3.cx_supported: C1/1/1 C2/2/59 C3/3/87
dev.cpu.2.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.2.cx_usage_counters: 84781 72770 657160
dev.cpu.2.cx_usage: 10.40% 8.93% 80.66% last 148us
dev.cpu.2.cx_lowest: C8
dev.cpu.2.cx_supported: C1/1/1 C2/2/59 C3/3/87
dev.cpu.1.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.1.cx_usage_counters: 51619 34555 432139
dev.cpu.1.cx_usage: 9.95% 6.66% 83.37% last 119us
dev.cpu.1.cx_lowest: C8
dev.cpu.1.cx_supported: C1/1/1 C2/2/59 C3/3/87
dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.0.cx_usage_counters: 76487 49092 532762
dev.cpu.0.cx_usage: 11.61% 7.45% 80.92% last 141us
dev.cpu.0.cx_lowest: C8
dev.cpu.0.cx_supported: C1/1/1 C2/2/59 C3/3/87

Code:
  drm-next-kmod is drm-fbsd12.0-kmod

Thank you. I should have better checked the release notes. I've added the driver but this doesn't help much. Most power drains by "Uncore", but I don't know what to make of it.

There was also a command to disable USB power for unused ports but I cannot find it.

Thanks. My USB ports seem to go into some power saving mode anyway, either by default or due to one of the settings below.

Code:
# usbconfig show_ifdrv
Passwort: 
ugen1.1: <Intel EHCI root HUB> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen1.1.0: uhub0: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1>
ugen0.1: <0x8086 XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.1.0: uhub1: <0x8086 XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1>
ugen2.1: <Intel EHCI root HUB> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.1.0: uhub2: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1>
ugen1.2: <vendor 0x8087 product 0x0024> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen1.2.0: uhub3: <vendor 0x8087 product 0x0024, class 9/0, rev 2.00/0.00, addr 2>
ugen2.2: <vendor 0x8087 product 0x0024> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.2.0: uhub4: <vendor 0x8087 product 0x0024, class 9/0, rev 2.00/0.00, addr 2>
ugen1.3: <Broadcom Corp BCM20702A0> at usbus1, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (0mA)
ugen1.3.0: ubt0: <Broadcom Corp BCM20702A0, rev 2.00/1.12, addr 3>

For sake of completeness, I also have some other energy efficiency tweaks enabled:

/boot/loader.conf:
Code:
# No power for devices without driver:
hw.pci.do_power_nodriver=3
# More efficient GPU
drm.i915.enable_rc6=7
drm.i915.semaphores=1
drm.i915.intel_iommu_enabled=1
# Less sound interrupts
hw.snd.latency=7

/etc/rc.conf:
Code:
# save energy on WiFi
ifconfig_wlan0="WPA DHCP powersave"

# CPU power saving, requires powerdxx
# Using default settings, e.g. -a hadp -b adp -n hadp
powerdxx_enable="YES"
 
To whom it may concern in the future: I've concluded that this most likely is not an issue with powerdxx -- after all the CPU power consumption is rather low -- but a problem with my battery. Although it reports a good status, the battery dies on a reported 45% charge. Moreover, running Windows 7 on the same machine, the battery life is even worse.
 
Good idea. However, my CPU seems to support an even lower C state, which is apparently enabled by default:

Code:
sysctl dev.cpu | grep cx
dev.cpu.3.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.3.cx_usage_counters: 55628 37455 507658
dev.cpu.3.cx_usage: 9.25% 6.23% 84.50% last 450us
dev.cpu.3.cx_lowest: C8
dev.cpu.3.cx_supported: C1/1/1 C2/2/59 C3/3/87
dev.cpu.2.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.2.cx_usage_counters: 84781 72770 657160
dev.cpu.2.cx_usage: 10.40% 8.93% 80.66% last 148us
dev.cpu.2.cx_lowest: C8
dev.cpu.2.cx_supported: C1/1/1 C2/2/59 C3/3/87
dev.cpu.1.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.1.cx_usage_counters: 51619 34555 432139
dev.cpu.1.cx_usage: 9.95% 6.66% 83.37% last 119us
dev.cpu.1.cx_lowest: C8
dev.cpu.1.cx_supported: C1/1/1 C2/2/59 C3/3/87
dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.0.cx_usage_counters: 76487 49092 532762
dev.cpu.0.cx_usage: 11.61% 7.45% 80.92% last 141us
dev.cpu.0.cx_lowest: C8
dev.cpu.0.cx_supported: C1/1/1 C2/2/59 C3/3/87



Thank you. I should have better checked the release notes. I've added the driver but this doesn't help much. Most power drains by "Uncore", but I don't know what to make of it.



Thanks. My USB ports seem to go into some power saving mode anyway, either by default or due to one of the settings below.

Code:
# usbconfig show_ifdrv
Passwort:
ugen1.1: <Intel EHCI root HUB> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen1.1.0: uhub0: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1>
ugen0.1: <0x8086 XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.1.0: uhub1: <0x8086 XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1>
ugen2.1: <Intel EHCI root HUB> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.1.0: uhub2: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1>
ugen1.2: <vendor 0x8087 product 0x0024> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen1.2.0: uhub3: <vendor 0x8087 product 0x0024, class 9/0, rev 2.00/0.00, addr 2>
ugen2.2: <vendor 0x8087 product 0x0024> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.2.0: uhub4: <vendor 0x8087 product 0x0024, class 9/0, rev 2.00/0.00, addr 2>
ugen1.3: <Broadcom Corp BCM20702A0> at usbus1, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (0mA)
ugen1.3.0: ubt0: <Broadcom Corp BCM20702A0, rev 2.00/1.12, addr 3>

For sake of completeness, I also have some other energy efficiency tweaks enabled:

/boot/loader.conf:
Code:
# No power for devices without driver:
hw.pci.do_power_nodriver=3
# More efficient GPU
drm.i915.enable_rc6=7
drm.i915.semaphores=1
drm.i915.intel_iommu_enabled=1
# Less sound interrupts
hw.snd.latency=7

/etc/rc.conf:
Code:
# save energy on WiFi
ifconfig_wlan0="WPA DHCP powersave"

# CPU power saving, requires powerdxx
# Using default settings, e.g. -a hadp -b adp -n hadp
powerdxx_enable="YES"
About your lines in /boot/loader.conf, you should note that when using graphics/drm-kmod they have no effect. You would need to change them to:
Code:
# More efficient GPU
compat.linuxkpi.enable_rc6=7
compat.linuxkpi.semaphores=1
# This one below doesn't seem to exist anymore
#drm.i915.intel_iommu_enabled=1
Also, "hw.snd.latency=7" is discouraged as it causes some issues with sound quality.
Hope it helps 👍
 
I noticed on my X230 a slight hissing sound and battery power just evaporates after a while.

What it turned out to be is the finger print scanner. It is providing some dumb pointless feature of being able to start the machine by swiping your thumb, so always needed to be active. I disabled that in the BIOS (actually I disconnected the whole thing for good measure).
 
Back
Top