Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 72354
b: refs/heads/master
c: 8c66006
h: refs/heads/master
v: v3
  • Loading branch information
Dave Johnson authored and Thomas Gleixner committed Oct 23, 2007
1 parent 2480308 commit cc555a2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 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: edaf420fdc122e7a42326fe39274c8b8c9b19d41
refs/heads/master: 8c660065383976f09fbdae86c33448c8da643d4e
34 changes: 20 additions & 14 deletions trunk/arch/x86/kernel/tsc_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,31 +137,37 @@ unsigned long native_calculate_cpu_khz(void)

local_irq_save(flags);

/* run 3 times to ensure the cache is warm */
/* run 3 times to ensure the cache is warm and to get an accurate reading */
for (i = 0; i < 3; i++) {
mach_prepare_counter();
rdtscll(start);
mach_countup(&count);
rdtscll(end);

/*
* Error: ECTCNEVERSET
* The CTC wasn't reliable: we got a hit on the very first read,
* or the CPU was so fast/slow that the quotient wouldn't fit in
* 32 bits..
*/
if (count <= 1)
continue;

/* cpu freq too slow: */
if ((end - start) <= CALIBRATE_TIME_MSEC)
continue;

/*
* We want the minimum time of all runs in case one of them
* is inaccurate due to SMI or other delay
*/
delta64 = min(delta64, (end - start));
}
/*
* Error: ECTCNEVERSET
* The CTC wasn't reliable: we got a hit on the very first read,
* or the CPU was so fast/slow that the quotient wouldn't fit in
* 32 bits..
*/
if (count <= 1)
goto err;

/* cpu freq too fast: */
/* cpu freq too fast (or every run was bad): */
if (delta64 > (1ULL<<32))
goto err;

/* cpu freq too slow: */
if (delta64 <= CALIBRATE_TIME_MSEC)
goto err;

delta64 += CALIBRATE_TIME_MSEC/2; /* round for do_div */
do_div(delta64,CALIBRATE_TIME_MSEC);

Expand Down

0 comments on commit cc555a2

Please sign in to comment.