Intro cpupower

Intro cpupower

這篇介紹cpupower。

C-states versus P-states

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
CPU 依據省電模式有區分為 Processor Operating States (C-states) 
與 Processor Performance States (P-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

P-States 就是指 CPU 依據目前狀態自行調整工作頻率,用以省電。

指令1 - cpupower

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
CPU 有支援哪一些指令,可以直接下cpupower

[root@localhost ~]# cpupower
Usage: cpupower [-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.

指令2 - cpupower idle-info

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
查詢CPU有支援的 C-State

[root@localhost ~]# cpupower idle-info
CPUidle driver: acpi_idle
CPUidle governor: menu
analyzing CPU 0:

Number of idle states: 2
Available idle states: POLL C1
POLL:
Flags/Description: CPUIDLE CORE POLL IDLE
Latency: 0
Usage: 0
Duration: 0
C1:
Flags/Description: ACPI HLT
Latency: 0
Usage: 4183551158
Duration: 11583728700572

指令3 - cpupower monitor -l

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
參數 monitor 可以檢視目前是哪一種 C-State

[root@localhost ~]# cpupower monitor -l
Monitor "Nehalem" (4 states) - Might overflow after 922000000 s
C3 [C] -> Processor Core C3
C6 [C] -> Processor Core C6
PC3 [P] -> Processor Package C3
PC6 [P] -> Processor Package C6
Monitor "Mperf" (3 states) - Might overflow after 922000000 s
C0 [T] -> Processor Core not idle
Cx [T] -> Processor Core in an idle state
Freq [T] -> Average Frequency (including boost) in MHz
Monitor "Idle_Stats" (2 states) - Might overflow after 4294967295 s
POLL [T] -> CPUIDLE CORE POLL IDLE
C1 [T] -> ACPI HLT

[root@localhost ~]# cpupower monitor
| Nehalem || Mperf || Idle_Stats
PKG|CORE| CPU| C3 | C6 | PC3 | PC6 || C0 | Cx | Freq || POLL | C1
0| 0| 0| 0.00| 0.00| 0.00| 0.00|| 0.00| 100.0|9223372036854775808|| 0.00| 98.54
0| 1| 1| 0.00| 0.00| 0.00| 0.00|| 0.00| 100.0|9223372036854775808|| 0.00| 98.48
0| 2| 2| 0.00| 0.00| 0.00| 0.00|| 0.00| 100.0|9223372036854775808|| 0.00| 98.54
0| 3| 3| 0.00| 0.00| 0.00| 0.00|| 0.00| 100.0|9223372036854775808|| 0.00| 98.36
1| 0| 4| 0.00| 0.00| 0.00| 0.00|| 0.00| 100.0|9223372036854775808|| 0.00| 98.65
1| 1| 5| 0.00| 0.00| 0.00| 0.00|| 0.00| 100.0|9223372036854775808|| 0.00| 98.99
1| 2| 6| 0.00| 0.00| 0.00| 0.00|| 0.00| 100.0|9223372036854775808|| 0.00| 98.63
1| 3| 7| 0.00| 0.00| 0.00| 0.00|| 0.00| 100.0|9223372036854775808|| 0.00| 98.74

指令4 - cpupower frequency-info

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
透過指令參數 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.
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: yes
Active: yes