[power] Dynamic voltage and frequency scaling(DVFS)简单概述

Many systems operate under conditions where their workload is variable. Therefore it is useful
to have the ability to reduce or increase the core performance to match the expected core
workload. Clocking the core more slowly reduces dynamic power consumption.

Dynamic Voltage and Frequency Scaling (DVFS) is an energy saving technique that exploits:
• The linear relationship between power consumption and operational frequency.
• The quadratic relationship between power consumption and operational voltage.

This relationship is given as:

P = C * V^2 * f

Where:
P Is the dynamic power.
C Is the switching capacitance of the logic circuit in question.
V Is the operational voltage.
f Is the operational frequency.

Power savings are achieved by adjusting the frequency of a core clock.

At lower frequencies the core can also operate at lower voltages. The advantage of reducing
supply voltage is that it reduces both dynamic and static power.

There is an IMPLEMENTATION SPECIFIC relationship between the operational voltage for a given circuit and the range of frequencies that circuit can safely operate at. A given frequency of
operation together with its corresponding operational voltage is expressed as a tuple and is
known as an Operating Performance Point (OPP). For a given system, the range of attainable
OPPs are collectively termed as the system DVFS curve.

Operating systems use DVFS to save energy and, where necessary, keep within thermal limits.
The OS provides DVFS policies to manage the power consumed and the required performance.
A policy aimed at high-performance selects higher frequencies and uses more energy. A policy
aimed at saving energy selects lower frequencies and therefore results in lower performance.

翻译成中文大概的意思如下:
DVFS是一种节省CPU功耗的技术,怎么来节省功耗呢?

  1. 根据system workload来动态调节CPU频率,直到调节CPU的供电电压,电压越低,功耗越小
  2. CPU的电源消耗大小与CPU所在的频率大小成正比(实际中并不是线性比例,按照当前A75/A76,在高频段,电源消耗明显比低频段消耗的更多.就像一条直线的斜率变的更陡了.).
  3. CPU电源消耗与CPU供电电压成平方关系.
  4. 对于CPU频率的动态调整,现在的kernel中存在大量的策略,比如ondemand/power save/performance/userspace/schedutil等等.
  5. 所以如果系统一旦发现过热现象,就可能会触发thermal动作,限制CPU频率,或者热插拔CPU(或者简单的隔离CPU,热插拔CPU的轻量级操作)来达到降低温度的作用.反之就是降低系统性能了.
  6. 如果你想知道cpu相关信息和相关sys节点怎么创建的可以参考这个:
    sys接口:/sys/devices/system/cpu/目录下所有节点怎么创建的

其实最终节省功耗的方式就是调整core的时钟频率(电压). 这样会同时减少动态功耗和静态功耗.

其实我第一份工作的时候,还一起与CV同事验证过频率点和电压点的组合是否合理,一般的要求如下:

  1. 我们在DVFS中,一般一个频率点对应一个电压点,但是DVFS 驱动完成之前,频率点和电压点对应的table需要多次反复验证其稳定性.不能因为频率与电压不匹配导致系统不稳定.如果不在前提找出合理匹配点,一旦出现问题,会很麻烦去定位root cause
  2. 芯片蚀刻的时候,会有不同体质的芯片.也就会导致类似市面上的旗舰机型的阉割版芯片.需要对这部分芯片重新适配验证.

当然DVFS不仅仅使用在CPU场合,其实很多可以频率条件的硬件都是通用的概念.比如GPU/外设(devfreq)/DRAM等等.

很多时候,如何让CPU处于一个合理的频点,即可以save power,也可以keep performance,其实还是比较难的. 所以很多时候碰到的情况是,某些人为的去限制CPU频率(比如通过上层接口),虽然会节省你锁观察到的场景功耗降低,但是可能影响其他场景的性能.因此现在对于手机端都提倡分场景(智能些的:场景检测,场景匹配,AI技术模型训练,匹配更准确)定制化,是性能优先些还是功耗优先些.

以上供自己备份.

参考文献: ARMV8手册.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章