[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250612122355.19629-2-gautham.shenoy@amd.com>
Date: Thu, 12 Jun 2025 17:53:54 +0530
From: "Gautham R. Shenoy" <gautham.shenoy@....com>
To: Thomas Renninger <trenn@...e.com>, Shuah Khan <shuah@...nel.org>, "John B
. Wyatt IV" <jwyatt@...hat.com>, John Kacur <jkacur@...hat.com>
CC: <linux-pm@...r.kernel.org>, <linux-kernel@...r.kernel.org>, "Gautham R.
Shenoy" <gautham.shenoy@....com>
Subject: [PATCH 1/2] pm: cpupower: Fix the snapshot-order of tsc,mperf, clock in mperf_stop()
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@....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
Powered by blists - more mailing lists