Skip to content

Commit

Permalink
time: Avoid making adjustments if we haven't accumulated anything
Browse files Browse the repository at this point in the history
commit bf2ac312195155511a0f79325515cbb61929898a upstream.

If update_wall_time() is called and the current offset isn't large
enough to accumulate, avoid re-calling timekeeping_adjust which may
change the clock freq and can cause 1ns inconsistencies with
CLOCK_REALTIME_COARSE/CLOCK_MONOTONIC_COARSE.

Signed-off-by: John Stultz <[email protected]>
Cc: Prarit Bhargava <[email protected]>
Cc: Ingo Molnar <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Thomas Gleixner <[email protected]>
Signed-off-by: John Stultz <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: D. Andrei Măceș <[email protected]>
  • Loading branch information
johnstultz-work authored and airend committed Mar 28, 2018
1 parent 1ee5de8 commit 77a56d2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -1119,9 +1119,12 @@ static void update_wall_time(void)
#else
offset = (clock->read(clock) - clock->cycle_last) & clock->mask;
#endif
/* Check if there's really nothing to do */
if (offset < timekeeper.cycle_interval)
goto out;

timekeeper.xtime_nsec = (s64)timekeeper.xtime.tv_nsec <<
timekeeper.shift;

/*
* With NO_HZ we may have to accumulate many cycle_intervals
* (think "ticks") worth of time at once. To do this efficiently,
Expand Down

0 comments on commit 77a56d2

Please sign in to comment.