diff options
author | John Stultz <john.stultz@linaro.org> | 2016-08-23 16:08:21 -0700 |
---|---|---|
committer | Sasha Levin <alexander.levin@verizon.com> | 2016-08-31 19:21:09 -0400 |
commit | 0c7b2c2aea55b4e940e3de8b41658855aebcbca4 (patch) | |
tree | 64e1b9a74e9fcca467204fcdb8f14a5eb19be1fe /kernel | |
parent | 2d701beb5dd816fa4c1115c88d464a6cc0e7271f (diff) |
timekeeping: Avoid taking lock in NMI path with CONFIG_DEBUG_TIMEKEEPING
[ Upstream commit 27727df240c7cc84f2ba6047c6f18d5addfd25ef ]
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 <rostedt@goodmis.org>
Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Cc: stable <stable@vger.kernel.org>
Link: http://lkml.kernel.org/r/1471993702-29148-2-git-send-email-john.stultz@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/time/timekeeping.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 65dbf8aee751..8fcc801fde15 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -419,7 +419,10 @@ static __always_inline u64 __ktime_get_fast_ns(struct tk_fast *tkf) do { seq = raw_read_seqcount(&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; |