Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 178148
b: refs/heads/master
c: 83f57a1
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed Dec 22, 2009
1 parent e1cad1c commit 14142fd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 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: 0e2c8b8f55072a98b99e7bdad55c912084d6a526
refs/heads/master: 83f57a11d84460dfe2afdb5a8bc759953428e38b
1 change: 1 addition & 0 deletions trunk/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ static inline void warp_clock(void)
write_seqlock_irq(&xtime_lock);
wall_to_monotonic.tv_sec -= sys_tz.tz_minuteswest * 60;
xtime.tv_sec += sys_tz.tz_minuteswest * 60;
update_xtime_cache(0);
write_sequnlock_irq(&xtime_lock);
clock_was_set();
}
Expand Down
27 changes: 23 additions & 4 deletions trunk/kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ struct timespec raw_time;
/* flag for if timekeeping is suspended */
int __read_mostly timekeeping_suspended;

static struct timespec xtime_cache __attribute__ ((aligned (16)));
void update_xtime_cache(u64 nsec)
{
xtime_cache = xtime;
timespec_add_ns(&xtime_cache, nsec);
}

/* must hold xtime_lock */
void timekeeping_leap_insert(int leapsecond)
{
Expand Down Expand Up @@ -325,6 +332,8 @@ int do_settimeofday(struct timespec *tv)

xtime = *tv;

update_xtime_cache(0);

timekeeper.ntp_error = 0;
ntp_clear();

Expand Down Expand Up @@ -550,6 +559,7 @@ void __init timekeeping_init(void)
}
set_normalized_timespec(&wall_to_monotonic,
-boot.tv_sec, -boot.tv_nsec);
update_xtime_cache(0);
total_sleep_time.tv_sec = 0;
total_sleep_time.tv_nsec = 0;
write_sequnlock_irqrestore(&xtime_lock, flags);
Expand Down Expand Up @@ -583,6 +593,7 @@ static int timekeeping_resume(struct sys_device *dev)
wall_to_monotonic = timespec_sub(wall_to_monotonic, ts);
total_sleep_time = timespec_add_safe(total_sleep_time, ts);
}
update_xtime_cache(0);
/* re-base the last cycle value */
timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock);
timekeeper.ntp_error = 0;
Expand Down Expand Up @@ -722,6 +733,7 @@ static void timekeeping_adjust(s64 offset)
timekeeper.ntp_error_shift;
}


/**
* logarithmic_accumulation - shifted accumulation of cycles
*
Expand Down Expand Up @@ -765,6 +777,7 @@ static cycle_t logarithmic_accumulation(cycle_t offset, int shift)
return offset;
}


/**
* update_wall_time - Uses the current clocksource to increment the wall time
*
Expand All @@ -774,6 +787,7 @@ void update_wall_time(void)
{
struct clocksource *clock;
cycle_t offset;
u64 nsecs;
int shift = 0, maxshift;

/* Make sure we're fully resumed: */
Expand Down Expand Up @@ -839,6 +853,9 @@ void update_wall_time(void)
timekeeper.ntp_error += timekeeper.xtime_nsec <<
timekeeper.ntp_error_shift;

nsecs = clocksource_cyc2ns(offset, timekeeper.mult, timekeeper.shift);
update_xtime_cache(nsecs);

/* check to see if there is a new clocksource to use */
update_vsyscall(&xtime, timekeeper.clock, timekeeper.mult);
}
Expand Down Expand Up @@ -875,13 +892,13 @@ void monotonic_to_bootbased(struct timespec *ts)

unsigned long get_seconds(void)
{
return xtime.tv_sec;
return xtime_cache.tv_sec;
}
EXPORT_SYMBOL(get_seconds);

struct timespec __current_kernel_time(void)
{
return xtime;
return xtime_cache;
}

struct timespec current_kernel_time(void)
Expand All @@ -891,7 +908,8 @@ struct timespec current_kernel_time(void)

do {
seq = read_seqbegin(&xtime_lock);
now = xtime;

now = xtime_cache;
} while (read_seqretry(&xtime_lock, seq));

return now;
Expand All @@ -905,7 +923,8 @@ struct timespec get_monotonic_coarse(void)

do {
seq = read_seqbegin(&xtime_lock);
now = xtime;

now = xtime_cache;
mono = wall_to_monotonic;
} while (read_seqretry(&xtime_lock, seq));

Expand Down

0 comments on commit 14142fd

Please sign in to comment.