]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
pm: cpupower: Fix the snapshot-order of tsc,mperf, clock in mperf_stop()
authorGautham R. Shenoy <gautham.shenoy@amd.com>
Thu, 12 Jun 2025 12:23:54 +0000 (17:53 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Aug 2025 16:41:03 +0000 (18:41 +0200)
commitd66713e2618d330cf1bc29c72fe95eff945f8667
tree5657812b7d5258f130f4322e6b273144333b263e
parentbc9477b6e760b9b1a82b512f30868e51c56c57a8
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>
tools/power/cpupower/utils/idle_monitor/mperf_monitor.c