Re: [PATCH v14 20/25] x86/tsc: calibrate tsc only once

From: Thomas Gleixner
Date: Thu Jul 19 2018 - 12:20:24 EST


On Thu, 19 Jul 2018, Pavel Tatashin wrote:
> On 07/19/2018 07:01 AM, Thomas Gleixner wrote:
>
> And hpet_pmtime_calibrate_cpu() contains all the hpet/pmtime stuff.
>
> However, when cpu_khz = x86_platform.calibrate_cpu() is called the first
> time, we still call hpet_pmtime_calibrate_cpu() from
> native_calibrate_cpu(). We cannot simply split native_calibrate_cpu()
> into two independent functions because it is also called from
> recalibrate_cpu_khz().

> So, the question is how to enforce that the first time we do not call hpet/pmtime?
>
> 1. Use a new global variable? Kind of ugly.
> 2. Use system_state == SYSTEM_BOOTING ? Ugly, and probably not very safe.

Both are horrible.

So create two functions. native_...early..() and native....(). The early
one does not contain the hpet/pmtimer stuff and it replaces the ops.pointer
with the late one which contains all of it.

Hmm?

Thanks,

tglx