Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 163067
b: refs/heads/master
c: 2ba2a30
h: refs/heads/master
i:
  163065: b0d4043
  163063: 84ca924
v: v3
  • Loading branch information
Martin Schwidefsky authored and Thomas Gleixner committed Aug 15, 2009
1 parent effad35 commit ba7e50f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 54 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: 0a54419836254a27baecd9037103171bcbabaf67
refs/heads/master: 2ba2a3054fdffc8e6452f4ee120760322a6fbd43
91 changes: 38 additions & 53 deletions trunk/kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,40 @@ static void timekeeper_setup_internals(struct clocksource *clock)
timekeeper.mult = clock->mult;
}

/* Timekeeper helper functions. */
static inline s64 timekeeping_get_ns(void)
{
cycle_t cycle_now, cycle_delta;
struct clocksource *clock;

/* read clocksource: */
clock = timekeeper.clock;
cycle_now = clock->read(clock);

/* calculate the delta since the last update_wall_time: */
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;

/* return delta convert to nanoseconds using ntp adjusted mult. */
return clocksource_cyc2ns(cycle_delta, timekeeper.mult,
timekeeper.shift);
}

static inline s64 timekeeping_get_ns_raw(void)
{
cycle_t cycle_now, cycle_delta;
struct clocksource *clock;

/* read clocksource: */
clock = timekeeper.clock;
cycle_now = clock->read(clock);

/* calculate the delta since the last update_wall_time: */
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;

/* return delta convert to nanoseconds using ntp adjusted mult. */
return clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift);
}

/*
* This read-write spinlock protects us from races in SMP while
* playing with xtime.
Expand Down Expand Up @@ -183,8 +217,6 @@ static void timekeeping_forward_now(void)
*/
void getnstimeofday(struct timespec *ts)
{
cycle_t cycle_now, cycle_delta;
struct clocksource *clock;
unsigned long seq;
s64 nsecs;

Expand All @@ -194,17 +226,7 @@ void getnstimeofday(struct timespec *ts)
seq = read_seqbegin(&xtime_lock);

*ts = xtime;

/* read clocksource: */
clock = timekeeper.clock;
cycle_now = clock->read(clock);

/* calculate the delta since the last update_wall_time: */
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;

/* convert to nanoseconds: */
nsecs = clocksource_cyc2ns(cycle_delta, timekeeper.mult,
timekeeper.shift);
nsecs = timekeeping_get_ns();

/* If arch requires, add in gettimeoffset() */
nsecs += arch_gettimeoffset();
Expand All @@ -218,8 +240,6 @@ EXPORT_SYMBOL(getnstimeofday);

ktime_t ktime_get(void)
{
cycle_t cycle_now, cycle_delta;
struct clocksource *clock;
unsigned int seq;
s64 secs, nsecs;

Expand All @@ -229,17 +249,7 @@ ktime_t ktime_get(void)
seq = read_seqbegin(&xtime_lock);
secs = xtime.tv_sec + wall_to_monotonic.tv_sec;
nsecs = xtime.tv_nsec + wall_to_monotonic.tv_nsec;

/* read clocksource: */
clock = timekeeper.clock;
cycle_now = clock->read(clock);

/* calculate the delta since the last update_wall_time: */
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;

/* convert to nanoseconds: */
nsecs += clocksource_cyc2ns(cycle_delta, timekeeper.mult,
timekeeper.shift);
nsecs += timekeeping_get_ns();

} while (read_seqretry(&xtime_lock, seq));
/*
Expand All @@ -260,8 +270,6 @@ EXPORT_SYMBOL_GPL(ktime_get);
*/
void ktime_get_ts(struct timespec *ts)
{
cycle_t cycle_now, cycle_delta;
struct clocksource *clock;
struct timespec tomono;
unsigned int seq;
s64 nsecs;
Expand All @@ -272,17 +280,7 @@ void ktime_get_ts(struct timespec *ts)
seq = read_seqbegin(&xtime_lock);
*ts = xtime;
tomono = wall_to_monotonic;

/* read clocksource: */
clock = timekeeper.clock;
cycle_now = clock->read(clock);

/* calculate the delta since the last update_wall_time: */
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;

/* convert to nanoseconds: */
nsecs = clocksource_cyc2ns(cycle_delta, timekeeper.mult,
timekeeper.shift);
nsecs = timekeeping_get_ns();

} while (read_seqretry(&xtime_lock, seq));

Expand Down Expand Up @@ -445,23 +443,10 @@ void getrawmonotonic(struct timespec *ts)
{
unsigned long seq;
s64 nsecs;
cycle_t cycle_now, cycle_delta;
struct clocksource *clock;

do {
seq = read_seqbegin(&xtime_lock);

/* read clocksource: */
clock = timekeeper.clock;
cycle_now = clock->read(clock);

/* calculate the delta since the last update_wall_time: */
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;

/* convert to nanoseconds: */
nsecs = clocksource_cyc2ns(cycle_delta, clock->mult,
clock->shift);

nsecs = timekeeping_get_ns_raw();
*ts = raw_time;

} while (read_seqretry(&xtime_lock, seq));
Expand Down

0 comments on commit ba7e50f

Please sign in to comment.