mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] pm: cpupower: Couple of fixes to the cpupower monitor
@ 2025-06-12 12:23 Gautham R. Shenoy
  2025-06-12 12:23 ` [PATCH 1/2] pm: cpupower: Fix the snapshot-order of tsc,mperf, clock in mperf_stop() Gautham R. Shenoy
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Gautham R. Shenoy @ 2025-06-12 12:23 UTC (permalink / raw)
  To: Thomas Renninger, Shuah Khan, John B . Wyatt IV, John Kacur
  Cc: linux-pm, linux-kernel, Gautham R. Shenoy

Hello!

This patch-series contains a couple of fixes to the cpupower monitor.

* The first patch ensures that the C0% printed by the mperf-monitor is
  100% when the core is fully busy.

* The second patch ensure that the CORE and CPU fields are printed in
  the cpupower-monitor output for multi-socket systems. This has been
  broken since 6.15.

Gautham R. Shenoy (2):
  pm: cpupower: Fix the snapshot-order of tsc,mperf, clock in mperf_stop()
  pm: cpupower: Fix printing of CORE, CPU fields in cpupower-monitor

 tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c | 4 ----
 tools/power/cpupower/utils/idle_monitor/mperf_monitor.c    | 4 ++--
 2 files changed, 2 insertions(+), 6 deletions(-)

-- 
2.34.1


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

* [PATCH 1/2] pm: cpupower: Fix the snapshot-order of tsc,mperf, clock in mperf_stop()
  2025-06-12 12:23 [PATCH 0/2] pm: cpupower: Couple of fixes to the cpupower monitor Gautham R. Shenoy
@ 2025-06-12 12:23 ` Gautham R. Shenoy
  2025-06-12 12:23 ` [PATCH 2/2] pm: cpupower: Fix printing of CORE, CPU fields in cpupower-monitor Gautham R. Shenoy
  2025-06-18 22:43 ` [PATCH 0/2] pm: cpupower: Couple of fixes to the cpupower monitor Shuah Khan
  2 siblings, 0 replies; 4+ messages in thread
From: Gautham R. Shenoy @ 2025-06-12 12:23 UTC (permalink / raw)
  To: Thomas Renninger, Shuah Khan, John B . Wyatt IV, John Kacur
  Cc: linux-pm, linux-kernel, Gautham R. Shenoy

In the function mperf_start(), mperf_monitor snapshots the time, tsc
and finally the aperf,mperf MSRs. However, this order of snapshotting
in is reversed in mperf_stop(). As a result, the C0 residency (which
is computed as delta_mperf * 100 / delta_tsc) is under-reported on
CPUs that is 100% busy.

Fix this by snapshotting time, tsc and then aperf,mperf in
mperf_stop() in the same order as in mperf_start().

Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
---
 tools/power/cpupower/utils/idle_monitor/mperf_monitor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/power/cpupower/utils/idle_monitor/mperf_monitor.c b/tools/power/cpupower/utils/idle_monitor/mperf_monitor.c
index 73b6b10cbdd2..5ae02c3d5b64 100644
--- a/tools/power/cpupower/utils/idle_monitor/mperf_monitor.c
+++ b/tools/power/cpupower/utils/idle_monitor/mperf_monitor.c
@@ -240,9 +240,9 @@ static int mperf_stop(void)
 	int cpu;
 
 	for (cpu = 0; cpu < cpu_count; cpu++) {
-		mperf_measure_stats(cpu);
-		mperf_get_tsc(&tsc_at_measure_end[cpu]);
 		clock_gettime(CLOCK_REALTIME, &time_end[cpu]);
+		mperf_get_tsc(&tsc_at_measure_end[cpu]);
+		mperf_measure_stats(cpu);
 	}
 
 	return 0;
-- 
2.34.1


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

* [PATCH 2/2] pm: cpupower: Fix printing of CORE, CPU fields in cpupower-monitor
  2025-06-12 12:23 [PATCH 0/2] pm: cpupower: Couple of fixes to the cpupower monitor Gautham R. Shenoy
  2025-06-12 12:23 ` [PATCH 1/2] pm: cpupower: Fix the snapshot-order of tsc,mperf, clock in mperf_stop() Gautham R. Shenoy
@ 2025-06-12 12:23 ` Gautham R. Shenoy
  2025-06-18 22:43 ` [PATCH 0/2] pm: cpupower: Couple of fixes to the cpupower monitor Shuah Khan
  2 siblings, 0 replies; 4+ messages in thread
From: Gautham R. Shenoy @ 2025-06-12 12:23 UTC (permalink / raw)
  To: Thomas Renninger, Shuah Khan, John B . Wyatt IV, John Kacur
  Cc: linux-pm, linux-kernel, Gautham R. Shenoy

After the commit 0014f65e3df0 ("pm: cpupower: remove hard-coded
topology depth values"), "cpupower monitor" output ceased to print the
CORE and the CPU fields on a multi-socket platform.

The reason for this is that the patch changed the behaviour to break
out of the switch-case after printing the PKG details, while prior to
the patch, the CORE and the CPU details would also get printed since
the "if" condition check would pass for any level whose topology depth
was lesser than that of a package.

Fix this ensuring all the details below a desired topology depth are
printed in the cpupower monitor output.

Fixes: 0014f65e3df0 ("pm: cpupower: remove hard-coded topology depth values")
Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
---
 tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
index ad493157f826..e8b3841d5c0f 100644
--- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
+++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
@@ -121,10 +121,8 @@ void print_header(int topology_depth)
 	switch (topology_depth) {
 	case TOPOLOGY_DEPTH_PKG:
 		printf(" PKG|");
-		break;
 	case TOPOLOGY_DEPTH_CORE:
 		printf("CORE|");
-		break;
 	case	TOPOLOGY_DEPTH_CPU:
 		printf(" CPU|");
 		break;
@@ -167,10 +165,8 @@ void print_results(int topology_depth, int cpu)
 	switch (topology_depth) {
 	case TOPOLOGY_DEPTH_PKG:
 		printf("%4d|", cpu_top.core_info[cpu].pkg);
-		break;
 	case TOPOLOGY_DEPTH_CORE:
 		printf("%4d|", cpu_top.core_info[cpu].core);
-		break;
 	case TOPOLOGY_DEPTH_CPU:
 		printf("%4d|", cpu_top.core_info[cpu].cpu);
 		break;
-- 
2.34.1


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

* Re: [PATCH 0/2] pm: cpupower: Couple of fixes to the cpupower monitor
  2025-06-12 12:23 [PATCH 0/2] pm: cpupower: Couple of fixes to the cpupower monitor Gautham R. Shenoy
  2025-06-12 12:23 ` [PATCH 1/2] pm: cpupower: Fix the snapshot-order of tsc,mperf, clock in mperf_stop() Gautham R. Shenoy
  2025-06-12 12:23 ` [PATCH 2/2] pm: cpupower: Fix printing of CORE, CPU fields in cpupower-monitor Gautham R. Shenoy
@ 2025-06-18 22:43 ` Shuah Khan
  2 siblings, 0 replies; 4+ messages in thread
From: Shuah Khan @ 2025-06-18 22:43 UTC (permalink / raw)
  To: Gautham R. Shenoy, Thomas Renninger, Shuah Khan,
	John B . Wyatt IV, John Kacur
  Cc: linux-pm, linux-kernel, Shuah Khan

On 6/12/25 06:23, Gautham R. Shenoy wrote:
> Hello!
> 
> This patch-series contains a couple of fixes to the cpupower monitor.
> 
> * The first patch ensures that the C0% printed by the mperf-monitor is
>    100% when the core is fully busy.
> 
> * The second patch ensure that the CORE and CPU fields are printed in
>    the cpupower-monitor output for multi-socket systems. This has been
>    broken since 6.15.
> 
> Gautham R. Shenoy (2):
>    pm: cpupower: Fix the snapshot-order of tsc,mperf, clock in mperf_stop()
>    pm: cpupower: Fix printing of CORE, CPU fields in cpupower-monitor
> 
>   tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c | 4 ----
>   tools/power/cpupower/utils/idle_monitor/mperf_monitor.c    | 4 ++--
>   2 files changed, 2 insertions(+), 6 deletions(-)
> 

Applied - will include in my fixes PR to Rafael
https://web.git.kernel.org/pub/scm/linux/kernel/git/shuah/linux.git/?h=cpupower

thanks,
-- Shuah

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

end of thread, other threads:[~2025-06-18 22:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-12 12:23 [PATCH 0/2] pm: cpupower: Couple of fixes to the cpupower monitor Gautham R. Shenoy
2025-06-12 12:23 ` [PATCH 1/2] pm: cpupower: Fix the snapshot-order of tsc,mperf, clock in mperf_stop() Gautham R. Shenoy
2025-06-12 12:23 ` [PATCH 2/2] pm: cpupower: Fix printing of CORE, CPU fields in cpupower-monitor Gautham R. Shenoy
2025-06-18 22:43 ` [PATCH 0/2] pm: cpupower: Couple of fixes to the cpupower monitor Shuah Khan

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

all inboxes | Powered by JetHome®