]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/time/tick-sched.c
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux...
[linux-2.6-omap-h63xx.git] / kernel / time / tick-sched.c
index b416995b975727ca8b6dbf8b331de5351a1ef7f5..10a1347597fd394fec309d1ae74663ae2d9ae05c 100644 (file)
@@ -153,6 +153,7 @@ void tick_nohz_stop_sched_tick(void)
        unsigned long seq, last_jiffies, next_jiffies, delta_jiffies, flags;
        struct tick_sched *ts;
        ktime_t last_update, expires, now, delta;
+       struct clock_event_device *dev = __get_cpu_var(tick_cpu_device).evtdev;
        int cpu;
 
        local_irq_save(flags);
@@ -160,6 +161,18 @@ void tick_nohz_stop_sched_tick(void)
        cpu = smp_processor_id();
        ts = &per_cpu(tick_cpu_sched, cpu);
 
+       /*
+        * If this cpu is offline and it is the one which updates
+        * jiffies, then give up the assignment and let it be taken by
+        * the cpu which runs the tick timer next. If we don't drop
+        * this here the jiffies might be stale and do_timer() never
+        * invoked.
+        */
+       if (unlikely(!cpu_online(cpu))) {
+               if (cpu == tick_do_timer_cpu)
+                       tick_do_timer_cpu = -1;
+       }
+
        if (unlikely(ts->nohz_mode == NOHZ_MODE_INACTIVE))
                goto end;
 
@@ -290,10 +303,25 @@ void tick_nohz_stop_sched_tick(void)
 out:
        ts->next_jiffies = next_jiffies;
        ts->last_jiffies = last_jiffies;
+       ts->sleep_length = ktime_sub(dev->next_event, now);
 end:
        local_irq_restore(flags);
 }
 
+/**
+ * tick_nohz_get_sleep_length - return the length of the current sleep
+ *
+ * Called from power state control code with interrupts disabled
+ */
+ktime_t tick_nohz_get_sleep_length(void)
+{
+       struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
+
+       return ts->sleep_length;
+}
+
+EXPORT_SYMBOL_GPL(tick_nohz_get_sleep_length);
+
 /**
  * nohz_restart_sched_tick - restart the idle tick from the idle task
  *
@@ -558,7 +586,7 @@ void tick_setup_sched_timer(void)
        /* Get the next period (per cpu) */
        ts->sched_timer.expires = tick_init_jiffy_update();
        offset = ktime_to_ns(tick_period) >> 1;
-       do_div(offset, NR_CPUS);
+       do_div(offset, num_possible_cpus());
        offset *= smp_processor_id();
        ts->sched_timer.expires = ktime_add_ns(ts->sched_timer.expires, offset);