Skip to content

Commit cda7ac8

Browse files
gautshenshuahkh
authored andcommitted
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(). Link: https://lore.kernel.org/r/20250612122355.19629-2-gautham.shenoy@amd.com Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent e044b8a commit cda7ac8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/power/cpupower/utils/idle_monitor/mperf_monitor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ static int mperf_stop(void)
240240
int cpu;
241241

242242
for (cpu = 0; cpu < cpu_count; cpu++) {
243-
mperf_measure_stats(cpu);
244-
mperf_get_tsc(&tsc_at_measure_end[cpu]);
245243
clock_gettime(CLOCK_REALTIME, &time_end[cpu]);
244+
mperf_get_tsc(&tsc_at_measure_end[cpu]);
245+
mperf_measure_stats(cpu);
246246
}
247247

248248
return 0;

0 commit comments

Comments
 (0)