public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] tools/cpupower: display residency value in idle-info
@ 2024-08-09  8:37 Aboorva Devarajan
  2024-08-09 16:36 ` Shuah Khan
  0 siblings, 1 reply; 2+ messages in thread
From: Aboorva Devarajan @ 2024-08-09  8:37 UTC (permalink / raw)
  To: trenn, shuah; +Cc: aboorvad, linux-pm, linux-kernel

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>
---
 tools/power/cpupower/lib/cpuidle.c        | 8 ++++++++
 tools/power/cpupower/lib/cpuidle.h        | 2 ++
 tools/power/cpupower/utils/cpuidle-info.c | 4 ++++
 3 files changed, 14 insertions(+)

diff --git a/tools/power/cpupower/lib/cpuidle.c b/tools/power/cpupower/lib/cpuidle.c
index 479c5971aa6d..0ecac009273c 100644
--- a/tools/power/cpupower/lib/cpuidle.c
+++ b/tools/power/cpupower/lib/cpuidle.c
@@ -116,6 +116,7 @@ enum idlestate_value {
 	IDLESTATE_USAGE,
 	IDLESTATE_POWER,
 	IDLESTATE_LATENCY,
+	IDLESTATE_RESIDENCY,
 	IDLESTATE_TIME,
 	IDLESTATE_DISABLE,
 	MAX_IDLESTATE_VALUE_FILES
@@ -125,6 +126,7 @@ static const char *idlestate_value_files[MAX_IDLESTATE_VALUE_FILES] = {
 	[IDLESTATE_USAGE] = "usage",
 	[IDLESTATE_POWER] = "power",
 	[IDLESTATE_LATENCY] = "latency",
+	[IDLESTATE_RESIDENCY] = "residency",
 	[IDLESTATE_TIME]  = "time",
 	[IDLESTATE_DISABLE]  = "disable",
 };
@@ -254,6 +256,12 @@ unsigned long cpuidle_state_latency(unsigned int cpu,
 	return cpuidle_state_get_one_value(cpu, idlestate, IDLESTATE_LATENCY);
 }
 
+unsigned long cpuidle_state_residency(unsigned int cpu,
+					  unsigned int idlestate)
+{
+	return cpuidle_state_get_one_value(cpu, idlestate, IDLESTATE_RESIDENCY);
+}
+
 unsigned long cpuidle_state_usage(unsigned int cpu,
 					unsigned int idlestate)
 {
diff --git a/tools/power/cpupower/lib/cpuidle.h b/tools/power/cpupower/lib/cpuidle.h
index 2e10fead2e1e..2ab404d40259 100644
--- a/tools/power/cpupower/lib/cpuidle.h
+++ b/tools/power/cpupower/lib/cpuidle.h
@@ -8,6 +8,8 @@ int cpuidle_state_disable(unsigned int cpu, unsigned int idlestate,
 				   unsigned int disable);
 unsigned long cpuidle_state_latency(unsigned int cpu,
 						unsigned int idlestate);
+unsigned long cpuidle_state_residency(unsigned int cpu,
+						unsigned int idlestate);
 unsigned long cpuidle_state_usage(unsigned int cpu,
 					unsigned int idlestate);
 unsigned long long cpuidle_state_time(unsigned int cpu,
diff --git a/tools/power/cpupower/utils/cpuidle-info.c b/tools/power/cpupower/utils/cpuidle-info.c
index 44126a87fa7a..e0d17f0de3fe 100644
--- a/tools/power/cpupower/utils/cpuidle-info.c
+++ b/tools/power/cpupower/utils/cpuidle-info.c
@@ -64,6 +64,8 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose)
 
 		printf(_("Latency: %lu\n"),
 		       cpuidle_state_latency(cpu, idlestate));
+		printf(_("Residency: %lu\n"),
+		       cpuidle_state_residency(cpu, idlestate));
 		printf(_("Usage: %lu\n"),
 		       cpuidle_state_usage(cpu, idlestate));
 		printf(_("Duration: %llu\n"),
@@ -115,6 +117,8 @@ static void proc_cpuidle_cpu_output(unsigned int cpu)
 		printf(_("promotion[--] demotion[--] "));
 		printf(_("latency[%03lu] "),
 		       cpuidle_state_latency(cpu, cstate));
+		printf(_("residency[%05lu] "),
+		       cpuidle_state_residency(cpu, cstate));
 		printf(_("usage[%08lu] "),
 		       cpuidle_state_usage(cpu, cstate));
 		printf(_("duration[%020Lu] \n"),
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] tools/cpupower: display residency value in idle-info
  2024-08-09  8:37 [PATCH 1/1] tools/cpupower: display residency value in idle-info Aboorva Devarajan
@ 2024-08-09 16:36 ` Shuah Khan
  0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2024-08-09 16:36 UTC (permalink / raw)
  To: Aboorva Devarajan, trenn, shuah
  Cc: linux-pm, linux-kernel, Shuah Khan, Rafael J. Wysocki

On 8/9/24 02:37, Aboorva Devarajan wrote:
> 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>
> ---
>   tools/power/cpupower/lib/cpuidle.c        | 8 ++++++++
>   tools/power/cpupower/lib/cpuidle.h        | 2 ++
>   tools/power/cpupower/utils/cpuidle-info.c | 4 ++++
>   3 files changed, 14 insertions(+)
> 

Thank you for the patch. Applied for Linux 6.12 to

https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux.git/log/?h=cpupower

I will send this in my PR to Rafael.

thanks,
-- Shuah


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-09 16:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-09  8:37 [PATCH 1/1] tools/cpupower: display residency value in idle-info Aboorva Devarajan
2024-08-09 16:36 ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox