nfsd: track last inode only in use_wgather case
[safe/jmp/linux-2.6] / kernel / sched_clock.c
index db69174..e1d16c9 100644 (file)
  * The clock: sched_clock_cpu() is monotonic per cpu, and should be somewhat
  * consistent between cpus (never more than 2 jiffies difference).
  */
-#include <linux/sched.h>
-#include <linux/percpu.h>
 #include <linux/spinlock.h>
-#include <linux/ktime.h>
-#include <linux/module.h>
 #include <linux/hardirq.h>
+#include <linux/module.h>
+#include <linux/percpu.h>
+#include <linux/ktime.h>
+#include <linux/sched.h>
 
 /*
  * Scheduler clock - returns current time in nanosec units.
  */
 unsigned long long __attribute__((weak)) sched_clock(void)
 {
-       return (unsigned long long)jiffies * (NSEC_PER_SEC / HZ);
+       return (unsigned long long)(jiffies - INITIAL_JIFFIES)
+                                       * (NSEC_PER_SEC / HZ);
 }
 
 static __read_mostly int sched_clock_running;
 
 #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
+__read_mostly int sched_clock_stable;
 
 struct sched_clock_data {
        /*
@@ -88,7 +90,7 @@ void sched_clock_init(void)
 }
 
 /*
- * min,max except they take wrapping into account
+ * min, max except they take wrapping into account
  */
 
 static inline u64 wrap_min(u64 x, u64 y)
@@ -112,15 +114,13 @@ static u64 __update_sched_clock(struct sched_clock_data *scd, u64 now)
        s64 delta = now - scd->tick_raw;
        u64 clock, min_clock, max_clock;
 
-       WARN_ON_ONCE(!irqs_disabled());
-
        if (unlikely(delta < 0))
                delta = 0;
 
        /*
         * scd->clock = clamp(scd->tick_gtod + delta,
-        *                    max(scd->tick_gtod, scd->clock),
-        *                    scd->tick_gtod + TICK_NSEC);
+        *                    max(scd->tick_gtod, scd->clock),
+        *                    scd->tick_gtod + TICK_NSEC);
         */
 
        clock = scd->tick_gtod + delta;
@@ -149,8 +149,13 @@ static void lock_double_clock(struct sched_clock_data *data1,
 
 u64 sched_clock_cpu(int cpu)
 {
-       struct sched_clock_data *scd = cpu_sdc(cpu);
        u64 now, clock, this_clock, remote_clock;
+       struct sched_clock_data *scd;
+
+       if (sched_clock_stable)
+               return sched_clock();
+
+       scd = cpu_sdc(cpu);
 
        /*
         * Normally this is not called in NMI context - but if it is,
@@ -203,14 +208,18 @@ u64 sched_clock_cpu(int cpu)
 
 void sched_clock_tick(void)
 {
-       struct sched_clock_data *scd = this_scd();
+       struct sched_clock_data *scd;
        u64 now, now_gtod;
 
+       if (sched_clock_stable)
+               return;
+
        if (unlikely(!sched_clock_running))
                return;
 
        WARN_ON_ONCE(!irqs_disabled());
 
+       scd = this_scd();
        now_gtod = ktime_to_ns(ktime_get());
        now = sched_clock();
 
@@ -258,7 +267,7 @@ u64 sched_clock_cpu(int cpu)
        return sched_clock();
 }
 
-#endif
+#endif /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */
 
 unsigned long long cpu_clock(int cpu)
 {