summaryrefslogtreecommitdiffstats
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 e383bc7..42b81fa 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)
s64 delta = now - scd->prev_raw;
WARN_ON_ONCE(!irqs_disabled());
- min_clock = scd->tick_gtod + delta_jiffies * TICK_NSEC;
+
+ min_clock = scd->tick_gtod +
+ (delta_jiffies ? delta_jiffies - 1 : 0) * TICK_NSEC;
if (unlikely(delta < 0)) {
clock++;
goto out;
}
- max_clock = min_clock + TICK_NSEC;
+ /*
+ * The clock must stay within a jiffie of the gtod.
+ * But since we may be at the start of a jiffy or the end of one
+ * we add another jiffy buffer.
+ */
+ max_clock = scd->tick_gtod + (2 + delta_jiffies) * TICK_NSEC;
if (unlikely(clock + delta > max_clock)) {
if (clock < max_clock)
OpenPOWER on IntegriCloud