Re: [PATCH] tsc: make calibration refinement more robust

From: Daniel Vacek
Date: Mon Nov 05 2018 - 10:42:00 EST


On Sat, Nov 3, 2018 at 11:04 AM, Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
> Daniel,
>
> On Fri, 2 Nov 2018, Daniel Vacek wrote:
>> On Thu, Nov 1, 2018 at 4:34 PM, Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
>> >> -#define MAX_RETRIES 5
>> >> -#define SMI_TRESHOLD 50000
>> >> +#define MAX_RETRIES 5
>> >> +#define TSC_THRESHOLD (tsc_khz >> 5)
>> >
>> > This breaks pit_hpet_ptimer_calibrate_cpu() because at that point tsc_hkz is 0.
>>
>> That did not show up with my testing, sorry. I guess
>> pit_calibrate_tsc() never failed for me. Hmm, actually it looks like
>> quick_pit_calibrate() does the job for me so
>> pit_hpet_ptimer_calibrate_cpu() is likely not even called.
>
> Right. It's only called when quick calibration fails. Testing does not
> replace code inspection :)

Agreed. I was not 100% sure about this early init and order of
execution as it's dynamically changed with x86_platform.calibrate_cpu
and x86_platform.calibrate_tsc. Thanks again for the review, Thomas.

> Can you please avoid hiding the logic in a macro? Just use a local
> variable:
>
> u64 thresh = tsc_khz ? tsc_khz >> 5 : TSC_DEFAULT_THRESHOLD;
>
> and use that in the comparison.

Sweet, I'll do that :)

--nX

> Thanks,
>
> tglx