]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.0.29/nohz-fix-stale-jiffies-update-in-tick_nohz_restart.patch
Linux 5.1.3
[thirdparty/kernel/stable-queue.git] / releases / 3.0.29 / nohz-fix-stale-jiffies-update-in-tick_nohz_restart.patch
CommitLineData
5b31f822
GKH
1From 6f103929f8979d2638e58d7f7fda0beefcb8ee7e Mon Sep 17 00:00:00 2001
2From: Neal Cardwell <ncardwell@google.com>
3Date: Tue, 27 Mar 2012 15:09:37 -0400
4Subject: nohz: Fix stale jiffies update in tick_nohz_restart()
5
6From: Neal Cardwell <ncardwell@google.com>
7
8commit 6f103929f8979d2638e58d7f7fda0beefcb8ee7e upstream.
9
10Fix tick_nohz_restart() to not use a stale ktime_t "now" value when
11calling tick_do_update_jiffies64(now).
12
13If we reach this point in the loop it means that we crossed a tick
14boundary since we grabbed the "now" timestamp, so at this point "now"
15refers to a time in the old jiffy, so using the old value for "now" is
16incorrect, and is likely to give us a stale jiffies value.
17
18In particular, the first time through the loop the
19tick_do_update_jiffies64(now) call is always a no-op, since the
20caller, tick_nohz_restart_sched_tick(), will have already called
21tick_do_update_jiffies64(now) with that "now" value.
22
23Note that tick_nohz_stop_sched_tick() already uses the correct
24approach: when we notice we cross a jiffy boundary, grab a new
25timestamp with ktime_get(), and *then* update jiffies.
26
27Signed-off-by: Neal Cardwell <ncardwell@google.com>
28Cc: Ben Segall <bsegall@google.com>
29Cc: Ingo Molnar <mingo@elte.hu>
30Link: http://lkml.kernel.org/r/1332875377-23014-1-git-send-email-ncardwell@google.com
31Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
32Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
33
34---
35 kernel/time/tick-sched.c | 4 ++--
36 1 file changed, 2 insertions(+), 2 deletions(-)
37
38--- a/kernel/time/tick-sched.c
39+++ b/kernel/time/tick-sched.c
40@@ -484,9 +484,9 @@ static void tick_nohz_restart(struct tic
41 hrtimer_get_expires(&ts->sched_timer), 0))
42 break;
43 }
44- /* Update jiffies and reread time */
45- tick_do_update_jiffies64(now);
46+ /* Reread time and update jiffies */
47 now = ktime_get();
48+ tick_do_update_jiffies64(now);
49 }
50 }
51