OSDN Git Service

nohz: Fix spurious warning when hrtimer and clockevent get out of sync
authorFrederic Weisbecker <fweisbec@gmail.com>
Tue, 13 Jun 2017 04:04:14 +0000 (06:04 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 13 Jun 2017 06:45:43 +0000 (08:45 +0200)
commitd4af6d933ccffd24286528f04d5c39e702c8580f
treeee2805d4e80f4a2c0b3bf1332c402179ca83afe6
parentf99973e18b65ca1fff8c81532e3132b8f622aea8
nohz: Fix spurious warning when hrtimer and clockevent get out of sync

The sanity check ensuring that the tick expiry cache (ts->next_tick)
is actually in sync with the hardware clock (dev->next_event) makes the
wrong assumption that the clock can't be programmed later than the
hrtimer deadline.

In fact the clock hardware can be programmed later on some conditions
such as:

    * The hrtimer deadline is already in the past.
    * The hrtimer deadline is earlier than the minimum delay supported
      by the hardware.

Such conditions can be met when we program the tick, for example if the
last jiffies update hasn't been seen by the current CPU yet, we may
program the hrtimer to a deadline that is earlier than ktime_get()
because last_jiffies_update is our timestamp base to compute the next
tick.

As a result, we can randomly observe such warning:

WARNING: CPU: 5 PID: 0 at kernel/time/tick-sched.c:794 tick_nohz_stop_sched_tick kernel/time/tick-sched.c:791 [inline]
Call Trace:
 tick_nohz_irq_exit
 tick_irq_exit
 irq_exit
 exiting_irq
 smp_call_function_interrupt
 smp_call_function_single_interrupt
 call_function_single_interrupt

Therefore, let's rather make sure that the tick expiry cache is sync'ed
with the tick hrtimer deadline, against which it is not supposed to
drift away. The clock hardware instead has its own will and can't be
used as a reliable comparison point.

Reported-and-tested-by: Sasha Levin <alexander.levin@verizon.com>
Reported-and-tested-by: Abdul Haleem <abdhalee@linux.vnet.ibm.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: James Hartsock <hartsjc@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tim Wright <tim@binbash.co.uk>
Link: http://lkml.kernel.org/r/1497326654-14122-1-git-send-email-fweisbec@gmail.com
[ Minor readability edit. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/time/tick-sched.c