Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 119707
b: refs/heads/master
c: 6c9bacb
h: refs/heads/master
i:
  119705: 8a37606
  119703: 9431ac9
v: v3
  • Loading branch information
john stultz authored and Ingo Molnar committed Dec 4, 2008
1 parent f93a2b1 commit 797bf83
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: eccdaeafaea3ed115068ba55d01f22e486e5437d
refs/heads/master: 6c9bacb41c10ba84ff68f238e234d96f35fb64f7
22 changes: 22 additions & 0 deletions trunk/kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,28 @@ void update_wall_time(void)
/* correct the clock when NTP error is too big */
clocksource_adjust(offset);

/*
* Since in the loop above, we accumulate any amount of time
* in xtime_nsec over a second into xtime.tv_sec, its possible for
* xtime_nsec to be fairly small after the loop. Further, if we're
* slightly speeding the clocksource up in clocksource_adjust(),
* its possible the required corrective factor to xtime_nsec could
* cause it to underflow.
*
* Now, we cannot simply roll the accumulated second back, since
* the NTP subsystem has been notified via second_overflow. So
* instead we push xtime_nsec forward by the amount we underflowed,
* and add that amount into the error.
*
* We'll correct this error next time through this function, when
* xtime_nsec is not as small.
*/
if (unlikely((s64)clock->xtime_nsec < 0)) {
s64 neg = -(s64)clock->xtime_nsec;
clock->xtime_nsec = 0;
clock->error += neg << (NTP_SCALE_SHIFT - clock->shift);
}

/* store full nanoseconds into xtime after rounding it up and
* add the remainder to the error difference.
*/
Expand Down

0 comments on commit 797bf83

Please sign in to comment.