[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手冊.

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