diff --git a/knowledge base/linux/lower the power consumption.md b/knowledge base/linux/lower the power consumption.md index 8dc1bb1..ae548f9 100644 --- a/knowledge base/linux/lower the power consumption.md +++ b/knowledge base/linux/lower the power consumption.md @@ -1,29 +1,115 @@ # Lower the power consumption 1. [TL;DR](#tldr) -1. [Sources](#sources) +1. [Disable unused services](#disable-unused-services) +1. [Improve battery performance](#improve-battery-performance) +1. [Tune power-related settings](#tune-power-related-settings) +1. [Further readings](#further-readings) ## TL;DR +1. [Disable unused services]. +1. [Tune power-related settings]. +1. \[if using a battery] [Improve battery performance]. +1. Turn off the NMI watchdog hardlockup detector.\ + The NMI watchdog is a debugging feature to catch hardware hangs that cause a kernel panic. On some systems it can + generate a lot of interrupts, causing a noticeable increase in power usage. +1. Bump SATA Active Link Power Management to a higher setting. +1. Increase the virtual memory dirty writeback time to help aggregating disk I/O.\ + This reduces spanned disk writes. + ```sh +# Summarize performance of the last boot. +sudo systemd-analyze + +# Show last boot performance. +# Also shows the process tree. +sudo systemd-analyze critical-chain + +# Check power stats. +sudo powertop + +# Set all tunable options to their `GOOD` setting. +# Calibration is interactive. +sudo powertop --calibrate && sudo powertop --auto-tune + +# Turn off the NMI watchdog hardlockup detector. echo '0' > '/proc/sys/kernel/nmi_watchdog' + +# Bump SATA Active Link Power Management to a higher setting. echo 'med_power_with_dipm' > '/sys/class/scsi_host/host0/link_power_management_policy' -# Increase the virtual memory dirty writeback time to help aggregating disk I/O -# together. This reduces spanned disk writes. +# Increase the virtual memory dirty writeback time to help aggregating disk I/O. # Value is in 1/100s of seconds. Default is 500 (5 seconds). echo 6000 > '/proc/sys/vm/dirty_writeback_centisecs' sudo sysctl vm.dirty_writeback_centisecs=6000 ``` -## Sources +## Disable unused services -- Arch Wiki's [power management][arch wiki power management] page +```sh +$ sudo systemd-analyze +Startup finished in 13.129s (firmware) + 5.413s (loader) + 1.746s (kernel) + 7.903s (userspace) = 28.192s +graphical.target reached after 1.239s in userspace + +$ sudo systemd-analyze critical-chain +The time when unit became active or started is printed after the "@" character. +The time the unit took to start is printed after the "+" character. + +graphical.target @1.239s +└─multi-user.target @1.239s + └─ModemManager.service @1.154s +84ms + └─polkit.service @937ms +215ms + └─basic.target @928ms + └─sockets.target @928ms + └─dbus.socket @928ms + └─sysinit.target @924ms + └─systemd-backlight@backlight:acpi_video0.service @2.273s +8ms + └─system-systemd\x2dbacklight.slice @2.272s + └─system.slice @197ms + └─-.slice @197ms +``` + +## Improve battery performance + +```sh +# Enable automatic power management. +# See `tlpui` on GitHub for UI. +sudo systemctl enable --now 'tlp.service' +sudo vim '/etc/tlp.conf' + +# Check power stats. +sudo 'powertop' +``` + +## Tune power-related settings + +```sh +sudo powertop --calibrate +sudo powertop --auto-tune +``` + +## Further readings + +- [PowerTOP] +- [Laptop Mode Tools: Extend Your Laptop Battery Life] +- [`laptop-mode-tools` article in the Arch Wiki][arch wiki laptop-mode-tools] +- [Power management article in the Arch Wiki][arch wiki power management] + +[Disable unused services]: #disable-unused-services +[Tune power-related settings]: #tune-power-related-settings +[Improve battery performance]: #improve-battery-performance + + +[PowerTOP]: ../powertop.md + -[arch wiki power management]: https://wiki.archlinux.org/title/Power_management +[Laptop Mode Tools: Extend Your Laptop Battery Life]: https://www.unixmen.com/laptop-mode-tools-extend-laptop-battery-life/ +[arch wiki laptop-mode-tools]: https://wiki.archlinux.org/title/Laptop_Mode_Tools +[arch wiki power management]: https://wiki.archlinux.org/title/Power_management diff --git a/knowledge base/linux/optimize battery.md b/knowledge base/linux/optimize battery.md deleted file mode 100644 index 5be9d50..0000000 --- a/knowledge base/linux/optimize battery.md +++ /dev/null @@ -1,71 +0,0 @@ -# Optimize battery - -1. [TL;DR](#tldr) -1. [Disable unused services](#disable-unused-services) -1. [Improve battery performance](#improve-battery-performance) -1. [Further readings](#further-readings) - -## TL;DR - -```sh -# Summarize performance of the last boot. -sudo systemd-analyze - -# Show last boot performance. -# Also shows the process tree. -sudo systemd-analyze critical-chain - -# Check power stats. -sudo 'powertop' -``` - -## Disable unused services - -```sh -$ sudo systemd-analyze -Startup finished in 13.129s (firmware) + 5.413s (loader) + 1.746s (kernel) + 7.903s (userspace) = 28.192s -graphical.target reached after 1.239s in userspace - -$ sudo systemd-analyze critical-chain -The time when unit became active or started is printed after the "@" character. -The time the unit took to start is printed after the "+" character. - -graphical.target @1.239s -└─multi-user.target @1.239s - └─ModemManager.service @1.154s +84ms - └─polkit.service @937ms +215ms - └─basic.target @928ms - └─sockets.target @928ms - └─dbus.socket @928ms - └─sysinit.target @924ms - └─systemd-backlight@backlight:acpi_video0.service @2.273s +8ms - └─system-systemd\x2dbacklight.slice @2.272s - └─system.slice @197ms - └─-.slice @197ms -``` - -## Improve battery performance - -```sh -# Enable automatic power management. -# See `tlpui` on GitHub for UI. -sudo systemctl enable --now 'tlp.service' -sudo vim '/etc/tlp.conf' - -# Check power stats. -sudo 'powertop' -``` - -## Further readings - -- [laptop-mode-tools] -- [laptop-mode-tools in the Arch Wiki] - - - - -[laptop-mode-tools]: https://www.unixmen.com/laptop-mode-tools-extend-laptop-battery-life/ -[laptop-mode-tools in the arch wiki]: https://wiki.archlinux.org/title/Laptop_Mode_Tools diff --git a/knowledge base/powertop.md b/knowledge base/powertop.md new file mode 100644 index 0000000..d01ceb9 --- /dev/null +++ b/knowledge base/powertop.md @@ -0,0 +1,77 @@ +# PowerTOP + +> TODO + +Linux tool used to diagnose issues with power consumption and power management. + +1. [TL;DR](#tldr) +1. [Further readings](#further-readings) + 1. [Sources](#sources) + +## TL;DR + +Has an interactive mode one can use to experiment with various power management settings. + +When running on battery, PowerTOP tracks power consumption and activity on the system.\ +Once there are sufficient measurements, it can start to report power estimates for various activities. + +Calibration entails cycling through various display brightness levels (including "off"), USB device activities, and +other workloads. + +
+ Setup + +```sh +zypper install 'powertop' +``` + +
+ +
+ Usage + +```sh +sudo powertop + +# Set all tunable options to their `GOOD` setting. +sudo powertop --auto-tune + +# Help increasing the accuracy of the consumption measurements estimation. +sudo powertop --calibrate +``` + +
+ + + +## Further readings + +- [Website] +- [Codebase] + +### Sources + +- [Documentation] + + + + + + + +[codebase]: https://github.com/fenrus75/powertop +[documentation]: https://website/docs/ +[website]: http://www.01.org/powertop + +