Skip to contentSkip to conversation

cpu_khz isn't reliable at boot time

BUG Shaohua Li 1 participant 1 message Jul 11, 2006

lore
Share & tools
lore

Shaohua Li

author
#0 lore raw

In mobile system, BIOS usually sets CPU to low speed. In modern CPU, TSC is constant speed regardless of CPU speed. Linux uses TSC to calculate cpu_khz, which is the full speed frequence of CPU instead of low speed in some systems. This might invoke some potential issues. One is NMI watchdog, which runs less frequently in cpu low speed mode.

Below workaround from Len addressed the NMI issue, any idea?

arch/i386/kernel/nmi.c +11 -1
index d43b498..b157186 100644
@@ -150,7 +150,12 @@ #ifdef CONFIG_SMP
 		if (!cpu_isset(cpu, cpu_callin_map))
 			continue;
 #endif
-		if (nmi_count(cpu) - prev_nmi_count[cpu] <= 5) {
+		/*
+		 * Fail if there were NO watchdog interrupts recorded.
+		 * We don't know the exact number to expect because
+		 * cpu_khz is variable.
+		 */
+		if ((nmi_count(cpu) - prev_nmi_count[cpu]) == 0) {
 			endflag = 1;
 			printk("CPU#%d: NMI appears to be stuck (%d->%d)!\n",
 				cpu,
@@ -357,6 +362,11 @@ static void clear_msr_range(unsigned int
 		wrmsr(base+i, 0, 0);
 }
 
+/*
+ * n.b.
+ * cpu_khz may not reflect the current or future khz of the processor
+ * depending on what speed the system booted at and if cpufreq is running
+ */
 static void write_watchdog_counter(const char *descr)
 {
 	u64 count = (u64)cpu_khz * 1000;