Solved How i can find what is draining my battery?

When I installed Freebsd stable on my x240 after log in thought slim the fan started to throttling a lot and the battery runs out very quickly. I followed https://forums.freebsd.org/threads/...or-intel-integrated-graphics-with-xorg.66732/ to configure my video card and this https://wiki.freebsd.org/TuningPowerConsumption but I haven't been successful.
I don't know if there is another way to find the program that is consuming my machine's resources so fast and that's what I want to find out or some solution for this.

Thanks!
 
powermon(8) can be used to roughly see power drain of your system (at least on Intel CPU + GPU chips). It will not show power drain per application but it is a start - you can see if GPU is running amok.
On my system (ThinkPad T430s, i7-3520M, CoreBoot BIOS, drm-fbsd12.0-kmod-4.16.g2020022) cpu frequency (with higher xorg usage in top(1)) can be also used to diagnose bad graphics - "fix" for that is to put system in standby for few seconds (or power cycle machine, not reboot).

My current system (3x Firefox profiles, FreeCAD, many terminals and vims):
Code:
 Package:           Uncore:             x86 Cores:          GPU:
 Current: 5.96W     Current: 2.61W      Current: 2.91W      Current: 0.43W
The same system on battery will draw around 20W, 25W when GPU is bad it is around 25W), currently:
Code:
acpiconf -i0
...
Present rate:           1562 mA (18264 mW)

Also watching YouTube (or offline videos) can be stressful for my system because my GPU doesn't have x265 decoder which YouTube likes to use.

What GPU driver are you using?
Code:
grep Loading /var/log/Xorg.0.log
[    14.186] (II) Loading /usr/local/lib/xorg/modules/extensions/libglx.so
[    14.202] (II) Loading /usr/local/lib/xorg/modules/drivers/modesetting_drv.so
[    14.224] (II) Loading sub module "glamoregl"
[    14.224] (II) Loading /usr/local/lib/xorg/modules/libglamoregl.so
[    14.630] (II) Loading sub module "fb"
[    14.630] (II) Loading /usr/local/lib/xorg/modules/libfb.so
[    14.779] (II) Loading /usr/local/lib/xorg/modules/input/libinput_drv.so

sysctl dev.cpu.0.freq
dev.cpu.0.freq: 1200
 
If you see high load of e.g. the window manager (use top(1)), the root cause often is a buggy ACPI. Then set
sysctl machdep.idle{_available,}
sysctl machdep.idle=spin
echo machdep.idle=spin >>/boot/loader.conf
or /etc/sysctl.conf, or set it to hlt.
USB, network interfaces (WLAN), etc. all need power & you can set these to powersave mode.
 
Yes, top, htop, systat show you the cpu usage.

All hardware components drain energy. E.g. webcam, wifi, bluetooth..
There is a long article on this topic here: vermaden.wordpress.com › tag › battery
After read the blog i made this changes
/boot/loader.conf
Code:
hw.pci.do_power_nodriver=3
compat.linuxkpi.fastboot=1
compat.linuxkpi.semaphores=1
compat.linuxkpi.enable_rc6=7
compat.linuxkpi.enable_dc=2
compat.linuxkpi.enable_fbc=1
/etc/rc.conf
Code:
powerd_enable=YES
powerd_flags="-n adaptive -a hiadaptive -b adaptive -m 800 -M 1600"
/etc/sysctl.conf
Code:
dev.cpu.0.cx_lowest=C1
dev.cpu.1.cx_lowest=C3
dev.cpu.2.cx_lowest=C3
dev.cpu.3.cx_lowest=C3

and the consume fall from ~10w to ~6w according to powermon
now the fan stopped throttling and seems the high consumption also stopped.
I'm gonna see how it behaves and i'll back to mark the issue as solved or continue to see what's going on with this.
Thanks!
 
Congratulations! 60% is a very good result. But if you have a modern CPU capable of Turbo Boost, you need to to set cx_lowest to Cmax, i.e. sysrc economy_cx_lowest=Cmax same for performance_cx_lowest.
I have good experience with sysrc powerd_flags='-a adp -n adp -i 75 -r 95' and
echo kern.sched.affinity=128>>/etc/sysctl.conf
echo hw.pci.do_power_nodriver=\"3\" >>/boot/loader.conf
 
Perfect. I'll add it. I'll tell you how it turned out.
Thanks!

update: using
Code:
powerd_flags='-a adp -n adp -i 75 -r 95'
didn't help it turned to 10w again. So i rollback and now is on 6w again.
 
Back
Top