diff options
| author | Gautham R. Shenoy <gautham.shenoy@amd.com> | 2025-06-12 17:53:54 +0530 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-08-28 16:25:54 +0200 |
| commit | eb636446e390d4303c5c87aab59c7f3ad10241dd (patch) | |
| tree | 860da53d54b31e772e01300050db0044c725d26b /tools | |
| parent | 4d2cc6967dd1852262b42a538577e6f8223ce27e (diff) | |
| download | linux-eb636446e390d4303c5c87aab59c7f3ad10241dd.tar.gz linux-eb636446e390d4303c5c87aab59c7f3ad10241dd.tar.bz2 linux-eb636446e390d4303c5c87aab59c7f3ad10241dd.zip | |
pm: cpupower: Fix the snapshot-order of tsc,mperf, clock in mperf_stop()
[ Upstream commit cda7ac8ce7de84cf32a3871ba5f318aa3b79381e ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/power/cpupower/utils/idle_monitor/mperf_monitor.c | 4 |
1 files 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 08a399b0be28..6ab9139f16af 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; |
