init: skip calibration delay if previously done
authorSameer Nanda <[email protected]>
Tue, 26 Jul 2011 00:13:29 +0000 (17:13 -0700)
committerLinus Torvalds <[email protected]>
Tue, 26 Jul 2011 03:57:17 +0000 (20:57 -0700)
For each CPU, do the calibration delay only once.  For subsequent calls,
use the cached per-CPU value of loops_per_jiffy.

This saves about 200ms of resume time on dual core Intel Atom N5xx based
systems.  This helps bring down the kernel resume time on such systems
from about 500ms to about 300ms.

[[email protected]: make cpu_loops_per_jiffy static]
[[email protected]: clean up message text]
[[email protected]: fix things up after upstream rmk changes]
Signed-off-by: Sameer Nanda <[email protected]>
Cc: Phil Carmody <[email protected]>
Cc: Andrew Worsley <[email protected]>
Cc: David Daney <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
init/calibrate.c

index aae2f40fea4cbea200f0658c7f6afddb60f1d934..24df7976816c6ca99f3403f97444f8e49f69a0a7 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/init.h>
 #include <linux/timex.h>
 #include <linux/smp.h>
+#include <linux/percpu.h>
 
 unsigned long lpj_fine;
 unsigned long preset_lpj;
@@ -243,12 +244,19 @@ recalibrate:
        return lpj;
 }
 
+static DEFINE_PER_CPU(unsigned long, cpu_loops_per_jiffy) = { 0 };
+
 void __cpuinit calibrate_delay(void)
 {
        unsigned long lpj;
        static bool printed;
+       int this_cpu = smp_processor_id();
 
-       if (preset_lpj) {
+       if (per_cpu(cpu_loops_per_jiffy, this_cpu)) {
+               lpj = per_cpu(cpu_loops_per_jiffy, this_cpu);
+               pr_info("Calibrating delay loop (skipped) "
+                               "already calibrated this CPU");
+       } else if (preset_lpj) {
                lpj = preset_lpj;
                if (!printed)
                        pr_info("Calibrating delay loop (skipped) "
@@ -266,6 +274,7 @@ void __cpuinit calibrate_delay(void)
                        pr_info("Calibrating delay loop... ");
                lpj = calibrate_delay_converge();
        }
+       per_cpu(cpu_loops_per_jiffy, this_cpu) = lpj;
        if (!printed)
                pr_cont("%lu.%02lu BogoMIPS (lpj=%lu)\n",
                        lpj/(500000/HZ),