# High power consumption on Thinkpad x230



## hotzenplotz (Apr 22, 2021)

Hi,

I'm on FreeBSD 13 on a Thinkpad x230 and am trying to optimise the power use when on battery.

I followed some of the advice given here, since that was the most recent article on saving power I could find. The wiki article seems rather old, referencing FreeBSD 8 / 9, and as someone new to this, I wasn't sure how valid that advice still is.

Power consumption is regularly over 15W. See output below.

I tried both, powerd and powerdxx, but none improved the situation. I used the following:


```
# Power management
#powerdxx_enable="YES"
#powerdxx_flags="-n adaptive -a hiadaptive -b adaptive -m 800 -M 1600"

powerd_enable="YES"
powerd_flags="-a maximum -b adaptive -i 85 -r 60 -p 100"

performance_cx_lowest="HIGH"    # Online CPU idle state
performance_cpu_freq="NONE"     # Online CPU frequency
economy_cx_lowest="HIGH"        # Offline CPU idle state
economy_cpu_freq="NONE"         # Offline CPU frequency
```


I also tried tweaking the loader.conf variables as discussed in the above linked article, but to no avail...


```
cpuctl_enable="YES"

# AHCI POWER MANAGEMENT FOR EVERY USED CHANNEL (ahcich 0-7)
  hint.ahcich.0.pm_level=5
  hint.ahcich.1.pm_level=5
  hint.ahcich.2.pm_level=5
  hint.ahcich.3.pm_level=5
  hint.ahcich.4.pm_level=5
  hint.ahcich.5.pm_level=5
  hint.ahcich.6.pm_level=5
  hint.ahcich.7.pm_level=5

# POWER OFF DEVICES WITHOUT ATTACHED DRIVER
  hw.pci.do_power_nodriver=3

# INTEL DRM WITH graphics/drm-kmod PACKAGE (NEW)
# SKIP UNNECESSARY MODE SETS AT BOOT TIME
  compat.linuxkpi.fastboot=1
# USE SEMAPHORES FOR INTER RING SYNC
  compat.linuxkpi.semaphores=1
# ENABLE POWER SAVING RENDER C-STATE 6
  compat.linuxkpi.enable_rc6=7
# ENABLE POWER SAVING DISPLAY C-STATES
  compat.linuxkpi.enable_dc=2
# ENABLE FRAME BUFFER COMPRESSION FOR POWER SAVINGS
  compat.linuxkpi.enable_fbc=1
```


Are there any other options I could try? Thanks!


Sample power consumption:


```
>> acpiconf -i 0               
Design capacity:        93960 mWh
Last full capacity:     93900 mWh
Technology:             secondary (rechargeable)
Design voltage:         10800 mV
Capacity (warn):        4695 mWh
Capacity (low):         200 mWh
Low/warn granularity:   1 mWh
Warn/full granularity:  1 mWh
Model number:           45N1175
Serial number:            526
Type:                   LION
OEM info:               SANYO
State:                  discharging
Remaining capacity:     76%
Remaining time:         4:32
Present rate:           15710 mW
Present voltage:        11586 mV
```


----------



## bessie (Apr 24, 2021)

I don't want hijack your thread, but I was just about to post on the same problem, different hardware: Huawei Matebook13 2019 model. FreeBSD-RELEASE-13.0, and power consumption always just a little more than my 15 watt charger. I think I've got missing acpi functions. Have you also seen this thread?


----------



## hotzenplotz (Apr 24, 2021)

Thanks, I haven't seen this one... if I read the output below correctly, my CPUs don't relax...


```
>> sudo  sysctl dev.cpu.{0,1,2,3}.cx_usage
dev.cpu.0.cx_usage: 100.00% 0.00% 0.00% last 5290us
dev.cpu.1.cx_usage: 100.00% 0.00% 0.00% last 1716us
dev.cpu.2.cx_usage: 100.00% 0.00% 0.00% last 3180us
dev.cpu.3.cx_usage: 100.00% 0.00% 0.00% last 9399us
```

I tried the recommendations in that thread but it didn't have any impact. Has it done anything for you at all?


----------



## Crivens (Apr 24, 2021)

My x230 does use C states and goes down to about 9W when idle. I may need to tune it a bit more, did not do much in that regard.


----------



## kpedersen (Apr 24, 2021)

You have:


> performance_cx_lowest="HIGH"    # Online CPU idle state
> performance_cpu_freq="NONE"     # Online CPU frequency
> economy_cx_lowest="HIGH"        # Offline CPU idle state
> economy_cpu_freq="NONE"         # Offline CPU frequency


Is this correct? Shouldn't it be:


```
performance_cx_lowest="Cmax"
economy_cx_lowest="Cmax"
```


----------



## hotzenplotz (Apr 24, 2021)

kpedersen said:


> You have:
> 
> Is this correct? Shouldn't it be:
> 
> ...



You are right! Not sure how I got this there.... Thanks for picking this up. I changed it, however it doesn't seem to have an effect...

EDIT: actually those are from the wiki


----------



## hotzenplotz (Apr 24, 2021)

Crivens said:


> My x230 does use C states and goes down to about 9W when idle. I may need to tune it a bit more, did not do much in that regard.



I discovered the high power usage after a fresh install of FreeBSD 13 and after setting up KDE, vpn etc. Are you also running FreeBSD 13?


----------



## Crivens (Apr 24, 2021)

Yes, running -13, build from source.


----------



## hotzenplotz (Apr 25, 2021)

Crivens said:


> My x230 does use C states and goes down to about 9W when idle. I may need to tune it a bit more, did not do much in that regard.



I discovered the high power usage after a fresh install of FreeBSD 13 and after setting up KDE, vpn etc. Are you also running FreeBSD 13?


----------



## hotzenplotz (Apr 25, 2021)

So I do have the C states working now, after changing `machdep.idle=acpi` (changing back to default?). When I had it set to `hlt` and `spin`, `sysctl dev.cpu.0.cx_usage` didn't report any percentages, i.e. it was all 0%. Before I started playing with this setting, it was shown to be 100% for C1 (see post above). Here is the current output:


```
>> sysctl dev.cpu.{0,1,2,3}.cx_usage
dev.cpu.0.cx_usage: 12.24% 14.46% 73.28% last 368us
dev.cpu.1.cx_usage: 8.96% 9.37% 81.65% last 300us
dev.cpu.2.cx_usage: 9.36% 10.29% 80.34% last 428us
dev.cpu.3.cx_usage: 8.79% 8.62% 82.58% last 332us
```

Now power consumption is a tad better, but nowhere where I'd like it to be:


```
>> acpiconf -i0 | grep -i rate
Present rate:           13879 mW
```

Are there any other tweaks that I could try? Is there an equivalent to powertop on linux, which does a lot of these settings?

On the positive side, I come to like a lot the way FreeBSD is configured. It seems a fair bit cleaner then linux and I can confirm that the documentation is better (for me at least).


----------



## Crivens (Apr 25, 2021)

I set the screen brightness to 50-60%. Power off BT and camera when unused. Use pci.power_nodriver=3.


----------



## George (Apr 25, 2021)

I think the Howto of Vermaden is not outdated yet.

It is here:








						The Power to Serve – FreeBSD Power Management
					

This is the motto of the FreeBSD operating system – The Power to Serve – which also greatly fits for the topic of this article. Decade ago (yes time flies) I even made a wallpaper with …




					vermaden.wordpress.com
				




There are many areas to look at, e.g. CPU, screen brightness, network powersave modes, peripherals (usb, pci).

There were a few reports about high power consumption on FreeBSD 13 recently (e.g. acpi mailing list, bugzilla).


----------



## bessie (Apr 25, 2021)

OP, you seem to have done all the things I have, with similar results. I would have thought Thinkpads were pretty thoroughly "normal" by now. Does your `kldstat` show `acpi_ibm.ko` ? If not, you may need to add it to /etc/rc.conf as `kldlist="acpi_ibm.ko"`


----------



## hotzenplotz (Apr 26, 2021)

bessie said:


> OP, you seem to have done all the things I have, with similar results. I would have thought Thinkpads were pretty thoroughly "normal" by now. Does your `kldstat` show `acpi_ibm.ko` ? If not, you may need to add it to /etc/rc.conf as `kldlist="acpi_ibm.ko"`


Yep, it's there... I think I remember adding it while trying to optimise...


----------

