Announcement

Collapse
No announcement yet.

How to: Enable power management features

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to: Enable power management features

    Because I use only laptops, temperature control is important. I don't like loud fans and hot keyboards. Existing power management utilities work well when laptops are running on batteries, but then disable power management features when laptops are plugged in. Therefore, I now manually configure all power management settings. I haven't noticed any performance impacts.

    I suspect this post will be a continual work-in-progress, because these things seem to change from time to time.


    Kernel boot parameters

    These items are in /etc/default/grub, between the quotes on the line that begins with GRUB_CMDLINE_LINUX_DEFAULT:
    • acpi_osi=Linux ... allows the kernel to support some ACPI features that the BIOS would otherwise disable if the BIOS detects Windows isn't running
    • pcie_aspm=force ... enable PCI Express power management forcibly
    • i915.i915_enable_rc6=1 ... Intel graphics power saving render (remove if you experience random hangs)
    • i915.i915_enable_fbc=1 ... Intel graphics frame buffer compression
    • i915.lvds_downclock=1 ... panel downclocking


    A kernel boot line containing all these would be:
    Code:
    GRUB_CMDLINE_LINUX_DEFAULT="acpi_osi=Linux pcie_aspm=force i915.i915_enable_rc6=1 i915.i915_enable_fbc=1 i915.lvds_downclock=1"
    Note: the i915 parameters are useful only if your computer has Intel graphics.


    Temperature sensors and ThinkFan

    Install the package lm-sensors and then run sudo sensors-detect to query your computer for available sensors. Answer "yes" to all the questions. When the script ends, it will offer to write at least one module -- probably coretemp -- to /etc/modules. Finally, run sudo service module-init-tools start (*buntu 13.04 and earlier) or sudo service kmod start (*buntu 13.10 and later) to activate the module.

    Now what you can do with this is system-dependent. You can run sensors to see the current state of hardware sensors in your computer. If you have a ThinkPad, you might consider installing thinkfan, which enables extended fan control functionality of thinkpad_acpi. Configuring ThinkFan is a multi-step process. Here's what I did.
    • Find and document temperature sensors
      Code:
      sudo -i
      cd /
      find -iname '*temp*input*' >/tmpin
      exit
    • Set up ThinkFan
      • Install it:
        Code:
        sudo apt-get install thinkfan
      • Create the configuration file for the thinkpad_acpi kernel module to enable fan control:
        Code:
        sudo nano /etc/modprobe.d/thinkfan.conf
      • Add the following line to the file, then save and exit the editor:
        Code:
        options thinkpad_acpi fan_control=1
      • Edit the service file for ThinkFan:
        Code:
        sudo nano /etc/default/thinkfan
      • change the START line to enable the service, then save and exit the editor:
        Code:
        START=yes
      • Edit the configuration file for ThinkFan:
        Code:
        sudo nano /etc/thinkfan.conf
        Do the following, then save and exit the editor:
        • Cursor to a blank line above the temperature setting lines that look like "(nn nn nn)"
        • Insert the contents of the file /tmpin
        • Type the word sensor in front of each inserted line, type a space, and remove the leading period
        • Exit the editor and delete /tmpin

      • Run it
        Code:
        sudo /etc/init.d/thinkfan start



    Shell script to enable power managment features

    Essentially, this script automates enabling all the "tunables" that the power configuration utility powertop allows you to. Create the file /etc/init.d/z-powerlevels and add these lines:
    Code:
    #! /bin/sh
    
    echo 0 > /proc/sys/kernel/nmi_watchdog
    echo 1 | tee /sys/devices/system/cpu/sched_*_power_savings > /dev/null
    echo auto | tee /sys/bus/*/devices/*/power/control > /dev/null
    echo min_power | tee /sys/class/scsi_host/host*/link_power_management_policy > /dev/null
    echo 1 > /sys/module/snd_hda_intel/parameters/power_save
    iwconfig wlan0 power on
    Register the script with Upstart:
    Code:
    chmod a+x /etc/init.d/z-powerlevels
    sudo update-rc.d z-powerlevels defaults

    After all of the above, my X1 draws about 11 watts with wireless in use and the screen at 50% brightness. The fan cycles up and down as needed and the keyboard is slightly warm but not hot.
    Last edited by SteveRiley; Dec 26, 2014, 04:47 PM. Reason: Fixed typo

    #2
    Originally posted by SteveRiley View Post
    Register the script with Upstart:
    [CODE]chmod a+x /etc/init.d/z-powersave
    Shouldnt this be z-powerlevels instead of powersave
    Loka samastha sukhino bhavanthu

    Comment


      #3
      Originally posted by r View Post
      Shouldnt this be z-powerlevels instead of powersave
      You're right, my bad. Thanks for noticing. Fixed the typo.

      Comment


        #4
        Nice post, Steve!

        Out of curiosity I decided to try out the script and recommendations.

        Before:
        I had been getting about 40-50 fps with my Intel HD Graphics chip with no performance problems.
        The plasma temperature widget was working fine. The temperature on idle was around 102-104 F. The fan turned on and off as required but is so slient it is very hard to hear even when focusing your attention on it.

        After:
        The fps dropped to 25-30 fps, but no performance problems. Stellarium was noticeably slower, but not unacceptable. Ditto with Minecraft 1.2.3.
        The average CPU idle temp remained the same. Fan behavior the same.

        I un-installed lm-sensors and restored the default grub setting. My fps returned to 40-50 fps. Fan behavior the same.

        I'm guessing that the kernel is controlling the temperature control and installing lm-sensors and that script didn't make any difference.

        While the default configuration is squeezing maximum performance out of my graphic chip, and I haven't seen any problems with my display, your mods may put the chip in a performance region that is safer in the long run. (My Saturn SL2 red lines at 5,000 rpm. I can run it at 4,500 rpms all day long and not see anything quick accelerations accompanied by increased fuel and oil consumption, but in the long run I would, without a doubt, experience shorter engine life.) I'll risk the shorter life for the better performance. If it lasts 3 years I'll be happy.
        Last edited by GreyGeek; Mar 09, 2012, 11:16 AM.
        "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
        – John F. Kennedy, February 26, 1962.

        Comment


          #5
          Thanks, Jerry. If you have the interest, I'm curious to see how your FPS would improve if you removed all the i915 parameters from the kernel boot line in /etc/default/grub but continued to use the script.

          Comment


            #6
            I almost did that when I noticed the loss of fps. But, I checked the i915 kernel mod (modinfo i915) and noted:
            .....
            depends: drm, drm_kms_helper, video, i2c-algo-bit
            intree: Y
            vermagic: 3.2.0-18-generic SMP mod_unload modversions
            parm: modeset: Use kernel modesetting [KMS] (0=DRM_I915_KMS from .config, 1=on, -1=force vga console preference [default]) (int)
            parm: fbpercrtc: int
            parm: panel_ignore_lid:Override lid status (0=autodetect [default], 1=lid open, -1=lid closed) (int)
            parm: powersave: Enable powersavings, fbc, downclocking, etc. (default: true) (int)
            parm: semaphores: Use semaphores for inter-ring sync (default: -1 (use per-chip defaults)) (int)
            parm: i915_enable_rc6: Enable power-saving render C-state 6 (default: -1 (use per-chip default) (int)
            parm: i915_enable_fbc: Enable frame buffer compression for power savings (default: -1 (use per-chip default)) (int)
            parm: lvds_downclock: Use panel (LVDS/eDP) downclocking for power savings (default: false) (int)
            parm: lvds_use_ssc: Use Spread Spectrum Clock with panels [LVDS/eDP] (default: auto from VBT) (int)
            parm: vbt_sdvo_panel_type: Override selection of SDVO panel mode in the VBT (default: auto) (int)
            parm: reset: Attempt GPU resets (default: true) (bool)
            parm: enable_hangcheck: Periodically check GPU activity for detecting hangs. WARNING: Disabling this can cause system wide hangs. (default: true) (bool)
            ...
            so I am going to play with these, too, and see what happens.
            The default for i915_enable_rc6 is -1 (use per-chip default... this is probably the change which reduced performance.)
            Ditto for i915_enable_fbc. With these two toned down the power consumption of the GPU might have dropped, but at lower power speed suffered
            But, a default 50 fps on the Intel HD Graphics chip is not shabby!
            "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
            – John F. Kennedy, February 26, 1962.

            Comment


              #7
              Originally posted by GreyGeek View Post
              ... But, a default 50 fps on the Intel HD Graphics chip is not shabby!
              We have similar laptops from memory so I though Id follow your efforts GG.
              I'm not running the script at all with the following;

              Running synchronized to the vertical refresh. The framerate should be approximately the same as the monitor refresh rate.
              299 frames in 5.0 seconds = 59.739 FPS
              299 frames in 5.0 seconds = 59.696 FPS
              299 frames in 5.0 seconds = 59.698 FPS
              299 frames in 5.0 seconds = 59.716 FPS
              299 frames in 5.0 seconds = 59.693 FPS
              299 frames in 5.0 seconds = 59.713 FPS
              299 frames in 5.0 seconds = 59.694 FPS
              modinfo i915
              depends: drm,drm_kms_helper,video,i2c-algo-bit
              intree: Y
              vermagic: 3.2.0-18-generic SMP mod_unload modversions
              parm: modeset:Use kernel modesetting [KMS] (0=DRM_I915_KMS from .config, 1=on, -1=force vga console preference [default]) (int)
              parm: fbpercrtc:int
              parm: panel_ignore_lid:Override lid status (0=autodetect [default], 1=lid open, -1=lid closed) (int)
              parm: powersave:Enable powersavings, fbc, downclocking, etc. (default: true) (int)
              parm: semaphores:Use semaphores for inter-ring sync (default: -1 (use per-chip defaults)) (int)
              parm: i915_enable_rc6:Enable power-saving render C-state 6 (default: -1 (use per-chip default) (int)
              parm: i915_enable_fbc:Enable frame buffer compression for power savings (default: -1 (use per-chip default)) (int)
              parm: lvds_downclock:Use panel (LVDS/eDP) downclocking for power savings (default: false) (int)
              parm: lvds_use_ssc:Use Spread Spectrum Clock with panels [LVDS/eDP] (default: auto from VBT) (int)
              parm: vbt_sdvo_panel_type:Override selection of SDVO panel mode in the VBT (default: auto) (int)
              parm: reset:Attempt GPU resets (default: true) (bool)
              parm: enable_hangcheck:Periodically check GPU activity for detecting hangs. WARNING: Disabling this can cause system wide hangs. (default: true) (bool)
              Kubuntu 12.04 - Acer Aspire 5750G

              "I don't make a great deal of money, but I'm ok with that 'cause I don't hurt a lot of people in the process either"

              Comment


                #8
                The three i1915 module settings were initially discovered when Phoronix was investigating power regressions several months ago. Of those three, rc6 has been reported to be the most problematic. Indeed, it causes problems with VMware Player on my T520 but not on my X1 -- both of which have the same Intel HD 3000 graphics, so that's a bit of a mystery.

                The script controls different power-saving settings that are unrelated to Intel graphics. I'll annotate each line here.

                echo 0 > /proc/sys/kernel/nmi_watchdog
                NMI watchdog is a kernel debugging tool. I've not noticed it enabled on kernels before Precise. It does consume power, so I've disabled it. I suspect when Precise emerges from beta it will be disabled by default.

                echo 1 | tee /sys/devices/system/cpu/sched_*_power_savings > /dev/null
                This adjusts two CPU scheduling tunables for systems under light loads or that idle for periods of time. Very reasonable for laptops, probably not a good idea for servers.

                echo auto | tee /sys/bus/*/devices/*/power/control > /dev/null
                Enable runtime power management for all system devices that expose a power management mechanism. This applies to USB and PCI devices, mostly.

                echo min_power | tee /sys/class/scsi_host/host*/link_power_management_policy > /dev/null
                Reduce power on the SATA device link.

                echo 1 > /sys/module/snd_hda_intel/parameters/power_save
                Enable audio device power management.

                iwconfig wlan0 power on
                Enable wireless NIC power management.

                Comment


                  #9
                  Originally posted by bra|10n View Post
                  We have similar laptops from memory so I though Id follow your efforts GG.
                  I'm not running the script at all with the following ....
                  glxgears gave the following on my system:
                  302 frames in 5.0 seconds = 60.266 FPS
                  302 frames in 5.0 seconds = 60.269 FPS
                  302 frames in 5.0 seconds = 60.268 FPS
                  302 frames in 5.0 seconds = 60.267 FPS
                  302 frames in 5.0 seconds = 60.266 FPS
                  but it isn't a good indicator of fps, since the fps depends upon the size of the window the gears run in.

                  I also activated the fps in the KDE desktop settings. It gave a constant 57 fps.

                  My frame rate with this Acer's HD Graphics is the fastest frame rate I've every had for any laptop I've owned.
                  "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                  – John F. Kennedy, February 26, 1962.

                  Comment


                    #10
                    Originally posted by GreyGeek View Post
                    I also activated the fps in the KDE desktop settings. It gave a constant 57 fps.
                    I'm guessing you're referring to "Show FPS" in desktop effects, and a "constant" 57 fps is at idle?

                    If so, I seem to have a reverse result: glxgears giving me 59 fps where kde reports a constant 60 fps. Negligible result sure, but why the reverse result of your findings?

                    Originally posted by GreyGeek View Post
                    My frame rate with this Acer's HD Graphics is the fastest frame rate I've every had for any laptop I've owned.
                    I remember when buying this laptop being offered a choice of either onboard intel graphics with a 500Gb drive, or an NVIDIA graphics card with a 250 Gb drive. Go figure!
                    Kubuntu 12.04 - Acer Aspire 5750G

                    "I don't make a great deal of money, but I'm ok with that 'cause I don't hurt a lot of people in the process either"

                    Comment


                      #11
                      Originally posted by GreyGeek View Post
                      glxgears gave the following on my system:

                      but it isn't a good indicator of fps, since the fps depends upon the size of the window the gears run in.

                      I also activated the fps in the KDE desktop settings. It gave a constant 57 fps.

                      My frame rate with this Acer's HD Graphics is the fastest frame rate I've every had for any laptop I've owned.
                      On my HP Pavilion g7:
                      Graphics: Card: Intel Core Processor Integrated Graphics Controller
                      X.Org: 1.11.3 drivers: intel (unloaded: vesa,fbdev) Resolution: 1600x900@60.1hz
                      GLX Renderer: Mesa DRI Intel Ironlake Mobile GLX Version: 2.1 Mesa 8.0.1
                      glxgears reports:
                      paul@tanagra:~$ glxgears
                      Running synchronized to the vertical refresh. The framerate should be
                      approximately the same as the monitor refresh rate.
                      303 frames in 5.0 seconds = 60.536 FPS
                      303 frames in 5.0 seconds = 60.409 FPS
                      303 frames in 5.0 seconds = 60.410 FPS
                      303 frames in 5.0 seconds = 60.407 FPS
                      303 frames in 5.0 seconds = 60.411 FPS
                      Windows no longer obstructs my view.
                      Using Kubuntu Linux since March 23, 2007.
                      "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                      Comment


                        #12
                        I never bothered to read the text above the frame rate readings. When I saw it on your post I re-ran glxgears to see if mine said the same thing. It did. So, I experimented by resizing the glxgears window. Even filling the screen the fps is exactly the same. This behavior is totally diffferent from what I remember, when full screen windows gave only 1/10 the rate of the small default screen.

                        Glxgears is now a good indicator of fps.
                        "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                        – John F. Kennedy, February 26, 1962.

                        Comment


                          #13
                          Hey thanks for the script it has greatly improved my power management! One thing I noticed after a suspend is some of the settings go back to normal of which I can just rerun the script. Just wanted to let you know.

                          Otherwise great script!

                          Comment


                            #14
                            Yes, I have noticed that, too -- runtime power management for PCI devices. I need to track that one down.

                            Also, I'm experimenting with various settings for Thinkfan's temperature steps, trying to even out sudden (and loud) starts/stops. I'll report my findings once I find a config that seems reasonable.

                            Comment


                              #15
                              Found the answer/fix for the after suspend problem. All you need to do is add a file to /etc/pm/sleep.d/ and tell it run your script in /etc/init.d/. Heres the code to do it.

                              Code:
                              #!/bin/bash
                              case "$1" in
                                  thaw|resume)
                                      /etc/init.d/z-powerlevels 2>/dev/null
                                      ;;
                                  *)
                                      ;;
                              esac
                              exit $?
                              Credit goes to http://ubuntuforums.org/showthread.php?t=1484156

                              Comment

                              Working...
                              X