aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/timekeeping.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index e91c29f961c9..5ecbfc39a268 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -454,7 +454,7 @@ void update_wall_time(void)
454#else 454#else
455 offset = clock->cycle_interval; 455 offset = clock->cycle_interval;
456#endif 456#endif
457 clock->xtime_nsec += (s64)xtime.tv_nsec << clock->shift; 457 clock->xtime_nsec = (s64)xtime.tv_nsec << clock->shift;
458 458
459 /* normally this loop will run just once, however in the 459 /* normally this loop will run just once, however in the
460 * case of lost or late ticks, it will accumulate correctly. 460 * case of lost or late ticks, it will accumulate correctly.
@@ -479,9 +479,12 @@ void update_wall_time(void)
479 /* correct the clock when NTP error is too big */ 479 /* correct the clock when NTP error is too big */
480 clocksource_adjust(offset); 480 clocksource_adjust(offset);
481 481
482 /* store full nanoseconds into xtime */ 482 /* store full nanoseconds into xtime after rounding it up and
483 xtime.tv_nsec = (s64)clock->xtime_nsec >> clock->shift; 483 * add the remainder to the error difference.
484 */
485 xtime.tv_nsec = ((s64)clock->xtime_nsec >> clock->shift) + 1;
484 clock->xtime_nsec -= (s64)xtime.tv_nsec << clock->shift; 486 clock->xtime_nsec -= (s64)xtime.tv_nsec << clock->shift;
487 clock->error += clock->xtime_nsec << (NTP_SCALE_SHIFT - clock->shift);
485 488
486 update_xtime_cache(cyc2ns(clock, offset)); 489 update_xtime_cache(cyc2ns(clock, offset));
487 490