Re: [RFC patch 0/4] TSC calibration improvements

From: Ingo Molnar
Date: Thu Sep 04 2008 - 16:43:44 EST



* Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

> + unsigned char expect = 0xfe;
> +
> + t1 = get_cycles();
> + for (expect = 0xfe, i = 0; i < QUICK_PIT_ITERATIONS; i++, expect--) {
> + if (!pit_expect_msb(expect))
> + goto failed;
> + }
> + t2 = get_cycles();

i suspect you didnt want the second initialization of 'expect' to 0xfe?
I fixed that up by removing the second one.

( although i think it would all be even clearer if we initialized
'expect' to 0xff before the first call of pit_expect_msb() higher up,
and then doing an expect-- before doing this loop - but that is really
painting the bikeshed i guess. )

> @@ -189,9 +300,15 @@ unsigned long native_calibrate_tsc(void)
> {
> u64 tsc1, tsc2, delta, pm1, pm2, hpet1, hpet2;
> unsigned long tsc_pit_min = ULONG_MAX, tsc_ref_min = ULONG_MAX;
> - unsigned long flags;
> + unsigned long flags, fast_calibrate;
> int hpet = is_hpet_enabled(), i;
>
> + local_irq_save(flags);
> + fast_calibrate = quick_pit_calibrate();
> + local_irq_restore(flags);
> + if (fast_calibrate)
> + return fast_calibrate;
> +
> /*
> * Run 5 calibration loops to get the lowest frequency value
> * (the best estimate). We use two different calibration modes

these bits collided with Thomas's textually but not conceptually: Thomas
improved the slowpath calibration while you introduced a new fastpath. I
kept both and applied your patch to tip/x86/tsc.

if you are happy with the commit below, could you please give your
Signed-off-by for it?

Ingo

-------------->