Results 1 to 7 of 7

Thread: Power management with udev rule "med_power_with_dipm"

  1. #1

    Default Power management with udev rule "med_power_with_dipm"

    Hi,

    recently I noticed that the kernel from 4.15 on comes with a new power saving feature, see e.g. here: https://www.phoronix.com/scan.php?pa...5-libata-power or search for "med_power_with_dipm". Seems to work with Haswell and newer CPUs.

    So I googled and found the idea that you can add a new udev-rule. I created under /etc/udev/rules.d/ the file 50-hd_power_save.rules with one line:

    Code:
    ACTION=="add", SUBSYSTEM=="scsi_host", KERNEL=="host*", ATTR{link_power_management_policy}="med_power_with_dipm"
    Now, `cat /sys/class/scsi_host/host*/link_power_management_policy`produces:
    Code:
    med_power_with_dipm
    med_power_with_dipm
    med_power_with_dipm
    Drawback: Right now the notebook is connected to the grid. There is no need to save power, I'd prefer to have max_power.

    So can somebody provide the code to make the power-management policy dependend on the state of the notebook: connected to grid or not?

    Notebook runs on kernel 4.16.2.

  2. #2
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    12,136
    Blog Entries
    2

    Default Re: Power management with udev rule "med_power_with_dipm"

    If you read the patch documentation, it only creates the new policy and sets it as the default.
    Choosing <which> policy to use as an alternative to the new default is left for something else to do,
    And I can only assume that would mean when your system is under load, it will automatically switch to the original Max policy and later return to the Med policy when load has been removed.

    So,
    I'd guess that is what you should test...
    What happens if you put your system (particularly the drive sub-system) under extreme load, and then take your sensor readings (in particular wattage draw). Unfortunately, the patch author doesn't describe exactly how he set up his sensor readings or used an external device to measure power draw, so you may have to figure this out on your own.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  3. #3

    Default Re: Power management with udev rule "med_power_with_dipm"

    Quote Originally Posted by tsu2 View Post
    If you read the patch documentation, it only creates the new policy and sets it as the default.
    Choosing <which> policy to use as an alternative to the new default is left for something else to do,
    And I can only assume that would mean when your system is under load, it will automatically switch to the original Max policy and later return to the Med policy when load has been removed.

    So,
    I'd guess that is what you should test...
    What happens if you put your system (particularly the drive sub-system) under extreme load, and then take your sensor readings (in particular wattage draw). Unfortunately, the patch author doesn't describe exactly how he set up his sensor readings or used an external device to measure power draw, so you may have to figure this out on your own.

    TSU
    Thank you for reading the docu of those patch for me! I'll test this the other day when compiling something.

  4. #4

    Default Re: Power management with udev rule "med_power_with_dipm"

    Patch is indeed working. On my Haswell (i5-4260u) I've got -1W in slight load (youtube video).
    But what it does? Something with SATA controller powerstates, right?

  5. #5
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    12,136
    Blog Entries
    2

    Default Re: Power management with udev rule "med_power_with_dipm"

    Quote Originally Posted by nicomunet123 View Post
    Patch is indeed working. On my Haswell (i5-4260u) I've got -1W in slight load (youtube video).
    But what it does? Something with SATA controller powerstates, right?
    Yes,
    Unless I'm misreading, that's what the code does.
    Since the two biggest draws on power are the display and the disk subsystem, the potential benefit can be very significant.
    Would be interesting if the patch indirectly affects CPU stepping, but I don't see anything that would do so.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  6. #6
    Join Date
    Sep 2012
    Posts
    5,501

    Default Re: Power management with udev rule "med_power_with_dipm"

    Quote Originally Posted by cookie170 View Post
    So can somebody provide the code to make the power-management policy dependend on the state of the notebook: connected to grid or not
    You could use laptop-mode-tools that already supports managing SATA power policy, just need to configure it with suitable policy. Or use acpid to handle AC plugged/unplugged event directly.

    Quote Originally Posted by tsu2 View Post
    And I can only assume that would mean when your system is under load, it will automatically switch to the original Max policy
    Your assumption is wrong.

  7. #7
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    12,136
    Blog Entries
    2

    Default Re: Power management with udev rule "med_power_with_dipm"

    To try to provide a more accurate answer,
    I skimmed a few articles, and settled on the following ArchWiki articles as best to provide some guidance...
    The main recommended "Power Management" article
    https://wiki.archlinux.org/index.php/Power_management
    The Laptop Tools Archwiki which was mostly to understand limitations but also how to enable/set frequency scaling
    https://wiki.archlinux.org/index.php/Laptop_Mode_Tools

    I also came to a personal conclusion that acpid won't likely do what you want properly (maybe someone else will have a different opinion)

    The main topic in this thread is described a few sections from the end in the first link.
    From it,
    - The benefit is mainly for rotating disks (unlikely to benefit SSD)
    - Management of SATA power policy is not automatic.

    Through a combination of both Wikis,
    Laptop Tools describes only completely powering down the disk to save energy, but can result in latencies when powering up and severely shortening the life of the drive. This new option to lower the power draw but not power down the drive completely is potentially the best of all options with power savings without shortening the life of the drive.

    So, the remaining question is how to manage your SATA power policy according to whether you're plugged into external power or not, and the first Wiki link provides a couple suggestions but perhaps the systemd recommendation is best

    Although the first reference on Power Management should be read completely for a full picture managing power states with systemd,

    The section that describes what we have already discussed about creating a "medium" SATA power policy
    https://wiki.archlinux.org/index.php...wer_Management

    An approach for systemd to run a script that manages based on whether plugged into AC or on laptop power (With some suggested scripts for what to activate in each state)
    https://wiki.archlinux.org/index.php...d_an_udev_rule

    Lastly,
    If you're interested in CPU frequency scaling,
    There is a Laptop-Tools section for enabling and managing frequency scaling with link to main article
    https://wiki.archlinux.org/index.php...#CPU_frequency

    HTH,
    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •