Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 288767
b: refs/heads/master
c: 9993bc6
h: refs/heads/master
i:
  288765: cb5407f
  288763: 569c3f9
  288759: 96e0235
  288751: b9a20c8
  288735: 373226b
  288703: 783d171
  288639: 04077cd
  288511: c86ec1a
  288255: 5852ec8
  287743: 4f58ce1
  286719: 66d4c0f
v: v3
  • Loading branch information
Salman Qazi authored and Ingo Molnar committed Mar 13, 2012
1 parent e21f3bc commit 8bd0fe7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 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: 47258cf3c4aa5d56e678bafe0dd0d03ddd980b88
refs/heads/master: 9993bc635d01a6ee7f6b833b4ee65ce7c06350b1
8 changes: 2 additions & 6 deletions trunk/arch/x86/include/asm/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,10 @@ DECLARE_PER_CPU(unsigned long long, cyc2ns_offset);

static inline unsigned long long __cycles_2_ns(unsigned long long cyc)
{
unsigned long long quot;
unsigned long long rem;
int cpu = smp_processor_id();
unsigned long long ns = per_cpu(cyc2ns_offset, cpu);
quot = (cyc >> CYC2NS_SCALE_FACTOR);
rem = cyc & ((1ULL << CYC2NS_SCALE_FACTOR) - 1);
ns += quot * per_cpu(cyc2ns, cpu) +
((rem * per_cpu(cyc2ns, cpu)) >> CYC2NS_SCALE_FACTOR);
ns += mult_frac(cyc, per_cpu(cyc2ns, cpu),
(1UL << CYC2NS_SCALE_FACTOR));
return ns;
}

Expand Down
3 changes: 2 additions & 1 deletion trunk/arch/x86/kernel/tsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,8 @@ static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu)

if (cpu_khz) {
*scale = (NSEC_PER_MSEC << CYC2NS_SCALE_FACTOR)/cpu_khz;
*offset = ns_now - (tsc_now * *scale >> CYC2NS_SCALE_FACTOR);
*offset = ns_now - mult_frac(tsc_now, *scale,
(1UL << CYC2NS_SCALE_FACTOR));
}

sched_clock_idle_wakeup_event(0);
Expand Down
13 changes: 13 additions & 0 deletions trunk/include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@
} \
)

/*
* Multiplies an integer by a fraction, while avoiding unnecessary
* overflow or loss of precision.
*/
#define mult_frac(x, numer, denom)( \
{ \
typeof(x) quot = (x) / (denom); \
typeof(x) rem = (x) % (denom); \
(quot * (numer)) + ((rem * (numer)) / (denom)); \
} \
)


#define _RET_IP_ (unsigned long)__builtin_return_address(0)
#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })

Expand Down

0 comments on commit 8bd0fe7

Please sign in to comment.