Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/cpupower: display residency value in idle-info

Update cpuidle tool to display the residency value of cpuidle
states. This addition provides a clearer and more detailed view
of idle state information when using cpuidle-info.

--------------------------------
Before Patch:
--------------------------------
$ cpupower idle-info
CPUidle driver: intel_idle
CPUidle governor: menu
analyzing CPU 28:

Number of idle states: 3
Available idle states: POLL C1 C1E
POLL:
Flags/Description: CPUIDLE CORE POLL IDLE
Latency: 0
Usage: 7448
Duration: 207170
C1:
Flags/Description: MWAIT 0x00
Latency: 2
Usage: 7023
Duration: 3736853
C1E:
Flags/Description: MWAIT 0x01
Latency: 10
Usage: 18468
Duration: 11396212

--------------------------------
After Patch:
--------------------------------
$ cpupower idle-info
CPUidle driver: intel_idle
CPUidle governor: menu
analyzing CPU 12:

Number of idle states: 3
Available idle states: POLL C1 C1E
POLL:
Flags/Description: CPUIDLE CORE POLL IDLE
Latency: 0
Residency: 0
Usage: 1950
Duration: 38458
C1:
Flags/Description: MWAIT 0x00
Latency: 2
Residency: 2
Usage: 10688
Duration: 7133020
C1E:
Flags/Description: MWAIT 0x01
Latency: 10
Residency: 20
Usage: 22356
Duration: 15687259
--------------------------------

Signed-off-by: Aboorva Devarajan <aboorvad@linux.ibm.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Aboorva Devarajan and committed by
Shuah Khan
76fb981a 8400291e

+14
+8
tools/power/cpupower/lib/cpuidle.c
··· 116 116 IDLESTATE_USAGE, 117 117 IDLESTATE_POWER, 118 118 IDLESTATE_LATENCY, 119 + IDLESTATE_RESIDENCY, 119 120 IDLESTATE_TIME, 120 121 IDLESTATE_DISABLE, 121 122 MAX_IDLESTATE_VALUE_FILES ··· 126 125 [IDLESTATE_USAGE] = "usage", 127 126 [IDLESTATE_POWER] = "power", 128 127 [IDLESTATE_LATENCY] = "latency", 128 + [IDLESTATE_RESIDENCY] = "residency", 129 129 [IDLESTATE_TIME] = "time", 130 130 [IDLESTATE_DISABLE] = "disable", 131 131 }; ··· 254 252 unsigned int idlestate) 255 253 { 256 254 return cpuidle_state_get_one_value(cpu, idlestate, IDLESTATE_LATENCY); 255 + } 256 + 257 + unsigned long cpuidle_state_residency(unsigned int cpu, 258 + unsigned int idlestate) 259 + { 260 + return cpuidle_state_get_one_value(cpu, idlestate, IDLESTATE_RESIDENCY); 257 261 } 258 262 259 263 unsigned long cpuidle_state_usage(unsigned int cpu,
+2
tools/power/cpupower/lib/cpuidle.h
··· 8 8 unsigned int disable); 9 9 unsigned long cpuidle_state_latency(unsigned int cpu, 10 10 unsigned int idlestate); 11 + unsigned long cpuidle_state_residency(unsigned int cpu, 12 + unsigned int idlestate); 11 13 unsigned long cpuidle_state_usage(unsigned int cpu, 12 14 unsigned int idlestate); 13 15 unsigned long long cpuidle_state_time(unsigned int cpu,
+4
tools/power/cpupower/utils/cpuidle-info.c
··· 64 64 65 65 printf(_("Latency: %lu\n"), 66 66 cpuidle_state_latency(cpu, idlestate)); 67 + printf(_("Residency: %lu\n"), 68 + cpuidle_state_residency(cpu, idlestate)); 67 69 printf(_("Usage: %lu\n"), 68 70 cpuidle_state_usage(cpu, idlestate)); 69 71 printf(_("Duration: %llu\n"), ··· 117 115 printf(_("promotion[--] demotion[--] ")); 118 116 printf(_("latency[%03lu] "), 119 117 cpuidle_state_latency(cpu, cstate)); 118 + printf(_("residency[%05lu] "), 119 + cpuidle_state_residency(cpu, cstate)); 120 120 printf(_("usage[%08lu] "), 121 121 cpuidle_state_usage(cpu, cstate)); 122 122 printf(_("duration[%020Lu] \n"),