]> err.no Git - linux-2.6/blobdiff - kernel/time/tick-sched.c
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/hpa/linux...
[linux-2.6] / kernel / time / tick-sched.c
index 52db9e3c526e5bba4dc733a6d5ddd77908458401..ce89ffb474d0cbeba8b2d84af5c3a6c9ae5f7389 100644 (file)
@@ -160,6 +160,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;
 
@@ -546,6 +558,7 @@ void tick_setup_sched_timer(void)
 {
        struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
        ktime_t now = ktime_get();
+       u64 offset;
 
        /*
         * Emulate tick processing via per-CPU hrtimers:
@@ -554,8 +567,12 @@ void tick_setup_sched_timer(void)
        ts->sched_timer.function = tick_sched_timer;
        ts->sched_timer.cb_mode = HRTIMER_CB_IRQSAFE_NO_SOFTIRQ;
 
-       /* Get the next period */
+       /* Get the next period (per cpu) */
        ts->sched_timer.expires = tick_init_jiffy_update();
+       offset = ktime_to_ns(tick_period) >> 1;
+       do_div(offset, num_possible_cpus());
+       offset *= smp_processor_id();
+       ts->sched_timer.expires = ktime_add_ns(ts->sched_timer.expires, offset);
 
        for (;;) {
                hrtimer_forward(&ts->sched_timer, now, tick_period);