CPU 依據省電模式有區分為 Processor Operating States (C-states) 與 Processor Performance States (P-states),兩者的差別是?
Processor Operating States (C-states)
CPU 在沒有使用時可以被停用或以比較低的效能模式來運行,依據不同的狀態可以區分成為幾種 C-state ,C-state 從 C0 (不閒置)開始,數字越高表示越省電(每一家的 CPU 定義 C-state 會稍微不同).
CPU 的 C-state 有下面幾種.
- C0 – Operating State
- C1 – Halt
- C1E – Enhanced Halt
- C2 – Stop Grant
- C2 – Stop Clock
- C2E – Extended Stop Grant
- C3 – Sleep
- C3 – Deep Sleep
- C3 – AltVID
- C4 – Deeper Sleep
- C4E/C5 -Enhanced Deeper Sleep
- C6 – Deep Power Down
- C7 – C6 + LLC may be flushed
- C8 – C7 + LLC must be flushed
要看 CPU 有支援哪一些 C-state 可以透過指令 cpupower.
[root@localhost ~]# cpupower Usage: cpupower [-d|--debug] [-c|--cpu cpulist ] <command> [<args>] Supported commands are: frequency-info frequency-set idle-info idle-set set info monitor help Not all commands can make use of the -c cpulist option. Use 'cpupower help <command>' for getting help for above commands.
參數 idle-info 可以看到有支援的 C-State
[root@localhost ~]# cpupower idle-info
參數 monitor 可以檢視目前的 C-State 為哪一種.
POLL = C0
[root@localhost ~]# cpupower monitor |Nehalem || Mperf || Idle_Stats PKG |CORE|CPU | C3 | C6 | PC3 | PC6 || C0 | Cx | Freq || POLL | C1-S | C1E- | C6-S 0| 0| 0| 0.00| 98.89| 0.00| 0.00|| 0.02| 99.98| 1601|| 0.00| 0.00| 0.00| 99.98 0| 0| 2| 0.00| 98.90| 0.00| 0.00|| 0.01| 99.99| 1632|| 0.00| 0.00| 0.00| 99.98 0| 1| 1| 0.00| 92.93| 0.00| 0.00|| 0.01| 99.99| 2197|| 0.00| 0.00| 0.00| 99.97 0| 1| 2| 0.00| 93.02| 0.00| 0.00|| 2.65| 97.35| 3376|| 0.00| 0.00| 0.22| 96.98
Processor Performance States (P-states)
P-States 就是指 CPU 依據目前狀態自行調整工作頻率,用以省電.
透過指令 cpupower ,參數 frequency-info 可以得知目前這個 CPU 支援的工作頻率.
[root@localhost ~]# cpupower frequency-info
透過 turbostat 與 powertop (EPEL 套件) , 一樣可以觀察目前 CPU 狀態.