Skip to contentSkip to conversation

Platform SMIs and their interferance with tsc based delay calibration

Discuss Martin Wilck 1 participant 2 messages Jan 31, 2005 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 11 lines · Venkatesh Pallipadi

(0) Estimate a value for loops_per_jiffy
(1) While (loops_per_jiffy estimate is accurate enough)

(2)   wait for jiffy transition (jiffy1)
(3)   Note down current tsc (tsc1)
(4)   loop until tsc becomes tsc1 + loops_per_jiffy
(5)   check whether jiffy changed since jiffy1 or not 

and refine loops_per_jiffy estimate

Case 2: If SMIs happen between (3) and (4) above, then we can end up with a loops_per_jiffy value that is too high.

I don't think this can really happen (at least not on the bootstrap CPU) because even if an SMI occurs, the CPU must first serve the timer interrupt and increment jiffies before it continues looping.

However "LPJ too short" is what needs to be avoided at all cost.

Regards and thanks for working on this problem,
Martin

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 1 line · Linus Torvalds

In particular, I don't see why you didn't just put this in the generic calibrate_delay() routine. You seem to have basically duplicated it, and added the "guess from an external timer" code - and I don't see what's non-generic about that, except for some trivial "what's the current timer" lookup.

The trivial lookup is hidden in the __delay() function. Making it return the number of "loops" it actually waited would help having a robust generic code.

Regards
Martin