public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/aperfmperf: Fix the fallback condition in arch_freq_get_on_cpu()
@ 2023-06-26 19:36 Keyon Jie
  2023-06-28  0:57 ` Yang Jie
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Keyon Jie @ 2023-06-26 19:36 UTC (permalink / raw)
  To: Thomas Gleixner, x86, linux-kernel
  Cc: Ingo Molnar, Borislav Petkov, Dave Hansen, H . Peter Anvin,
	Peter Zijlstra, Yair Podemsky, Keyon Jie

From the commit f3eca381bd49 on, the fallback condition about the 'the
last update was too long' have been comparing ticks and milliseconds by
mistake, which leads to that the condition is met and the fallback
method is used frequently.

The change to compare ticks here corrects that and fixes related issues
have been seen on x86 platforms since 5.18 kernel.

Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217597
Fixes: f3eca381bd49 ("x86/aperfmperf: Replace arch_freq_get_on_cpu()")
CC: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
---
 arch/x86/kernel/cpu/aperfmperf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c
index fdbb5f07448f..24e24e137226 100644
--- a/arch/x86/kernel/cpu/aperfmperf.c
+++ b/arch/x86/kernel/cpu/aperfmperf.c
@@ -432,7 +432,7 @@ unsigned int arch_freq_get_on_cpu(int cpu)
 	 * Bail on invalid count and when the last update was too long ago,
 	 * which covers idle and NOHZ full CPUs.
 	 */
-	if (!mcnt || (jiffies - last) > MAX_SAMPLE_AGE)
+	if (!mcnt || (jiffies - last) > MAX_SAMPLE_AGE * cpu_khz)
 		goto fallback;
 
 	return div64_u64((cpu_khz * acnt), mcnt);
-- 
2.34.1


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

end of thread, other threads:[~2023-07-05 17:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-26 19:36 [PATCH] x86/aperfmperf: Fix the fallback condition in arch_freq_get_on_cpu() Keyon Jie
2023-06-28  0:57 ` Yang Jie
2023-06-30 12:35 ` Thomas Gleixner
2023-07-05 17:23   ` Keyon Jie
2023-06-30 15:13 ` Dave Hansen

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