OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • Development and Code Review (Moderator: fabian) »
  • Support SATA Link Power Management - savings of ~1 watt
« previous next »
  • Print
Pages: [1]

Author Topic: Support SATA Link Power Management - savings of ~1 watt  (Read 2157 times)

Werner Fischer

  • Jr. Member
  • **
  • Posts: 66
  • Karma: 14
  • Working at Thomas-Krenn, doing lot of Open Source
    • View Profile
    • Thomas-Krenn-Wiki
Support SATA Link Power Management - savings of ~1 watt
« on: June 22, 2023, 11:18:08 am »
I happened to notice that FreeBSD has SATA Link Power Management disabled by default.

This is also the case with the Linux vanilla Kernel so far. However, numerous Linux distributions (e.g. Ubuntu as of Linux kernel 5.15) enable this for mobile/embedded chipsets using "SATA_LPM_POLICY=3".

For the upstream Linux kernel "SATA_LPM_POLICY=3" was also already under discussion: https://www.spinics.net/lists/linux-ide/msg62918.html Due to a hot-plug problem with AMD-based systems (there the SATA controller is identical for EPYC and Ryzen - thus it can't be determined via the PCIe IDs of the SATA controller whether it is a mobile/embedded chipset) this has not been implemented yet.

What are the advantages of enabled SATA Link Power Management?

  • Reduced power consumption (approx. 1-1.8 watts for a system with one SATA SSD.)
  • Lower waste heat, cooler SSD controller chips (e.g. 30 °C lower temperature of the SSD controller for an ATP AF120GSTIC-T22). Especially in summer this can be very advantageous for small fanless firewall systems, if such systems are located in unair-conditioned rooms and possibly the sun shines on the device.

What are the disadvantages of enabled SATA Link Power Management?
  • Possible problems with hot-plug. This is not relevant for smaller/embedded firewalls with a M.2 SATA SSDs. Likewise, it does not affect rack systems that boot from M.2 SATA. The hot-plug limitation really only affects rack systems with hot-swap drive bays that have two SATA SSDs in a ZFS mirror.
  • Slightly increased SATA I/O latency. When the link is in "Partial" power saving state, this is max. 10 microseconds. In the "Slumber" power saving state, this is 10ms max (but this is only activated if no I/O happens for a long time). See SATA AHCI Spec https://www.intel.com/content/www/us/en/io/serial-ata/serial-ata-ahci-spec-rev1-3-1.html chapter 8.2 Power State Mappings (Partial - Phy logic is powered, but in a reduced state. Exit latency is no longer than 10µs / Slumber - Phy logic is powered, but in a reduced state. Exit latency can be up to 10ms)

Under FreeBSD there are several SATA link power management options available - see https://man.freebsd.org/cgi/man.cgi?ahci(4)
  • 0 -> Off (default)
  • 1 -> Device Initiated Power Management (DIPM)
  • 2 to 5 -> different options for Host Initiated Power Management (HIPM)

However, a combination of DIPM+HIPM would be ideal. This would achieve the highest energy savings. Linux has offered this since kernel 4.15 - see https://hansdegoede.livejournal.com/18412.html and https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f4ac6476945ff62939420bcf8266e39f8d5d54bd. This emulates the functionality of the Intel RST driver from Windows, which is explained in detail in this PDF: https://www-ssl.intel.com/content/dam/doc/reference-guide/sata-devices-implementation-recommendations.pdf. In the mid and long term, it would be ideal to implement this functionality (combination of DIPM+HIPM) in FreeBSD as well. However, this is beyond my qualifications. For now, it would already bring a lot to support DIPM.

Currently it is possible to enable DIPM for a SSD via Tuneable: hint.ahcich.0.pm_level = 1 (Attention: a system can have multiple SATA ports - if in doubt set the value for all of them). I have documented all details about this: https://www.thomas-krenn.com/en/wiki/Activate_SATA_Link_Power_Management_in_OPNsense

My questions to you in the OPNsense development:
  • (for OPNsense 23.7): Currently OPNsense shows at tuneables hint.ahcich.0.pm_level, hint.ahcich.1.pm_level, hint.ahcich.2.pm_level, ... as "Type" the info "unsupported" in red. Could you change this to "boot-time" (in black)? Background: the red display of "unsupported" could discourage users to use this function.
  • (later after OPNsense 23.7 release): Option in web interface to enable SATA link power management. Would probably also be solvable via plugin. So far I haven't developed a plugin, but I could imagine it.
  • (for discussion in the medium term): Enable DIPM by default for mobile/embedded SATA chipsets. However, since there is the limitation with hot-plug, this would have to be well-considered. However, the advantage would be that thousands (or tens/hundreds of thousands - I don't know how many OPNsense systems with SATA are in use worldwide) would then potentially need 1 watt less energy each. Globally, this would result in a relevant CO2 saving. OPNsense could call itself "Green IT deleoped Software" or something like that or just emphasize that energy optimization (in this case practically without costs on network performance) is an important point.

What do you think?
Best regards, Werner
Logged

Werner Fischer

  • Jr. Member
  • **
  • Posts: 66
  • Karma: 14
  • Working at Thomas-Krenn, doing lot of Open Source
    • View Profile
    • Thomas-Krenn-Wiki
Re: Support SATA Link Power Management - savings of ~1 watt
« Reply #1 on: July 18, 2023, 08:20:16 am »
Franco has changed "unsupported" to "environment"
https://github.com/opnsense/core/commit/b1e270957c800

Thank you for this Franco :)
Logged

thatso

  • Newbie
  • *
  • Posts: 15
  • Karma: 1
    • View Profile
Re: Support SATA Link Power Management - savings of ~1 watt
« Reply #2 on: August 19, 2023, 01:56:00 am »
Sorry to ask: is this option already implemented?
I'm on OPNsense 23.7.1_3-amd64 and don't see it in tunables. The linked TK wiki article reads as if it was introduced in 23.1.9. What gives?
Logged

thatso

  • Newbie
  • *
  • Posts: 15
  • Karma: 1
    • View Profile
Re: Support SATA Link Power Management - savings of ~1 watt
« Reply #3 on: September 15, 2023, 06:28:00 pm »
Any updates on this?
Logged

Patrick M. Hausen

  • Hero Member
  • *****
  • Posts: 4048
  • Karma: 353
    • View Profile
Re: Support SATA Link Power Management - savings of ~1 watt
« Reply #4 on: September 15, 2023, 08:26:05 pm »
Just add the tunable if you so desire, it does not need to be predefined by OPNsense. There's a small (+) in the UI.
Logged
Protectli FW4B
Intel J3160 4 cores
4x Intel I211 1 Gbit/s
8 GB memory
64 GB mSATA SSD storage
Coreboot
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

thatso

  • Newbie
  • *
  • Posts: 15
  • Karma: 1
    • View Profile
Re: Support SATA Link Power Management - savings of ~1 watt
« Reply #5 on: September 16, 2023, 12:16:23 am »
Thanks, I know that tunables can be added manually. However, https://www.thomas-krenn.com/en/wiki/Activate_SATA_Link_Power_Management_in_OPNsense reads as if this entry should be available as predefined. I was hoping @Werner Fischer could clarify this.
Logged

Patrick M. Hausen

  • Hero Member
  • *****
  • Posts: 4048
  • Karma: 353
    • View Profile
Re: Support SATA Link Power Management - savings of ~1 watt
« Reply #6 on: September 16, 2023, 08:13:00 am »
"A new tunable can be set" == you create a new tunable.
Logged
Protectli FW4B
Intel J3160 4 cores
4x Intel I211 1 Gbit/s
8 GB memory
64 GB mSATA SSD storage
Coreboot
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

thatso

  • Newbie
  • *
  • Posts: 15
  • Karma: 1
    • View Profile
Re: Support SATA Link Power Management - savings of ~1 watt
« Reply #7 on: September 18, 2023, 03:41:42 pm »
Quote from: Patrick M. Hausen on September 16, 2023, 08:13:00 am
"A new tunable can be set" == you create a new tunable.

I see. That's one way to read it. As said, I had the impression it should be predefined. ;)
Thanks for clarification.
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • English Forums »
  • Development and Code Review (Moderator: fabian) »
  • Support SATA Link Power Management - savings of ~1 watt
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2023 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2