From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753136AbdBJIqs (ORCPT ); Fri, 10 Feb 2017 03:46:48 -0500 Received: from terminus.zytor.com ([65.50.211.136]:53874 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752644AbdBJIqm (ORCPT ); Fri, 10 Feb 2017 03:46:42 -0500 Date: Fri, 10 Feb 2017 00:45:56 -0800 From: tip-bot for Frederic Weisbecker Message-ID: Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, fweisbec@gmail.com, hpa@zytor.com, tglx@linutronix.de, riel@redhat.com, peterz@infradead.org Reply-To: mingo@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, hpa@zytor.com, fweisbec@gmail.com, peterz@infradead.org, riel@redhat.com In-Reply-To: <1486485894-29173-1-git-send-email-fweisbec@gmail.com> References: <1486485894-29173-1-git-send-email-fweisbec@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:timers/urgent] tick/nohz: Fix possible missing clock reprog after tick soft restart Git-Commit-ID: 7bdb59f1ad474bd7161adc8f923cdef10f2638d1 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 7bdb59f1ad474bd7161adc8f923cdef10f2638d1 Gitweb: http://git.kernel.org/tip/7bdb59f1ad474bd7161adc8f923cdef10f2638d1 Author: Frederic Weisbecker AuthorDate: Tue, 7 Feb 2017 17:44:54 +0100 Committer: Thomas Gleixner CommitDate: Fri, 10 Feb 2017 09:43:48 +0100 tick/nohz: Fix possible missing clock reprog after tick soft restart 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 Reviewed: Wanpeng Li Acked-by: Rik van Riel Cc: Peter Zijlstra 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 --- kernel/time/tick-sched.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 74e0388..fc6f740 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -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; } }