lkml.org 
[lkml]   [2011]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: x86: tsc: v2 make TSC calibration more immune to interrupts
On 04/21/2011 12:39 AM, Josh Triplett wrote:
>
> Have you considered disabling interrupts while calibrating? That would
> ensure that you only have to care about SMIs, not arbitrary interrupts.
>
> Also, on more recent x86 systems you could look at MSR_SMI_COUNT (MSR
> 0x34) to detect if any SMIs have occurred during the sample period.
> rdmsr, start sample period, stop sample period, rdmsr, if delta of 0
> then no SMIs occurred. Exists on Nehalem and newer, at least.


I have now tested this, and it is worth doing.

+ local_irq_save(flags);
t1 = get_cycles();
if (hpet)
tp = hpet_readl(HPET_COUNTER) & 0xFFFFFFFF;
else
tp = acpi_pm_read_early();
t2 = get_cycles();
+ local_irq_restore(flags);

On P3, when no SMI occur, the sample is now always perfect.
On Core2 there is still very rare variation - up to 8000 clock,
maybe bus contention?
Thinking it was cache I tried keeping irqs disabled for 5M
iterations, and that makes it occur _more_ often.

Atom shows the same as Core2, but even more rarely.

So, even if we have a Nehalem with SMI counter, the 5 samples
will still have benefit.


/Kasper Pedersen
--
This is my second patch ever, tell me when I do something wrong.


\
 
 \ /
  Last update: 2011-04-21 21:51    [W:0.258 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site