mm: memcg: remove unneeded checks from newpage_charge()
[platform/adaptation/renesas_rcar/renesas_kernel.git] / init / calibrate.c
index aae2f40..5f117ca 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,32 @@ recalibrate:
        return lpj;
 }
 
+static DEFINE_PER_CPU(unsigned long, cpu_loops_per_jiffy) = { 0 };
+
+/*
+ * Check if cpu calibration delay is already known. For example,
+ * some processors with multi-core sockets may have all cores
+ * with the same calibration delay.
+ *
+ * Architectures should override this function if a faster calibration
+ * method is available.
+ */
+unsigned long __attribute__((weak)) __cpuinit calibrate_delay_is_known(void)
+{
+       return 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) "
@@ -257,6 +278,8 @@ void __cpuinit calibrate_delay(void)
                lpj = lpj_fine;
                pr_info("Calibrating delay loop (skipped), "
                        "value calculated using timer frequency.. ");
+       } else if ((lpj = calibrate_delay_is_known())) {
+               ;
        } else if ((lpj = calibrate_delay_direct()) != 0) {
                if (!printed)
                        pr_info("Calibrating delay using timer "
@@ -266,6 +289,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),