Aggressive powersaving?

I still wonder what your use case might be.

I just need to save as much power as I can for the most part during general use, i’m gonna be living in a van converted into a motorhome, and every watt counts because I need to use the van’s batteries sparingly and i’ll mostly be operating the laptop plugged into the wall sockets in the van.

I’ve got about 2400wh of safely usable energy storage (some of which will be needed to power other things, namely refrigeration heating and lighting which in the worst case scenario would all probably eat around 50-60w/h), and I need to do what i can to make it last.

enable compression:
sudo nano /etc/modprobe.d/i915.conf
inside it put this line:
options i915 enable_fbc=1
press ctrl+x to save the file, reboot and test power consumption
also check with this command:
sudo dmesg | grep [drm] not enough stolen space
if it returns something

just a thought but what about using a sbc like raspberry for power saving applications and use the laptop only in circumstances when more cpu-power is needed? a raspberry is about 8 Watt in usual cases and spins up to about 12 Watts. You need a additional display that’s where the search would start in this case but i’m pretty sure it’s possible to create a solution where it’s able to run a web-browser, e-mails, office and multimedia (okay video is limited) with a power-draw of 20 Watts or less without problem.

P.S.: it’s also possible to use this raspberry as part of your electronic control system and to replace a lot of other power-consuming devices in this way. that can save a lot of other power-consuming devices.

Under low/idle loads there’s no discernable difference in consumption with this setting on, and the dmesg | grep didn’t return anything.

@olli on setting up a pi with a monitor and keyboard to use instead of a laptop, I considered it, but my laptop seems to be already capable of being as low as ~20w (maybe even as low as 16w with the right configuration), so it doesn’t seem worth it for that, as for using the raspberry as part of my electric control system I simply do not have the know-how for that.

so open again the /etc/modprobe.d/i915.conf and add this:
options i915 enable_fbc=1 enable_dc=2
save the file, reboot and test

Still no discernable difference in consumption, but I get this from dmesg.

Setting dangerous option enable_dc - tainting kernel

And I’m not sure i like the sound of that.

you get the tainting kernel from nvidia too … if it didnt do anything you can remove the enable_dc=2 … and back to nvidia, do you have a setting in bios for disabling nvidia? i assume youre not going to game on it?
also setting the screen brightness to the lowest possible for comfortable viewing could help…
also disabling hardware/modules you dont need, like webcam/card reader/cd-dvd rom etc…

My bios is unfortunately very dry of options, it’s the worst piece of ■■■■ bios i’ve ever had and is making me consider not buying a laptop from msi again; hell, they even removed options in some of the bios updates (i used to have an option to set the FN button from left meta or use right meta for it, and i set it to right meta where I want it to be, but after one of the bios updates this option no longer exists so there’s no changing it back unless I manage to downgrade my bios, this wasn’t the only option removed either, but i just don’t remember the others)

Long story short though, there’s neither an option for disabling the nvidia gpu nor the igpu in the bios :slight_smile: Or i’d probably be using it.

Disabling the nvidia gpu would save me about 3w but it is a massive pain in the ass to do and I still haven’t figured out how to do it without making my PC just randomly start crashing after disabling it.

why do you have these kernel parameters?

pci=noaer cpufreq.default_governor=performance

do you have issues with aer/pcie if you have the noaer set?
and the performance parameter is the opposite of what you want… maybe thats why you have issues with the autocpufreq

I did have some issues with AER yes, i kept getting warnings or error messages about it, it was months ago i don’t remember the specifics, but i think i primarily disabled it just to get rid of the messages and not because of any actual problems i was encounting due to it.

As for setting the cpufreq default to performance, that’s because I used to want my PC performance optimized rather than power optimized, that’s a good catch i’m gonna change that, I doubt it’s actually been causing any problems considering it just sets the default governor (and auto-cpufreq changes the governor without much regard for what the default is) but i will still change it and set it to powersave, seems like a good redundancy.

the aer issues causes problems, lagging, freezing, crashing the system… and the pci=noaer is the worst parameter to address the aer issue, since it doesnt actually fix it, it just disables the reporting of the errors, but they are still there running in backround … so replace the pci=noaer parameter with this one:
pci=nommconf
update grub, reboot and check journal/ksystemlog if you have the aer/pcie errors…

I changed the setting like you suggested and it all still looks green, not seeing any errors for aer or pcie, thanks for letting me know.

lets disable the nvidia with optimus manager
first open this:
kate /etc/sddm.conf
and put a # before the line starting with DisplayCommand and the one starting with DisplayStopCommand:
#DisplayCommand
#DisplayStopCommand
(its possible that you may not have these display lines there)
save the file, install optimus:
pamac build optimus-manager optimus-manager-qt
reboot

then right click on the optimus tray icon/settings/general - check startup
under the optimus section select startup mode to integrated, click ok, reboot again

if you by any chance after installing optimus/rebooting end up stuck at the black screen, enter into tty and uninstall optimus:
pamac remove optimus-manager optimus-manager-qt
reboot

I’ve already done this but optimus manager couldn’t really disable the nvidia gpu, it just prevented it from being used for games, it’s still online.

it doesn’t really help.

What I really need is a way to turn the gpu entirely off, and I have that, but it requires uninstalling the nvidia driver and using acpi_call, however like i mentioned before it makes the PC crash easily, for instance i’ll crash if i use lspci, and when i start certain programs. I should probably dig deeper into that, but I just really don’t like it when it crashes because I must restart the pc by holding down the power button when it does since sysrq won’t even work anymore.

Edit: I have succeeded in fully disabling the nvidia gpu without crashing, it requires a reboot, i’m gonna make a script and share it.

Update to thread:
So far, the best options I have found to reduce power consumptions have been to install & use auto-cpufreq and power off the nvidia dedicated gpu.

I ditched TLP in favor of auto-cpufreq, power-profiles-daemon was (at a glance) worthless in comparison to both of those.

Using the powersave governor over the performance governor saves me about 3w under idle loads (I configured auto-cpufreq to always use powersave).

I also enabled PCI Runtime power management enabled and it seems to be saving me about 1.5w/h

The most critical component of lowering power consumption so far is disabling turbo boost (reduces idle consumption by about 10w!), auto-cpufreq does this automatically whenever turbo boost would not be needed, but re-enables it when it is granting the ideal compromise between power saving and performance for most users (the pc will draw less power under low load essentially)

Another important component for lowering power draw is limiting the igpu frequency, it can be done with this script

igpu_limit:

#!/bin/sh
#Must be run as root/sudo
#Identifier for igpu (should usually be 0)
card=0

#Limiter Status
limiter=$(( $(cat /sys/class/drm/card$card/gt_max_freq_mhz) / $(cat /sys/class/drm/card$card/gt_min_freq_mhz) ))
if [ $limiter != 1 ]; then
    limiter=0
fi


#Main
if [ "$1" == "on" ]; then #Limit igpu frequency to it's minimum
    echo $(cat /sys/class/drm/card$card/gt_min_freq_mhz) > /sys/class/drm/card$card/gt_max_freq_mhz
    echo $(cat /sys/class/drm/card$card/gt_min_freq_mhz) > /sys/class/drm/card$card/gt_boost_freq_mhz
elif [ "$1" == "off" ]; then #Restore max igpu frequency to default
    echo $(cat  /sys/class/drm/card$card/gt_RP0_freq_mhz) > /sys/class/drm/card$card/gt_max_freq_mhz
    echo $(cat  /sys/class/drm/card$card/gt_RP0_freq_mhz) > /sys/class/drm/card$card/gt_boost_freq_mhz
elif [ "$1" == "boot" ]; then #Limit igpu frequency to it's minimum on boot
    echo w /sys/class/drm/card$card/gt_max_freq_mhz - - - - $(cat /sys/class/drm/card$card/gt_min_freq_mhz) > /etc/tmpfiles.d/igpu_powersave.conf
    echo w /sys/class/drm/card$card/gt_boost_freq_mhz - - - - $(cat /sys/class/drm/card$card/gt_min_freq_mhz) >> /etc/tmpfiles.d/igpu_powersave.conf
elif [ "$1" == "boot-off" ]; then #Don't limit igpu frequency to it's minimum on boot
    rm /etc/tmpfiles.d/igpu_powersave.conf
elif [ "$1" == "toggle" ]; then #Toggle limiter on and off
    DISPLAY=":$(ls /tmp/.X11-unix/* | sed 's#/tmp/.X11-unix/X##' | head -n 1)"
    username=$(who | grep '('$DISPLAY')' | awk '{print $1}' | head -n 1)
    user_id=$(id -u $username)
    case $limiter in
        1)
            echo $(cat  /sys/class/drm/card$card/gt_RP0_freq_mhz) > /sys/class/drm/card$card/gt_max_freq_mhz
            echo $(cat  /sys/class/drm/card$card/gt_RP0_freq_mhz) > /sys/class/drm/card$card/gt_boost_freq_mhz
        ;;
        0)
            echo $(cat /sys/class/drm/card$card/gt_min_freq_mhz) > /sys/class/drm/card$card/gt_max_freq_mhz
            echo $(cat /sys/class/drm/card$card/gt_min_freq_mhz) > /sys/class/drm/card$card/gt_boost_freq_mhz
        ;;
        *)
            echo "Error! Something went wrong!"
            exit
        ;;
    esac
    sudo -u $username DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$user_id/bus notify-send "iGPU Max Frequency: $(cat /sys/class/drm/card$card/gt_max_freq_mhz)mHz"
else
    echo "Usage: igpu_limit [arg]
    on - Limits igpu frequency to minimum
    off - Resets limit on igpu frequency
    boot - Limits igpu frequency to minimum on boot
    boot-off - Disable limiting igpu frequency on boot
    toggle - Toggle limit on and off"
fi

disabling the nvidia dgpu is a solid 3w power saving, however when it is on it may occasionally jump up to 8w even when it should not be in use. so overall it should help quite a bit.

Here is the script to power down the nvidia gpu

nvidia_toggle:

#!/bin/sh
#The nvidia gpu can only be toggled on and off between reboots, i have not found a way to disable it without a reboot that doesn't cause the system to crash (may be possible on muxed laptops), and I have not found a way to re-enable it without a reboot because I can't find a way to make the nvidia drivers detect the gpu.

#The bus is autodetected, should be fine on most laptos but no idea how it'd behave on a desktop
bus=$(lspci | grep -m1 NVID | cut -d '.' -f1 | sed 's/:/\\\\:/g')
#Sanity check to see if the gpu is currently enabled requires the bus value given in a slightly different format
busalt=$(lspci | grep -m1 NVID | cut -d '.' -f1)
#This acpi id is the most common one for nvidia dgpus on laptops, but some laptops might have a different id, if the script doesn't work for you this is most likely the problem.
#You should be able to use this script to find the correct method for your laptop: https://github.com/mkottman/acpi_call/blob/master/examples/turn_off_gpu.sh
acpi_id=SB.PCI0.PEG0.PEGP

#Check and report the current status of the dgpu
if [ -d /sys/bus/pci/devices/0000:$busalt.0 ]; then
    gpu="On"
else
    gpu="Off"
fi
if [ -f /etc/tmpfiles.d/nvidia_off.conf ]; then
    gpuboot="Off"
else
    gpuboot="On"
fi

echo "
Nvidia GPU current status: $gpu
Nvidia GPU status on next boot: $gpuboot
"

if [ "$1" == "off" ] && [ -d /sys/bus/pci/devices/0000:$busalt.0 ]; then #Disable nvidia gpu (confirm it is running before the command is executed to prevent errors, as it must be running for automatic detection of bus ID)
    #The command below which disables the nvidia driver on boot, it may not be necessary, however there's no reason to leave them running in the background doing nothing, therefore I kept the command in.
    echo "$(lsmod | grep nvidia | cut -d ' ' -f1 | sed 's/^/blacklist /')" | sudo tee /etc/modprobe.d/nvidia-off.conf
    sudo sh -c "echo w /sys/bus/pci/devices/0000\\\\:$bus.*/remove - - - - 1 > /etc/tmpfiles.d/nvidia_off.conf"
    sudo sh -c "echo w /proc/acpi/call - - - - \\\\\\\\_$acpi_id._OFF >> /etc/tmpfiles.d/nvidia_off.conf"
    sudo systemctl enable root-resume
    #Make sure this is the only Xorg config file that references the nvidia gpu! Uf there are any others left in Xorg likely will not launch properly.
    sudo rm /etc/X11/xorg.conf.d/10-intel-nvidia-drm-outputclass.conf
    echo "The nvidia GPU will be disabled upon reboot
    "
elif [ "$1" == "on" ]; then #Re-enable nvidia gpu
    sudo rm /etc/modprobe.d/nvidia-off.conf
    sudo systemctl disable root-resume
    sudo systemctl stop root-resume
    sudo rm /etc/tmpfiles.d/nvidia_off.conf
    #Add a xorg config file that references the nvidia gpu back in, otherwise Xorg may not launch properly.
    sudo cp /usr/share/X11/xorg.conf.d/10-intel-nvidia-drm-outputclass.conf /etc/X11/xorg.conf.d/
    echo "The Nvidia GPU will be enabled upon reboot
    "
    #the two commands below (must be run in order) will re-enable the nvidia gpu immediately, however I haven't found a way to get the nvidia driver to detect it again afterwards which is why they're commented out.
    #sudo sh -c "echo \\\\_$acpi_id._ON > /proc/acpi/call"
    #sudo sh -c "echo 1 > /sys/bus/pci/rescan"
else
    echo "Usage: nvidia_toggle [arg]
    on - Enables nvidia GPU (requires reboot)
    off - Disable nvidia GPU (requires reboot)
    "
fi

Here is /etc/systemd/system/root-resume.service (required to keep gpu disabled after suspend)

[Unit]
Description=Local system resume actions
After=suspend.target

[Service]
Type=simple
ExecStart=/usr/bin/sh -c "echo 1 > /sys/bus/pci/devices/0000:01:00.*/remove; echo '\\_SB.PCI0.PEG0.PEGP._OFF' >     /proc/acpi/call"

[Install]
WantedBy=suspend.target

Lastly, for truly extreme powersaving, the cpu frequency can be limited to it’s minimum

limit_cpufreq:

#!/bin/sh
#Limit cpu frequency to 800mhz with auto-cpufreq

limit=800000

if [ "$1" == "on" ]; then #Limit cpu frequency to it's minimum
    sudo cpufreqctl.auto-cpufreq --frequency-max --set=$limit
    echo "CPU Frequency limited to $(( $limit / 1000 ))mHz"
elif [ "$1" == "off" ]; then #Unlimit cpu frequency (restore max freq to default)
    sudo systemctl restart auto-cpufreq
    echo "CPU Frequency limit reset"
elif [ "$1" == "toggle" ]; then #Unlimit cpu frequency (restore max freq to default)
    if [ "$(cpufreqctl.auto-cpufreq --frequency-max)" == "$limit" ]; then
        sudo systemctl restart auto-cpufreq
        echo "CPU Frequency limit reset"
    else
        sudo cpufreqctl.auto-cpufreq --frequency-max --set=$limit
        echo "CPU Frequency limited to $(( $limit / 1000 ))mHz"
    fi
else
    echo "Usage: cpu_limit [arg]
    on - Limits cpu frequency to minimum
    off - Resets limit on cpu frequency
    toggle - Toggles limit on or off"
fi

With every setting applied, my power draw is 18.5w under idle loads, and can go up to about 32w under load

With no powersaving settings applied my power draw was around 50w on idle loads with up to ~160w under full load.

With all changes except the cpu frequency limiter applied, it uses 18.5-80w (I think with the igpu frequency not limited to it’s minimum this goes up a further 10-20w. didn’t properly test it)

A potential alternative to limiting the cpu frequency for greater powersaving that has been suggested is limiting the CPU cores (more testing required to determine which is better)

For reference, under windows with it’s power manager settings set to maximum power saving options and with the laptop manufacturer’s ‘eco mode’ engaged, I’ve seen idle load power draw go as low as 16w, however in general it will use aroun 25w with the occasional spike up to 45w under idle loads, so with these settings my linux installation has finally well and truly surpassed the best powersaving options windows seems to have on offer for my laptop.

Although even with all the settings on it seems windows is still more efficient with certain tasks (for instance in the OP i mentioned the difference in consumption browsing youtube on windows vs linux, with the new settings the consumption on linux doing that is 25-28w (instead of just more or less around 28w, so it’s improved a little bit at least) but that’s still 3-4w higher than what it is on windows; I suspect this might have something to do with the soundcard, i’ve done what I can to improve powersaving on it on linux but it seems that intel hd audio soundcards are very poorly supported on linux in general (more like they’re a nightmare on linux))

nice job…
and what number outputs this command:
cat /sys/class/drm/card0/power/rc6_enable

edit: why do you use this parameter:
pcie_port_pm=off - doesnt this one disables power management on pcie ports?
do you use virtual machines?

$ cat /sys/class/drm/card0/power/rc6_enable
1

Hmm I honestly forgot why i set pcie_port_pm=off, but it might have had something to do with when i was messing with vga passthrough, I’ve dabbled with VMs, you could say i was on the cusp of success of setting up the ideal VM for me; but i’ve been procrastinating finishing that job for like a good month or two now.

It may have been required for vfio or something like that, i’m not entirely sure.

I got it from this gist I’m pretty sure [GUIDE] Optimus laptop dGPU passthrough · GitHub

It’s outdated and iprobably don’t need that param anymore, gonna disable it.

so edit again the /etc/modprobe.d/i915.conf
and add this one:
options i915 enable_dc=1
i remove the enable_fbc=1 parameter, since you have it set in grub
save the file, reboot and test

if you no longer use virtual machine you can remove also all the others parameters from grub related to it…

did you checked ananicy-cpp/ ananicy

No discernable difference after fixing that pcie power management setting, nor after enabling dc, power draw remains the same.

Never looked into ananicy no. It seems great, i’m gonna try ananicy-cpp