]>
Commit | Line | Data |
---|---|---|
5b31f822 GKH |
1 | From 6f103929f8979d2638e58d7f7fda0beefcb8ee7e Mon Sep 17 00:00:00 2001 |
2 | From: Neal Cardwell <ncardwell@google.com> | |
3 | Date: Tue, 27 Mar 2012 15:09:37 -0400 | |
4 | Subject: nohz: Fix stale jiffies update in tick_nohz_restart() | |
5 | ||
6 | From: Neal Cardwell <ncardwell@google.com> | |
7 | ||
8 | commit 6f103929f8979d2638e58d7f7fda0beefcb8ee7e upstream. | |
9 | ||
10 | Fix tick_nohz_restart() to not use a stale ktime_t "now" value when | |
11 | calling tick_do_update_jiffies64(now). | |
12 | ||
13 | If we reach this point in the loop it means that we crossed a tick | |
14 | boundary since we grabbed the "now" timestamp, so at this point "now" | |
15 | refers to a time in the old jiffy, so using the old value for "now" is | |
16 | incorrect, and is likely to give us a stale jiffies value. | |
17 | ||
18 | In particular, the first time through the loop the | |
19 | tick_do_update_jiffies64(now) call is always a no-op, since the | |
20 | caller, tick_nohz_restart_sched_tick(), will have already called | |
21 | tick_do_update_jiffies64(now) with that "now" value. | |
22 | ||
23 | Note that tick_nohz_stop_sched_tick() already uses the correct | |
24 | approach: when we notice we cross a jiffy boundary, grab a new | |
25 | timestamp with ktime_get(), and *then* update jiffies. | |
26 | ||
27 | Signed-off-by: Neal Cardwell <ncardwell@google.com> | |
28 | Cc: Ben Segall <bsegall@google.com> | |
29 | Cc: Ingo Molnar <mingo@elte.hu> | |
30 | Link: http://lkml.kernel.org/r/1332875377-23014-1-git-send-email-ncardwell@google.com | |
31 | Signed-off-by: Thomas Gleixner <tglx@linutronix.de> | |
32 | Signed-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 |