]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
tick/nohz: Fix possible missing clock reprog after tick soft restart
authorFrederic Weisbecker <fweisbec@gmail.com>
Tue, 7 Feb 2017 16:44:54 +0000 (17:44 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 10 Feb 2017 08:43:48 +0000 (09:43 +0100)
ts->next_tick keeps track of the next tick deadline in order to optimize
clock programmation on irq exit and avoid redundant clock device writes.

Now if ts->next_tick missed an update, we may spuriously miss a clock
reprog later as the nohz code is fooled by an obsolete next_tick value.

This is what happens here on a specific path: when we observe an
expired timer from the nohz update code on irq exit, we perform a soft
tick restart which simply fires the closest possible tick without
actually exiting the nohz mode and restoring a periodic state. But we
forget to update ts->next_tick accordingly.

As a result, after the next tick resulting from such soft tick restart,
the nohz code sees a stale value on ts->next_tick which doesn't match
the clock deadline that just expired. If that obsolete ts->next_tick
value happens to collide with the actual next tick deadline to be
scheduled, we may spuriously bypass the clock reprogramming. In the
worst case, the tick may never fire again.

Fix this with a ts->next_tick reset on soft tick restart.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Reviewed: Wanpeng Li <wanpeng.li@hotmail.com>
Acked-by: Rik van Riel <riel@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/1486485894-29173-1-git-send-email-fweisbec@gmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kernel/time/tick-sched.c

index 74e0388cc88d4d17b340d102ec8e053257d6ef55..fc6f740d02771284d18791633c6740861574a105 100644 (file)
@@ -725,6 +725,11 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,
                 */
                if (delta == 0) {
                        tick_nohz_restart(ts, now);
+                       /*
+                        * Make sure next tick stop doesn't get fooled by past
+                        * clock deadline
+                        */
+                       ts->next_tick = 0;
                        goto out;
                }
        }