Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 312391
b: refs/heads/master
c: 2a8c088
h: refs/heads/master
i:
  312389: 548789f
  312387: e014a71
  312383: b3b0df5
v: v3
  • Loading branch information
John Stultz authored and Thomas Gleixner committed Jul 15, 2012
1 parent a3ef2f4 commit 1ddc2f7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f2a5a0854efc62abe7f69e9947842cb135837f9a
refs/heads/master: 2a8c0883c3cfffcc148ea606e2a4e7453cd75e73
42 changes: 21 additions & 21 deletions trunk/kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,27 @@ static void timekeeping_adjust(s64 offset)
timekeeper.xtime_nsec -= offset;
timekeeper.ntp_error -= (interval - offset) <<
timekeeper.ntp_error_shift;

/*
* It may be possible that when we entered this function, xtime_nsec
* was very small. Further, if we're slightly speeding the clocksource
* in the code above, its possible the required corrective factor to
* xtime_nsec could cause it to underflow.
*
* Now, since we already accumulated the second, 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)timekeeper.xtime_nsec < 0)) {
s64 neg = -(s64)timekeeper.xtime_nsec;
timekeeper.xtime_nsec = 0;
timekeeper.ntp_error += neg << timekeeper.ntp_error_shift;
}

}


Expand Down Expand Up @@ -1105,27 +1126,6 @@ static void update_wall_time(void)
/* correct the clock when NTP error is too big */
timekeeping_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 timekeeping_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)timekeeper.xtime_nsec < 0)) {
s64 neg = -(s64)timekeeper.xtime_nsec;
timekeeper.xtime_nsec = 0;
timekeeper.ntp_error += neg << timekeeper.ntp_error_shift;
}

/*
* Store only full nanoseconds into xtime_nsec after rounding
Expand Down

0 comments on commit 1ddc2f7

Please sign in to comment.