Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 312389
b: refs/heads/master
c: 1f4f948
h: refs/heads/master
i:
  312387: e014a71
v: v3
  • Loading branch information
John Stultz authored and Thomas Gleixner committed Jul 15, 2012
1 parent c527b62 commit 548789f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 23 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: 1e75fa8be9fb61e1af46b5b3b176347a4c958ca1
refs/heads/master: 1f4f948706bcec1b51bf6492bf04057d2e21e273
54 changes: 32 additions & 22 deletions trunk/kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,35 @@ static void timekeeping_adjust(s64 offset)
}


/**
* accumulate_nsecs_to_secs - Accumulates nsecs into secs
*
* Helper function that accumulates a the nsecs greater then a second
* from the xtime_nsec field to the xtime_secs field.
* It also calls into the NTP code to handle leapsecond processing.
*
*/
static inline void accumulate_nsecs_to_secs(struct timekeeper *tk)
{
u64 nsecps = (u64)NSEC_PER_SEC << tk->shift;

while (tk->xtime_nsec >= nsecps) {
int leap;

tk->xtime_nsec -= nsecps;
tk->xtime_sec++;

/* Figure out if its a leap sec and apply if needed */
leap = second_overflow(tk->xtime_sec);
tk->xtime_sec += leap;
tk->wall_to_monotonic.tv_sec -= leap;
if (leap)
clock_was_set_delayed();

}
}


/**
* logarithmic_accumulation - shifted accumulation of cycles
*
Expand All @@ -1001,7 +1030,6 @@ static void timekeeping_adjust(s64 offset)
*/
static cycle_t logarithmic_accumulation(cycle_t offset, u32 shift)
{
u64 nsecps = (u64)NSEC_PER_SEC << timekeeper.shift;
u64 raw_nsecs;

/* If the offset is smaller than a shifted interval, do nothing */
Expand All @@ -1013,16 +1041,8 @@ static cycle_t logarithmic_accumulation(cycle_t offset, u32 shift)
timekeeper.clock->cycle_last += timekeeper.cycle_interval << shift;

timekeeper.xtime_nsec += timekeeper.xtime_interval << shift;
while (timekeeper.xtime_nsec >= nsecps) {
int leap;
timekeeper.xtime_nsec -= nsecps;
timekeeper.xtime_sec++;
leap = second_overflow(timekeeper.xtime_sec);
timekeeper.xtime_sec += leap;
timekeeper.wall_to_monotonic.tv_sec -= leap;
if (leap)
clock_was_set_delayed();
}

accumulate_nsecs_to_secs(&timekeeper);

/* Accumulate raw time */
raw_nsecs = timekeeper.raw_interval << shift;
Expand Down Expand Up @@ -1132,17 +1152,7 @@ static void update_wall_time(void)
* Finally, make sure that after the rounding
* xtime_nsec isn't larger than NSEC_PER_SEC
*/
if (unlikely(timekeeper.xtime_nsec >=
((u64)NSEC_PER_SEC << timekeeper.shift))) {
int leap;
timekeeper.xtime_nsec -= (u64)NSEC_PER_SEC << timekeeper.shift;
timekeeper.xtime_sec++;
leap = second_overflow(timekeeper.xtime_sec);
timekeeper.xtime_sec += leap;
timekeeper.wall_to_monotonic.tv_sec -= leap;
if (leap)
clock_was_set_delayed();
}
accumulate_nsecs_to_secs(&timekeeper);

timekeeping_update(false);

Expand Down

0 comments on commit 548789f

Please sign in to comment.