aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched_clock.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched_clock.c')
-rw-r--r--kernel/sched_clock.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/kernel/sched_clock.c b/kernel/sched_clock.c
index e383bc7df6dd..42b81fa38cbd 100644
--- a/kernel/sched_clock.c
+++ b/kernel/sched_clock.c
@@ -96,14 +96,21 @@ static void __update_sched_clock(struct sched_clock_data *scd, u64 now)
96 s64 delta = now - scd->prev_raw; 96 s64 delta = now - scd->prev_raw;
97 97
98 WARN_ON_ONCE(!irqs_disabled()); 98 WARN_ON_ONCE(!irqs_disabled());
99 min_clock = scd->tick_gtod + delta_jiffies * TICK_NSEC; 99
100 min_clock = scd->tick_gtod +
101 (delta_jiffies ? delta_jiffies - 1 : 0) * TICK_NSEC;
100 102
101 if (unlikely(delta < 0)) { 103 if (unlikely(delta < 0)) {
102 clock++; 104 clock++;
103 goto out; 105 goto out;
104 } 106 }
105 107
106 max_clock = min_clock + TICK_NSEC; 108 /*
109 * The clock must stay within a jiffie of the gtod.
110 * But since we may be at the start of a jiffy or the end of one
111 * we add another jiffy buffer.
112 */
113 max_clock = scd->tick_gtod + (2 + delta_jiffies) * TICK_NSEC;
107 114
108 if (unlikely(clock + delta > max_clock)) { 115 if (unlikely(clock + delta > max_clock)) {
109 if (clock < max_clock) 116 if (clock < max_clock)