存储控制器及磁盘 电源管理

目录

 

目录

 

目录

 

目录

AHCI 链路电源管理

基本概念

 在linux下的管理接口

策略选择

测试方法

测试数据

Runtime PM

NVME

APST 

用户接口 

查询磁盘支持ASPT的命令

NVME 三种测试场景

APM


 


 


 


AHCI 链路电源管理

基本概念

.AHCI Link Power Management is a technique in which the AHCI SATA controller places the SATA link into an SSD or HDD at very low power mode.

You can use the following settings:

SettingDescribe
ActiveHIPM or DIPM is not allowed. Do not use Link Power Management
HIPMOnly HIPM (Host Initiated Link Power Management) allowed
HIPM + DIPMEnable HIPM and DIPM
DIPMOnly DIPM (Device Initiated Link Power Management) allowed
LowestAllow HIPM, DIPM and DEVSLP (if the storage device supports DEVSLP)

 在linux下的管理接口

several modes for power management of a SATA drive are available.  这里特别关注是针对SATA 盘的。现代笔记本里面很多NVME接口的盘走PCIE,不适应此种电源管理策略。

同时针对SSD盘,HDD机械盘在节能模式下,会被spindown掉,除了导致性能下降严重外,会导致各种问题。

/sys/class/scsi_host/host0$ cat link_power_management_policy 
med_power_with_dipm

  • max_performance: A disk is typically kept awake and running to get the best performance out of it. This is most indicative when thinking about spinning disks, as a spindown leads to inevitable significant latencies for the next access of the drive
  • min_power: This mode prefers power saving over maximum performance. For spinning disks this for example implies spindowns to save power
  • medium_power: A compromise between the aforementioned two.
  • med_power_with_dipm: This mode configures the drive like medium_power does, but with additional Device Initiated Power Management

 med_power_with_dipm this has been merged for kernel 4.15, as part of this change this new policy will be the default on all Intel mobile chipsets. This saves aprox. 1.0 - 1.5 Watts of power on an idle laptop

策略选择

The newest mode med_power_with_dipm proves to be both among the lowest consuming ones for all modes for the tested SSD models and also very consistent in this, whereas other modes are either equal, systematically higher or highly dependent of the scenario at play (for example the min_power mode on the MX500).

最新的模式 med_power_with_dipm 是最能节省功耗的模式。

The performance impact, both in latency and in throughput, was, however, somewhere between measurable and completely negligible, the highest impact could be seen in the throughput of the M550 where the data still implies med_power_with_dipm to be the preferred choice.

采用 med_power_with_dipm 模式 ,对于IO延迟和吞吐量的影响也很小。

Beware that the results in this post are only applicable to SSDs. HDDs might have significantly different performance and power characteristics due to spin-down and spin-up times and other factors. Furthermore, the aforementioned results will likely apply for SSDs in general, but were obviously only tested on certain models. Different models, especially from differend vendors, could have different characteristics.

HDD的由于存在磁盘spindown的情况,spinup会耗时较长,并不适应此种策略。

 

测试方法

  1. Install Fedora 27 (with its 4.13.x release kernel), or boot Fedora 28 with a F27 4.13.x kernel, install powertop, run laptop on battery power, login and run "sudo powertop" in a terminal, let it idle for 5 minutes and note idle power-consumption rate
  2. Install Fedora 28, install powertop, run laptop on battery power, login and run "sudo powertop" in a terminal, let it idle for 5 minutes and note idle powerconsumption rate
  3. Note the screen brightness should be the same for both tests, if your laptop has a brightness sensor, disable automatic brightness adjustments
  4. Fedora 28 idle power-consumption should be lower then Fedora 27's power-consumption, esp. on Haswell and later systems using a SATA disk

上面描述的测试方法和我们用的是一致的,即用powertop测试,测试5分钟。

测试数据

通过下面的数据可以看到,采用 med_power_with_dipm可以节省1-1.5w的能耗

Laptop modelDiskNormal Idle usemed_power_with_dipm usenotes
Dell Latitude E6400TOSHIBA THNSFC1216.0 W14.5 W 
Dell Latitude E6430C400-MTFDDAC256M12.1 W11.0 W 
T-Bao T-Book AirStarsway-N2003.7W2.9 W 
HP EliteBook 8540wSamsung SSD 85018.8 W17.9 W 
Lenovo W530M4-CT128M4SSD211.9 W10.4 W 
Lenovo Thinkpad T530Samsung SSD 8507.7 W6.9 W 
ThinkPad T510WDC WD800BEVS-0810.6 W9.6 W 
Dell Latitude E7450SAMSUNG SSD PM876.4 W5.2 W 
Lenovo Thinkpad T400SanDisk Ultra II13.6 W11.8 W 
Lenovo ThinkPad T450sSamsung SSD 850 EVO 500GB4.5 W3.4 W 
Asus Zenbook UX31ACrucial_CT275MX34.9 W4.4 W 
Lenovo ThinkPad X1 Carbon 2nd genCrucial_CT525MX311 W8 WData corruption when using min_power
Lenovo ThinkPad T520INTEL SSDSC2BW1810.7 W10.1 W 
Lenovo Thinkpad T440sSAMSUNG MZ7TE2567.9 W6.7 W 
Lenovo ThinkPad X220SAMSUNG MZ7TD1288.8 W7.6 W

 

Runtime PM

 

 

NVME

APST 

  不可操作的电源状态主要用于消费者级的SSD,用于改进续航时间。NVME 充分利用PCIE  low power state来完成低功耗的目标。在主要的消费级应用场景中,SSD大多数处于idle状态,因而对于续航,低电力消耗是非常重要的。但是在数据中心,由于从PCIE L1 状态恢复的延时,不能采用这些低功耗态。

  ACTP (active power)表示了过去10秒钟的最大平均电力消耗。如果控制器支持APST (Autonomous Power State transition),则host控制器可以自动地切换电源状态。控制器支持的电源状态示例如下:

 

 可以看出最节能的状态,功耗消耗很小。

用户接口 

apst_max_latency_ns

This patch teaches the driver to program APST so that each successive non-operational state will be entered after an idle time
equal to 100% of the total latency (entry plus exit) associated with that state.  

A sysfs attribute 'apst_max_latency_ns' gives the maximum acceptable latency in ns; non-operational states with total latency greater than this value will not be used.  As a special
case, apst_max_latency_ns=0 will disable APST entirely.

On hardware without APST support, apst_max_latency_ns will not be  exposed in sysfs.

On my laptop, enabling APST seems to save nearly 1W.

 

查询磁盘支持ASPT的命令

# nvme get-feature /dev/nvme0 -f 0x0c -H
get-feature:0xc (Autonomous Power State Transition), Current value:0x000001
        Autonomous Power State Transition Enable (APSTE): Enabled
        Auto PST Entries        .................

...

When APST is enabled the output should contain "Autonomous Power State Transition Enable (APSTE): Enabled" and there should be non-zero entries in the table below indicating the idle time before transitioning into each of the available states.

If APST is enabled but no non-zero states appear in the table, the latencies might be too high for any states to be enabled by default. The output of nvme id-ctrl /dev/nvme[0-9] (as the root user) should show the available non-operational power states of the NVME controller. If the total latency of any state (enlat + xlat) is greater than 25000 (25ms) you must pass a value at least that high as parameter default_ps_max_latency_us for the nvme_core kernel module. This should enable APST and make the table in nvme get-feature (as the root user) show the entries.

如果总的延时大于25ms,必须修改 default_ps_max_latency_us  值大于25ms

 

NVME 三种测试场景

 1) Active idle is representative of a typical desktop, where none of the advanced PCIe link power saving features are enabled and the drive is immediately ready to process new commands.

  PCIE 链路电源管理功能被禁用。nvme盘可以立即响应IO请求

2) Our Desktop Idle number represents what can usually be expected from a desktop system that is configured to enable SATA link power management, PCIe ASPM and NVMe APST, but where the lowest PCIe L1.2 link power states are not available.

   使能SATA 链路电源管理;PCIE 链路状态电源管理;及NVME自动电源状态切换。但是PCIE L1.2 低功耗状态被禁用。

3)The Laptop Idle number represents the maximum power savings possible with all the NVMe and PCIe power management features in use—usually the default for a battery-powered system but rarely achievable on a desktop even after changing BIOS and OS settings. 

   开启所有的电源管理状态。

前两个测试场景的数据如下:根据磁盘的类型,可以看到 功耗减少 几百到上千毫瓦。

APM

 

 

参考资料:

名次解释: https://electrodealpro.com/how-to-add-or-delete-ahci-link-power-management-hipm-dipm-from-power-options-on-windows/

实验power mangement policy 的影响  https://insanity.industries/post/sata-power-consumption/

合入med_power_with_dipm 的patch说明  https://lore.kernel.org/patchwork/patch/830838/

在fedora上面测试配置不同策略的数据 https://fedoraproject.org/wiki/Changes/ImprovedLaptopBatteryLife

TLP 配置参数的讨论   https://archived.forum.manjaro.org/t/ssd-hdd-optimisations-for-performance-and-longevity/79804/2

NVME  power save 技术及各个状态进入 退出时间:https://www.phoronix.com/scan.php?page=news_item&px=NVMe-Power-Savings-APST

win10 NVME的管理策略  https://winaero.com/add-primary-nvme-idle-timeout-to-power-options-in-windows-10/

NVME 电源管理的详细说明: https://nvmexpress.org/resources/nvm-express-technology-features/nvme-technology-power-features/

SK 现代ssd的功耗及状态评测   https://www.anandtech.com/show/16012/the-sk-hynix-gold-p31-ssd-review/7

合入 APST的补丁 https://lore.kernel.org/patchwork/patch/711737/

APST的命令及开启后在某些磁盘上的bug: https://wiki.archlinux.org/title/Solid_state_drive/NVMe

DELL 笔记本 功耗优化 https://wiki.archlinux.org/title/Dell_XPS_15_9560

APST的状态转换图画的不错  https://blog.csdn.net/weixin_39571219/article/details/112525480

APS他详解   https://nvmexpress.org/resources/nvm-express-technology-features/nvme-technology-power-features/

https://www.laptopmag.com/articles/ssds-with-best-laptop-battery-life

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

proware

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值