Linux command – cpupower

CPU 依據省電模式有區分為 Processor Operating States (C-states) 與 Processor Performance States (P-states),兩者的差別是? ACPI 支援可以參考 http://benjr.tw/257

測試環境為 CentOS 7 x86_64 (虛擬機)

Processor Operating States (C-states)

CPU 在沒有使用時可以被停用或以比較低的效能模式來運行,依據不同的狀態可以區分成為幾種 C-state ,C-state 從 C0 (不閒置)開始,數字越高表示越省電(每一家的 CPU 定義 C-state 會稍微不同).
CPU 的 C-state 有下面幾種.

  1. C0 – Operating State
  2. C1 – Halt
  3. C1E – Enhanced Halt
  4. C2 – Stop Grant
  5. C2 – Stop Clock
  6. C2E – Extended Stop Grant
  7. C3 – Sleep
  8. C3 – Deep Sleep
  9. C3 – AltVID
  10. C4 – Deeper Sleep
  11. C4E/C5 -Enhanced Deeper Sleep
  12. C6 – Deep Power Down
  13. C7 – C6 + LLC may be flushed
  14. 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
CPUidle driver: none
CPUidle governor: menu
analyzing CPU 0:

CPU 0: No idle states

參數 monitor 可以檢視目前的 C-State 為哪一種.
POLL = C0

[root@localhost ~]# cpupower monitor -l
Monitor "SandyBridge" (3 states) - Might overflow after 922000000 s
C7	[C] -> Processor Core C7
PC2	[P] -> Processor Package C2
PC7	[P] -> Processor Package C7
[root@localhost ~]# cpupower monitor
              |SandyBridge         
PKG |CORE|CPU | C7   | PC2  | PC7  
   0|   0|   0|  0.00|  0.00|  0.00
   2|   0|   1|  0.00|  0.00|  0.00

MPERF increasing with maxium (P0) frequency in C0
APERF increasing with current/actual frequency in C0

Processor Performance States (P-states)

P-States 就是指 CPU 依據目前狀態自行調整工作頻率,用以省電.
透過指令 cpupower ,參數 frequency-info 可以得知目前這個 CPU 支援的工作頻率.

[root@localhost ~]# cpupower frequency-info
analyzing CPU 0:
  no or unknown cpufreq driver is active on this CPU
  CPUs which run at the same hardware frequency: Not Available
  CPUs which need to have their frequency coordinated by software: Not Available
  maximum transition latency:  Cannot determine or is not supported.
  hardware limits: Not Available
  available cpufreq governors: Not Available
  Unable to determine current policy
  current CPU frequency: Unable to call hardware
  current CPU frequency:  Unable to call to kernel
  boost state support:
    Supported: no
    Active: no

透過 turbostat – http://benjr.tw/99181 與 powertop – http://benjr.tw/99175 , 一樣可以觀察目前 CPU 狀態.

如果要設定 CPU 的工作頻率,可以透過指令 # cpupower frequency-set

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *