From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752987AbcHXHn3 (ORCPT ); Wed, 24 Aug 2016 03:43:29 -0400 Received: from terminus.zytor.com ([198.137.202.10]:41706 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751025AbcHXHnG (ORCPT ); Wed, 24 Aug 2016 03:43:06 -0400 Date: Wed, 24 Aug 2016 00:40:57 -0700 From: tip-bot for John Stultz Message-ID: Cc: tglx@linutronix.de, rostedt@goodmis.org, mingo@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, hpa@zytor.com, john.stultz@linaro.org, stable@vger.kernel.org Reply-To: stable@vger.kernel.org, john.stultz@linaro.org, hpa@zytor.com, linux-kernel@vger.kernel.org, peterz@infradead.org, rostedt@goodmis.org, mingo@kernel.org, tglx@linutronix.de In-Reply-To: <1471993702-29148-2-git-send-email-john.stultz@linaro.org> References: <1471993702-29148-2-git-send-email-john.stultz@linaro.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:timers/urgent] timekeeping: Avoid taking lock in NMI path with CONFIG_DEBUG_TIMEKEEPING Git-Commit-ID: 27727df240c7cc84f2ba6047c6f18d5addfd25ef 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: 27727df240c7cc84f2ba6047c6f18d5addfd25ef Gitweb: http://git.kernel.org/tip/27727df240c7cc84f2ba6047c6f18d5addfd25ef Author: John Stultz AuthorDate: Tue, 23 Aug 2016 16:08:21 -0700 Committer: Thomas Gleixner CommitDate: Wed, 24 Aug 2016 09:34:31 +0200 timekeeping: Avoid taking lock in NMI path with CONFIG_DEBUG_TIMEKEEPING When I added some extra sanity checking in timekeeping_get_ns() under CONFIG_DEBUG_TIMEKEEPING, I missed that the NMI safe __ktime_get_fast_ns() method was using timekeeping_get_ns(). Thus the locking added to the debug checks broke the NMI-safety of __ktime_get_fast_ns(). This patch open-codes the timekeeping_get_ns() logic for __ktime_get_fast_ns(), so can avoid any deadlocks in NMI. Fixes: 4ca22c2648f9 "timekeeping: Add warnings when overflows or underflows are observed" Reported-by: Steven Rostedt Reported-by: Peter Zijlstra Signed-off-by: John Stultz Cc: stable Link: http://lkml.kernel.org/r/1471993702-29148-2-git-send-email-john.stultz@linaro.org Signed-off-by: Thomas Gleixner --- kernel/time/timekeeping.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 3b65746..e07fb09 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -401,7 +401,10 @@ static __always_inline u64 __ktime_get_fast_ns(struct tk_fast *tkf) do { seq = raw_read_seqcount_latch(&tkf->seq); tkr = tkf->base + (seq & 0x01); - now = ktime_to_ns(tkr->base) + timekeeping_get_ns(tkr); + now = ktime_to_ns(tkr->base); + + now += clocksource_delta(tkr->read(tkr->clock), + tkr->cycle_last, tkr->mask); } while (read_seqcount_retry(&tkf->seq, seq)); return now;