# Tweaking Power Consumption



## dr3mro (Apr 23, 2022)

I have Thinkpad x250 with freeBSD 13.1 RC4 with most of tweaks  I could find online and in man pages enabled but I cannot get my power consuption below 5.5W even with all those tweaks and I am using BSPWM for comparison MS windows 10 uses 7 watt with all bloat running and UBUNTU 22.04 GNOME 42 uses 2.5 out of the box
any Ideas how could I get more power savings
here is my confs

/etc/sysctl.conf

```
# $FreeBSD$
#
#  This file is read when going to multi-user and its contents piped thru
#  ``sysctl'' to adjust kernel values.  ``man 5 sysctl.conf'' for details.
#
kern.coredump=0
# Uncomment this to prevent users from seeing information about processes that
# are being run under another UID.
#security.bsd.see_other_uids=0
dev.cpu.0.cx_lowest="Cmax"
dev.cpu.1.cx_lowest="Cmax"
dev.cpu.2.cx_lowest="Cmax"
dev.cpu.3.cx_lowest="Cmax"

# increase UFS readahead
vfs.read_max=256

# allow users to mount disks without root permissions
vfs.usermount=1

# make desktop more responsive under high CPU load
kern.sched.preempt_thresh=224

# disable annoying system beep
hw.syscons.bell=0
kern.vt.enable_bell=0

# needed for chromium to work
kern.ipc.shm_allow_removed=1

# enable IPv6 autoconfiguration
net.inet6.ip6.accept_rtadv=1

# suspend on lid close
hw.acpi.lid_switch_state=NONE

# increase the nub's tracking sensitivity - tweak to your liking
hw.psm.trackpoint.sensitivity=255
hw.psm.trackpoint.upper_plateau=125

# uncomment this to disable the touchpad - I never use it
# hw.psm.synaptics.touchpad_off=1

# some tweaks to boost network performance over long, fat pipes - see the
# networking section of my server guide for details.
net.inet.tcp.cc.algorithm=htcp
net.inet.tcp.cc.htcp.adaptive_backoff=1
net.inet.tcp.cc.htcp.rtt_scaling=1
net.inet.tcp.rfc6675_pipe=1
net.inet.tcp.syncookies=0
net.inet.tcp.nolocaltimewait=1
kern.ipc.soacceptqueue=1024
kern.ipc.maxsockbuf=8388608
kern.ipc.maxsockbuf=2097152
net.inet.tcp.sendspace=262144
net.inet.tcp.recvspace=262144
net.inet.tcp.sendbuf_max=16777216
net.inet.tcp.recvbuf_max=16777216
net.inet.tcp.sendbuf_inc=32768
#net.inet.tcp.recvbuf_inc=65536
net.local.stream.sendspace=16384
net.local.stream.recvspace=16384
net.inet.raw.maxdgram=16384
net.inet.raw.recvspace=16384
net.inet.tcp.abc_l_var=44
net.inet.tcp.initcwnd_segments=44
net.inet.tcp.mssdflt=1448
net.inet.tcp.minmss=524
net.inet.ip.intr_queue_maxlen=2048
net.route.netisr_maxqlen=2048
#dev.acpi_ibm.0.bluetooth=1
kern.vt.suspendswitch=0
kern.vt.deadtimer=6000
hw.usb.no_suspend_wait=1
#hw.pci.do_power_suspend=0
#hw.pci.do_power_resume=0

hw.snd.vpc_0db=15

# tweaks
# NETWORK/CERTAIN ICMP UNREACHABLE MESSAGES MAY ABORT CONNECTIONS IN SYN_SENT (1)
  net.inet.tcp.icmp_may_rst=0

# NETWORK/RECYCLE CLOSED FIN_WAIT_2 CONNECTIONS FASTER (0)
  net.inet.tcp.fast_finwait2_recycle=1

# NETWORK/DROP TCP PACKETS WITH SYN+FIN SET (0)
  net.inet.tcp.drop_synfin=1

# NETWORK/IGNORE ICMP REDIRECTS (0)
  net.inet.icmp.drop_redirect=1

# NETWORK/ASSIGN RANDOM ip_id VALUES (0)
  net.inet.ip.random_id=1

# NETWORK/ENABLE SENDING IP REDIRECTS (1)
  net.inet.ip.redirect=0

# NETWORK/DO NOT SEND RST ON SEGMENTS TO CLOSED PORTS
#  net.inet.tcp.blackhole=2

# NETWORK/DO NOT SEND PORT UNREACHABLES FOR REFUSED CONNECTS
#  net.inet.udp.blackhole=1

# NETWORK/LIMIT ON SYN/ACK RETRANSMISSIONS (3)
  net.inet.tcp.syncache.rexmtlimit=0

# DESKTOP QUANTUM FOR TIMESHARE THREADS IN stathz TICKS (12) NomadBSD
  kern.sched.slice=3

# DESKTOP/IRIDIUM/CHROMIUM
  kern.ipc.shm_allow_removed=1

# SAMPLE RATE CONVERTER QUALITY (0=low .. 4=high) (1) NomadBSD
  hw.snd.feeder_rate_quality=3

# PERFORMANCE/ALL SHARED MEMORY SEGMENTS WILL BE MAPPED TO UNPAGEABLE RAM
  kern.ipc.shm_use_phys=1
```

/etc/rc.conf


```
hostname="x250"
keymap="fi.kbd"
sshd_enable="NO"
rc_startmsgs=NO
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="NO"
wlans_iwm0="wlan0"
ifconfig_wlan0="WPA DHCP powersave"
defaultroute_delay=3
defaultroute_carrier_delay=3

kld_list="/boot/modules/i915kms.ko coretemp /boot/modules/thinkpad_smapi.ko acpi_wmi ichsmb pchtherm ng_ubt if_iwm if_iwlwifi acpi_dock umodem if_cdce"
sendmail_enable="NONE"
allscreens_flags="-f vgarom-thin-8x16"
performance_cx_lowest="Cmax"
economy_cx_lowest="Cmax"
#autofs_enable="YES"
#hald_enable="YES"
dbus_enable="YES"
webcamd_enable="YES"
devd_enable="YES"
devfs_system_ruleset="devfsrules_common"
background_dhclient="YES"
powerdxx_enable="YES"
powerdxx_flags="-a hiadaptive -b adaptive --max-batt 1900 -t dev.cpu.%d.temperature -N"
fanctl_enable="YES"
```

/boot/loader.conf


```
cpu_microcode_load="YES"
cpu_microcode_name="/boot/firmware/intel-ucode.bin
kern.vty="vt"
kern.vt.fb.default_mode="1366x768"
allscreens_flags="-f vgarom-thin-8x16"
screen.font="8x16"
cpufreq_load="YES"
#tmpfs_load="YES"
#autofs_load="YES"
# POWER OFF DEVICES WITHOUT ATTACHED DRIVER
hw.em.smart_pwr_down=1
hw.pci.do_power_nodriver=3
hw.snd.latency=7

# enable IBM ACPI
acpi_ibm_load="YES"
acpi_dock_enable="YES"
# enable cuse for webcamd
cuse_load="YES"

# fusefs for ntfs
fusefs_load="YES"

compat.linuxkpi.semaphores="1"  # USE SEMAPHORES FOR INTER RING SYNC
compat.linuxkpi.enable_rc6="7"  # ENABLE POWER SAVING RENDER C-STATE 6
compat.linuxkpi.i915_enable_guc=2 # firmware loading

#hw.i915kms.enable_psr=1
#hw.i915kms.enable_hangcheck=0

hw.i915kms.enable_dc=2  # ENABLE POWER SAVING DISPLAY C-STATES
hw.i915kms.enable_fbc=1 # ENABLE FRAME BUFFER COMPRESSION FOR POWER SAVINGS
hw.i915kms.nuclear_pageflip=1
compat.linuxkpi.i915_fastboot=1 # SKIP UNNECESSARY MODESETS AT BOOT TIME

#compat.linuxkpi.i915_reset=1

# simplified boot
boot_mute="NO"
beastie_disable="YES"
autoboot_delay="-1"

hw.usb.no_boot_wait=1

# these values need to be bumped up a bit for desktop usage
kern.maxproc="100000"
kern.ipc.shmseg="1024"
kern.ipc.shmmni="1024"

# enable the nub and the touchpad
hw.psm.trackpoint_support="1"
hw.psm.synaptics_support="1"

# Enables a faster but possibly buggy implementation of soreceive
net.inet.tcp.soreceive_stream="1"

# increase the network interface queue link - the default (50) is way
# too low
net.link.ifqmaxlen="2048"

# enable hardware accelerated AES (can speed up TLS)
aesni_load="YES"

# Load the H-TCP algorithm. It has a more aggressive ramp-up to max
# bandwidth, and is optimized for high-speed, high-latency connections.
cc_htcp_load="YES"

# enable CPU firmware updates
cpuctl_load="YES"

# enable CPU temperature monitoring
coretemp_load="YES"


# load firmware for wireless card - I have Intel 6300-N
iwm7265Dfw_load="YES"

# desktop-ish filesystems, webcam driver, etc
cuse4bsd_load="YES"
libiconv_load="YES"
libiconv_load="YES"
libmchain_load="YES"
cd9660_iconv_load="YES"
msdosfs_iconv_load="YES"

machdep.hwpstate_pkg_ctrl=1

# TERMINAL vt(4) COLORS
kern.vt.color.0.rgb="#000000"
kern.vt.color.1.rgb="#dc322f"
kern.vt.color.2.rgb="#859900"
kern.vt.color.3.rgb="#b58900"
kern.vt.color.4.rgb="#268bd2"
kern.vt.color.5.rgb="#ec0048"
kern.vt.color.6.rgb="#2aa198"
kern.vt.color.7.rgb="#94a3a5"
kern.vt.color.8.rgb="#586e75"
kern.vt.color.9.rgb="#cb4b16"
kern.vt.color.10.rgb="#859900"
kern.vt.color.11.rgb="#b58900"
kern.vt.color.12.rgb="#268bd2"
kern.vt.color.13.rgb="#d33682"
kern.vt.color.14.rgb="#2aa198"
kern.vt.color.15.rgb="#6c71c4"

# GELI THREADS
kern.geom.eli.threads=4

#geom_journal_load="YES"
```

/etc/rc.local


```
#!/bin/sh
usbconfig -d ugen0.1 power_save
usbconfig -d ugen0.2 power_off
usbconfig -d ugen0.3 power_off
usbconfig -d ugen0.4 power_off
usbconfig -d ugen0.5 power_off
usbconfig -d ugen0.6 power_save

apm -e enable
apm -d enable
apm -h enable

sysctl dev.acpi_ibm.0.fan=0
sysctl dev.acpi_ibm.0.fan_level=0
```



```
sysctl -a | fgrep -i cx_usage:
dev.cpu.3.cx_usage: 19.17% 13.92% 66.89% last 53us
dev.cpu.2.cx_usage: 20.39% 14.17% 65.43% last 3096us
dev.cpu.1.cx_usage: 19.96% 14.24% 65.79% last 73us
dev.cpu.0.cx_usage: 19.18% 13.64% 67.16% last 349us
```


Thanks
amr


----------



## the3ajm (Apr 24, 2022)

Are you running a desktop environment? You can also list the model of your CPU/GPU to compare the wattage if its consuming power relative to your measurement. The power draw is also depends on what activity the laptop is doing so you also need determine what application is running.


----------



## dr3mro (Apr 24, 2022)

the3ajm said:


> Are you running a desktop environment? You can also list the model of your CPU/GPU to compare the wattage if its consuming power relative to your measurement. The power draw is also depends on what activity the laptop is doing so you also need determine what application is running.


No I am running BSPWM and Thinkpad x250 has only Intel hd 5500 


and I am talking about lite usage


----------

