[HowTo] Power savings setup| 20180403

powersave
tlp
laptop
hardware
maintenance

#1

Take control of the energy consumption in Manjaro

Certain settings need to be done to optimize the power savings. Valid entries in the GRUB configuration file activates higher performance and correct operation of ACPI. Anyone who has a modern Intel processor should install the daemon Thermald. This deamon dynamically manages CPU cooling: cooler, quieter. After installing the kernel 4.9 LTS, users of AMD Radeon GPUs have access to DPM. Quieter, cooler and more efficient. TLP replaces laptop-tools. More control over the configuration of power saving is gained.

Important things

  • Make sure that you have installed 4.14 LTS kernel or lastest stable kernel
  • Since 4.12 kernel you have to create a /etc/udev/rules.d/60-schedulers.rules with setup about I/O schedulers. HowTo is described in this article.
  • Make sure that you have installed for your CPU Microcode
  • Make sure that you have added the appropriate entries in the GRUB configuration file
  • Make sure you have installed all of the updates

Kernel

In default Manjaro ISOs provides lastest stable LTS kernel release. If you have any issues/regressions hardware, you can simply change kernel to previous version. Please check official announcements forum threads to find out.

For install Linux 4.14 LTS in a terminal, run the following command:

sudo mhwd-kernel -i linux414

or install lastest Linux 4.16:

sudo mhwd-kernel -i linux416

CPUs Microcode

AMD CPU’s users should have installed lastest linux-firmware package.
Intel CPU’s users should have installed lastest intel-ucode package.

Adding advanced flags to the GRUB configuration file

This section IS NOT FOR NEWBIES. You need to know what hardware you’ve and set properly setup.
You can check what exactly flags are available for your hardware via command modinfo $MODULE_NAME | grep '^parm:'.

Example modinfo i915 | grep '^parm:' results:
modinfo i915 | grep '^parm:'
parm:           modeset:Use kernel modesetting [KMS] (0=disable, 1=on, -1=force vga console preference [default]) (int)
parm:           panel_ignore_lid:Override lid status (0=autodetect, 1=autodetect disabled [default], -1=force lid closed, -2=force lid open) (int)
parm:           semaphores:Use semaphores for inter-ring sync (default: -1 (use per-chip defaults)) (int)
parm:           enable_rc6:Enable power-saving render C-state 6. Different stages can be selected via bitmask values (0 = disable; 1 = enable rc6; 2 = enable deep rc6; 4 = enable deepest rc6). For example, 3 would enable rc6 and deep rc6, and 7 would enable everything. default: -1 (use per-chip default) (int)
parm:           enable_dc:Enable power-saving display C-states. (-1=auto [default]; 0=disable; 1=up to DC5; 2=up to DC6) (int)
parm:           enable_fbc:Enable frame buffer compression for power savings (default: -1 (use per-chip default)) (int)
parm:           lvds_channel_mode:Specify LVDS channel mode (0=probe BIOS [default], 1=single-channel, 2=dual-channel) (int)
parm:           panel_use_ssc:Use Spread Spectrum Clock with panels [LVDS/eDP] (default: auto from VBT) (int)
parm:           vbt_sdvo_panel_type:Override/Ignore selection of SDVO panel mode in the VBT (-2=ignore, -1=auto [default], index in VBT BIOS table) (int)
parm:           reset:Attempt GPU resets (0=disabled, 1=full gpu reset, 2=engine reset [default]) (int)
parm:           vbt_firmware:Load VBT from specified file under /lib/firmware (charp)
parm:           error_capture:Record the GPU state following a hang. This information in /sys/class/drm/card<N>/error is vital for triaging and debugging hangs. (bool)
parm:           enable_hangcheck:Periodically check GPU activity for detecting hangs. WARNING: Disabling this can cause system wide hangs. (default: true) (bool)
parm:           enable_ppgtt:Override PPGTT usage. (-1=auto [default], 0=disabled, 1=aliasing, 2=full, 3=full with extended address space) (int)
parm:           enable_execlists:Override execlists usage. (-1=auto [default], 0=disabled, 1=enabled) (int)
parm:           enable_psr:Enable PSR (0=disabled, 1=enabled - link mode chosen per-platform, 2=force link-standby mode, 3=force link-off mode) Default: -1 (use per-chip default) (int)
parm:           alpha_support:Enable alpha quality driver support for latest hardware. See also CONFIG_DRM_I915_ALPHA_SUPPORT. (bool)
parm:           disable_power_well:Disable display power wells when possible (-1=auto [default], 0=power wells always on, 1=power wells disabled when possible) (int)
parm:           enable_ips:Enable IPS (default: true) (int)
parm:           fastboot:Try to skip unnecessary mode sets at boot time (default: false) (bool)
parm:           prefault_disable:Disable page prefaulting for pread/pwrite/reloc (default:false). For developers only. (bool)
parm:           load_detect_test:Force-enable the VGA load detect code for testing (default:false). For developers only. (bool)
parm:           force_reset_modeset_test:Force a modeset during gpu reset for testing (default:false). For developers only. (bool)
parm:           invert_brightness:Invert backlight brightness (-1 force normal, 0 machine defaults, 1 force inversion), please report PCI device ID, subsystem vendor and subsystem device ID to dri-devel@lists.freedesktop.org, if your machine needs it. It will then be included in an upcoming module version. (int)
parm:           disable_display:Disable display (default: false) (bool)
parm:           enable_cmd_parser:Enable command parsing (true=enabled [default], false=disabled) (bool)
parm:           mmio_debug:Enable the MMIO debug code for the first N failures (default: off). This may negatively affect performance. (int)
parm:           verbose_state_checks:Enable verbose logs (ie. WARN_ON()) in case of unexpected hw state conditions. (bool)
parm:           nuclear_pageflip:Force enable atomic functionality on platforms that don't have full support yet. (bool)
parm:           edp_vswing:Ignore/Override vswing pre-emph table selection from VBT (0=use value from vbt [default], 1=low power swing(200mV),2=default swing(400mV)) (int)
parm:           enable_guc_loading:Enable GuC firmware loading (-1=auto, 0=never [default], 1=if available, 2=required) (int)
parm:           enable_guc_submission:Enable GuC submission (-1=auto, 0=never [default], 1=if available, 2=required) (int)
parm:           guc_log_level:GuC firmware logging level (-1:disabled (default), 0-3:enabled) (int)
parm:           guc_firmware_path:GuC firmware path to use instead of the default one (charp)
parm:           huc_firmware_path:HuC firmware path to use instead of the default one (charp)
parm:           enable_dp_mst:Enable multi-stream transport (MST) for new DisplayPort sinks. (default: true) (bool)
parm:           inject_load_failure:Force an error after a number of failure check points (0:disabled (default), N:force failure at the Nth failure check point) (uint)
parm:           enable_dpcd_backlight:Enable support for DPCD backlight control (default:false) (bool)
parm:           enable_gvt:Enable support for Intel GVT-g graphics virtualization host support(default:false) (bool)


Make backup a default grub file:

sudo cp /etc/default/grub /etc/default/grub.bak

Edit grub file in Your favorite text editor. For this HowTo I used nano.

sudo nano /etc/default/grub

Find line:

GRUB_CMDLINE_LINUX=""

Paste the appropriate flags ‘‘between the quotation marks’’ as described below.

For more information on what these flags do, please read The Arch Wiki.

The story of _OSI(Linux)

From pre-history through Linux-2.6.22, Linux responded TRUE upon a BIOS OSI(Linux) query. Unfortunately, reference BIOS writers got wind of this and put OSI(Linux) in their example code, quickly exposing this string as ill-conceived and opening the door to an un-bounded number of BIOS incompatibilities.
For example, OSI(Linux) was used on resume to re-POST a video card on one system, because Linux at that time could not do a speedy restore in its native driver. But then upon gaining quick native restore capability, Linux has no way to tell the BIOS to skip the time-consuming POST – putting Linux at a permanent performance disadvantage.
On another system, the BIOS writer used OSI(Linux) to infer native OS support for IPMI! On other systems, OSI(Linux) simply got in the way of Linux claiming to be compatible with other operating systems, exposing BIOS issues such as skipped device initialization.

So “Linux” turned out to be a really poor chose of
OSI string, and from Linux-2.6.23 onward we respond FALSE.

BIOS writers should NOT query _OSI(Linux) on future systems.
Linux will complain on the console when it sees it, and return FALSE.
To get Linux to return TRUE for your system will require
a kernel source update to add a DMI entry,
or boot with “acpi_osi=Linux”.

Source

More explain about OSI

GRUB Flags

STANDARD

acpi_osi=Linux acpi=force acpi_enforce_resources=lax

STANDARD - when not working backlight control function keys

acpi_osi=Linux acpi=force acpi_enforce_resources=lax drm.vblankoffdelay=1 acpi_backlight=vendor

ACPI - for the modern models of laptops with UEFI (2011 year production or newer) please adding after acpi_osi=Linux:

acpi_osi='!Windows 2012'

ACPI - for the modern models of laptops with UEFI (2014 year production or newer) please using:

This workaround is dedicated for Intel Skylike Laptops with NVIDIA Optimus freezes issue. See: Bumblebee GH-764:

acpi_osi=! acpi_osi="Windows 2009"

or

acpi_osi=! acpi_osi='Windows 2015'

On some laptops, when Fn keys or display backlight Fn keys does not works at all use blank acpi_osi value:

acpi_osi=

AMD - enable DPM for the graphics cards AMD Radeon. Flag Only for Linux Kernel built-in radeon module driver. (Linux 3.11.x or newer)

radeon.dpm=1

AMD - enable HDMI Audio for the graphics cards AMD Radeon. Flag Only for Linux Kernel built-in radeon module driver. (Linux 3.11.x or newer)

radeon.audio=1

INTEL - Enable Early Kernel Mode Setting for i915 module.

  • Edit /etc/mkinitcpio.conf file and in MODULES section add i915.
# MODULES
# The following modules are loaded before any boot hooks are
# run.  Advanced users may wish to specify all system modules
# in this array.  For instance:
#     MODULES=(piix ide_disk reiserfs)
MODULES=(i915)
  • Regenerate boot images:
sudo mkinitcpio -P
  • Add to GRUB_CMDLINE_LINUX in grub conf file and update grub configuration:
i915.modeset=1

Install X.org framebuffer video driver package:

sudo pacman -S xf86-video-fbdev --noconfirm --needed

Reboot for apply changes.

Disable IPv6 - don’t load required kernel modules for IPv6 working

NOTE: be sure you have disabled IPv6 support for external network apps and services like ufw firewall tool, ntpd Netwok Time Sync Daemon or dhcpd. Otherwise app services will not working properly. You have been warned.

More details and samples are available in this ArchWiki article.

For disable whole IPv6 stack add this setting to grub command line:

ipv6.disable=1

Disabling Consistent Network Device Naming

Simplify this setting restore legacy network interfaces names like ath0 wlan1 and so on.

net.ifnames=0

Don’t print systemd version during boot

rd.udev.log-priority=3

Forcing enable power saving mode for Atheros WLAN devices

In default ath9k module don’t switch to power saving mode under battery power mode.

ath9k.ps_enable=1

Enable ASPM even on devices that claim not to support it (optional):

pcie_aspm=force

WARNING: Forcing ASPM on may cause system lockups.
You can check ASPM status by commands:

sudo lspci -vv | grep ASPM.*abled\;
dmesg |grep ASPM
cat /sys/module/pcie_aspm/parameters/policy

Safe is using default BIOS settings of ASPM.

Disable sub menus in GRUB

To disable sub menus on your end please add the following line:

GRUB_DISABLE_SUBMENU=y

Disable Page Table Isolation to regain performance lost

nopti

Disable Spectre patches to regain performance lost

spectre_v2=off

After applying changes in grub AND REBOOT you can check status of SpectreV2 via command:

dmesg|grep "Spectre"
dmesg|grep "isolation"

Reference: https://access.redhat.com/articles/3311301

Save changes to a file. Execute the command in a terminal:

 sudo update-grub

Installing additionals for TLP

TLP is installed, customized and enabled in Manjaro ISOs. You can install additional recommended tools for boost/extend power saving.

In a terminal, run the following command:

sudo pacman -S --needed tlp tlp-rdw iw smartmontools ethtool x86_energy_perf_policy

Disable RFKILL services:

sudo systemctl mask systemd-rfkill.socket systemd-rfkill.service

Reboot.

Check current settings of TLP via

sudo tlp-stat

WARNING:
After made changes in /etc/default/tlp file restart systemd tlp service sudo systemctl restart tlp

Installing Linux Thermal Daemon

NOTE: thermald working only with Intel CPUs with P-State govenor

Before install thermald please install and configure propertly lm_sensors by command sudo pacman -S lm_sensors && sudo sensors-detect

Install, enable and run thermald daemon by following command:

sudo pacman -S thermald --noconfirm --needed

Manually enable and launch thermald systemd service:

sudo systemctl enable thermald && \
sudo systemctl start thermald

REQUIRED FOR 4.12 and NEWER. Dynamically changing the scheduler I/O disks.

Manjaro using in default mq-deadline. For customize I/O scheduler since 4.12 kernel YOU HAVE TO create a 60-schedulers.rules UDEV rule file. They are available new optionals schedulers. Full List: mq-deadline ; kyber ; bfq ; bfq-mq ; none (formally blk-mq)

Higher read/write performance for the solid state drives (SSD) have scheduler blk-mq. You can automate the process of change scheduler disk I/O, depending on whether the disk is rotating (HDD) or not (SSD). This is recommended way in environment SSD + HDD or just HDD drives.

Create a new file:

sudo nano /etc/udev/rules.d/60-schedulers.rules

Paste this code into it:

# /etc/udev/rules.d/60-scheduler.rules
#
# set blk-mq scheduler for non-rotating disks
# WARNING:  blk-mq scheduler REQUIRED scsi_mod.use_blk_mq=1 boot flag
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="none"

# set bfq-mq scheduler for rotating disks
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="bfq-mq"

Alternative I/O scheduler for SSD drives. Recommended for ONE SSD drive environment

A more contemporary option (since kernel version 3.16) is Multi-Queue Block IO Queuing Mechanism or blk-mq for short. Blk-mq leverages a CPU with multiple cores to map I/O queries to multiple queues. The tasks are distributed across multiple threads and therefore to multiple CPU cores (per-core software queues) and can speed up read/write operations vs. traditional I/O schedulers. ArchWiki

Enable blk-mq via grub CMD flag:

scsi_mod.use_blk_mq=1

to /etc/default/grub in GRUB_CMDLINE_LINUX line.
Update grub.

sudo update-grub

Restart the computer.

You can check current using scheduler for all connected disks by command:

 cat /sys/block/sd*/queue/scheduler

WARNING: If blk-mq is active, then command cat /sys/block/sd*/queue/scheduler will return none results. It is correct.

Summary

Default power settings (based on ‘‘laptop-tools’’ give high CPU temperature (52-56 °C idle and 65-70 °C under high usage). After applying the appropriate entries in the GRUB configuration file after installing the TLP and Linux Thermal Daemon (thermald), I got a low power consumption of battery time (around 9 W), low CPU temperature (40-48 °C idle and 56 °C under high usage) and higher performance at work on AC power.

I encourage you to read the documentation TLP. You can customize the service to suit your needs. This topic contains the basic configuration to work properly.

See Also


Power savings for laptops
Fstab okay for SSD?
Checking "blk-mq" is active
Laptop overheats and crashes on high power
Laptop doesn't wake from suspend - Frozen black screen
Fan control
Fstab okay for SSD?
Maximise/ optimise battery life
10 things to do for Manjaro 64 bit xfce?
Issues with backlight on a Samsung Laptop
Battery life worse than windows
[Unstable Update] 2017-09-22 - Nvidia 384.90, Nvidia 340.104, Nvidia 304.137, Haskell, Python
Optimizing Linux for Slow Computers | AkitaOnRails.com
Kernel module for laptop to incress battery life
The operating time from the battery (Gnome 3)
[SOLVED] ACPI Issues when running with lid closed - Cannot shutdown or reboot
Manjaro v17.1-rc4 feedback thread
KDE Plasma problems: Volume control, Brightness adjustment, Data traffic, LtoR layout [Solved]
Keyboard Issues on Opening Laptop after Suspend to RAM
Brightness Fn-keys Manjaro KDE [SOLVED]
[solved] Need help with laptop power management
How fix fonts during boot for intel i915
How fix fonts during boot for intel i915
ACPI error on boot - Nvidia/Intel hybrid BumbleBee
System freeze - wont boot when bumblebee is installed
Elevated System Temperature and loud fan
Reducing RAM use in KDE
[Stable Update] 2018-04-02 - Kernels, ZFS, Pamac, Udisks2
How to install intel graphics
Wifi very slow and brightness don't work
Brightness keyboard control doesn't work
Plasmashell (KDE) - High load over my CPU
Issues on wakeup from suspend
S.M.A.R.T + Trim on SSD
Maximize Battery Usage, How?
Awe-Struck + Problems installing/running Manjaro
Brightness keys not working in Xfce, although I can change brightness elsewhere and keystrokes register
Backlight is not working correctly
Manjaro Cinnamon freezing "randomly" :-(
Battery backup compare windows/linux
Manjaro on old Toshiba?
Problems with Optimus and Prime
Backlight keys not working
New laptop. Loud fan. lm_sensors can't detect fan
[SOLVED] ALT+F4 not working
I/O scheduler
Wi-Fi broken after suspending my Samsung RV509
[Stable Update] 2017-05-19 - Kernels, LibreOffice, Mesa, Thunderbird, Cinnamon
Lenovo Ideapad 510s Fan always on
Switching CPU hyperthreading on or off in Manjaro x64
BFQ is not the default scheduler in kernel 4.12
Ideas for manjaro-architect
Tlp and tlp-sleep
Battery life in laptops running Manjaro
Suspend to ram fix for the lts kernel linux49
#2

Thanks for tutorial @FadeMind could you add how add kernel parameters for Ati and Nvidia, I cant get it from Arch wiki. Please wikified and put to Manjaro wiki that is so important topic.


#3

thanks for the blk-mq scheduler tip … testing now.


#4

@mgundogdu Please read this howto with care. I mention how to ADD and USE flags. If you don’t understand GRUB config file specify, please begin basic setup guide learn.

https://ubuntuforums.org/showthread.php?t=1195275
http://www.dedoimedo.com/computers/grub-2.html

I don’t want spend time for transform MD text code in to WIKI code syntax, too much work to do here.

@cscs


#5

I found out manjaro much more cooler than my previous “bloated” Ubuntu, thanks for all the detailed tutorials!:slight_smile:


#6

I’ve just tried these steps and all looks good except that plymouth doesn’t work, it see it flash up very briefly and then disappears. The image that is where when it does show looks to be duplicated 4 times in each quarter of the screen and quite small.

This what I have:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash threadirqs acpi_osi=Linux acpi_osi='!Windows 2012' acpi=force acpi_enforce_resources=lax drm.vblankoffdelay=1 acpi_backlight=vendor i915.modeset=1 rd.udev.log-priority=3 libahci.ignore_sss=1"

I suspect it is the i915.modeset? Is there any way to fix this? I can live without plymouth but I would prefer to just fix it.

EDIT: nevermind, removing that line did fix it.


#8

It was the mere mention of Windows 2012 that broke things.

That’s my story, and I’m sticking to it.


#9

Errn Guys,

how many of you were successful in configuring this Power Saving stuff?

And how good was the results?

It sounds really awsome but I’m not gonna lie… it looks pretty intimidating


#10

I was able to run through this pretty quick… However, being a long time linux user, I only used half of the information.

Research a little into what each piece of this does, maybe one or two checklist items at a time and see how it goes. This article seems written in a straightforward fashion that should be somewhat simple to reverse.

It also depends on your setup and what you’re trying to accomplish. For me, this article is a good guide to Fn keys and acpi boot information.

Simple answer, if you don’t care about performance and you care about battery life, do everything. If you know which ones hinder performance and need performance, skip the ones that hinder performance.

I come from the debian world, so the idea of having to reimage less often seems nice to me… assuming I don’t break everything in the process of learning.


#11

This guide is not for newbies :wink:
Regards


#12

Edit - this was @amonobeax - sorry.

You can just start with Microcode, TLP and thermald - easy enough … then you can add grub flags that pertain to your system - maybe just 1 at a time (read up on how to edit flags at boot in case you mess it up) … not too scary there.
(heres mine on a newish intel system + SSD)
GRUB_CMDLINE_LINUX="scsi_mod.use_blk_mq=1 acpi_osi=Linux acpi_osi='!Windows 2015' acpi=force acpi_enforce_resources=lax i915.modeset=1 kernel.nmi_watchdog=0 rd.udev.log-priority=3"


#13

The question persists is it worth it?

It concerns me that most of the material I can find about power saving the Author never mention results… which IMO suggests the effect is marginal.

It’d be so much better if authors did something like:
I gave up this and this for % of battery life gain.


#14

I dunno, the benefit of tlp and thermald is 1-2 hours of battery life for me. The other optimizations seem to provide lesser gains. Optimizing desktop for lower cpu usage can have greater impact (if you can go from 2-3% idle to 0-1% idle).


#15

Not so sure that’s the biggest power draw in most machines.
You want long battery run time:

  1. Turn down the screen brightness
  2. Invest in an SSD big enough to hold everything. Move seldom used stuff to some NAS or another Mains powered machine that you keep running with the monitor off.

Since forever, the screen takes more power than any other component.
Modern CPUs ramp the power up and down so efficiently that you don’t have to micro-manage them anymore.


#16

Sure, not the biggest issue. But can make a noticeable difference still, for example 20 minutes gained from using a wm instead gnome. Btw, I counted brightness as a part of the desktop optimization.


#17

I would consider myself a newbie. Followed this tutorial. Was managable. What I did notice on the system monitor is that all 4 cores now seem to be working at the same time which I guess implies a better use of the CPU. However this could also be related to switching from 4.4 to 4.9. 4.4 has never worked great for me on my Skylake laptop. Well I guess even if the improvement is marginal it’s still worth it given the few minutes of implementing these.

BTW Intel Microcode was already installed on mine so I think that step is no longer necessary.


#18

When an article has more power than a nuclear bomb. Thanks for all the time you have invested to write this awesome article. Cheers :beer:


Installing Manjaro power saving
#19

This is a solid tutorial!!

Thank you for making this.

I was just wondering that how are NVMe drives handled with Kernel 4.12?


#20

Section with blk-mq is outdated. According to arch wiki link it now requires two commands to activate.
Does someone knows is the mq schedules are better for HDD/SSD setup?


#21

using scsi_mod.use_blk_mq=1 i get the I/O scheduler mq-deadline which is correct as far as I’m concerned since I’m using an SSD. I replaced the elevator=deadline command so am quite happy with this new mq-deadline being the enabled scheduler.

it’s a new type of scheduler added in later kernels since this tutorial was written up as explained in the arch wiki ‘improvement’ comment

Reason: Linux 4.12 and later introduced new schedulers: [none] mq-deadline kyber bfq (Discuss in Talk:Improving performance#)


Why Upgrade linux49?