Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 116337
b: refs/heads/master
c: 1aa5dfb
h: refs/heads/master
i:
  116335: cbcada4
v: v3
  • Loading branch information
John Stultz authored and Ingo Molnar committed Aug 21, 2008
1 parent 00460ee commit 3e736d5
Show file tree
Hide file tree
Showing 4 changed files with 12 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: ee974e01e5ef2914036f08c8e41d1a3fa8bfc9d9
refs/heads/master: 1aa5dfb751d275ae7117d3b73ac423b4a46f2a73
11 changes: 7 additions & 4 deletions trunk/include/linux/clocksource.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ struct clocksource;
* @read: returns a cycle value
* @mask: bitmask for two's complement
* subtraction of non 64 bit counters
* @mult: cycle to nanosecond multiplier
* @mult: cycle to nanosecond multiplier (adjusted by NTP)
* @mult_orig: cycle to nanosecond multiplier (unadjusted by NTP)
* @shift: cycle to nanosecond divisor (power of two)
* @flags: flags describing special properties
* @vread: vsyscall based read
Expand All @@ -63,6 +64,7 @@ struct clocksource {
cycle_t (*read)(void);
cycle_t mask;
u32 mult;
u32 mult_orig;
u32 shift;
unsigned long flags;
cycle_t (*vread)(void);
Expand Down Expand Up @@ -201,16 +203,17 @@ static inline void clocksource_calculate_interval(struct clocksource *c,
{
u64 tmp;

/* XXX - All of this could use a whole lot of optimization */
/* Do the ns -> cycle conversion first, using original mult */
tmp = length_nsec;
tmp <<= c->shift;
tmp += c->mult/2;
do_div(tmp, c->mult);
tmp += c->mult_orig/2;
do_div(tmp, c->mult_orig);

c->cycle_interval = (cycle_t)tmp;
if (c->cycle_interval == 0)
c->cycle_interval = 1;

/* Go back from cycles -> shifted ns, this time use ntp adjused mult */
c->xtime_interval = (u64)c->cycle_interval * c->mult;
}

Expand Down
3 changes: 3 additions & 0 deletions trunk/kernel/time/clocksource.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ int clocksource_register(struct clocksource *c)
unsigned long flags;
int ret;

/* save mult_orig on registration */
c->mult_orig = c->mult;

spin_lock_irqsave(&clocksource_lock, flags);
ret = clocksource_enqueue(c);
if (!ret)
Expand Down
1 change: 1 addition & 0 deletions trunk/kernel/time/jiffies.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct clocksource clocksource_jiffies = {
.read = jiffies_read,
.mask = 0xffffffff, /*32bits*/
.mult = NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */
.mult_orig = NSEC_PER_JIFFY << JIFFIES_SHIFT,
.shift = JIFFIES_SHIFT,
};

Expand Down

0 comments on commit 3e736d5

Please sign in to comment.