Re: [PATCH v6 1/4] sched/clock: interface to allow timestamps early in boot

From: Thomas Gleixner
Date: Wed Oct 18 2017 - 17:02:35 EST


On Mon, 9 Oct 2017, Pavel Tatashin wrote:
> > Urgh, that's horrific.
> >
> > Can't we simply make sched_clock() go earlier? (we're violating "notsc"
> > in any case and really should kill that option).
> >
> > Then we can do something like so on top...
> >
>
> Hi Peter,
>
> I've been thinking about your proposal, and I have one concern: sched_clock()
> can be implemented two ways either via pv_time_ops.sched_clock vectors when
> CONFIG_PARAVIRT is defined
>
> sched_clock()
> paravirt_sched_clock()
> PVOP_CALL0(unsigned long long, pv_time_ops.sched_clock);
>
> Or native via alias
>
> sched_clock()
> native_sched_clock()
>
> Using sched_clock_early() approach makes early time stamps work with both
> cases when it is determined that tsc can be used simple_udelay_calibration().
> (As we agreed I am going to change notsc to use tsc=unstable path.)
>
> It may be not the most efficient clock for some virtualizations to use rdtsc
> directly, but since this is for early boot only, and not something that is
> going to be used after machine is booted it is OK.

The early boot time stamps are not really important for the production use
case where you care about performance.

So it's simple enough to refactor the code so it supports early time stamps
under the following conditons:

1) TSC is stable and constant frequency

2) TSC frequency is known early

3) paravirt sched clock is not used

- running on bare metal

- forcing the paravirt stuff to not override pv_time_ops.sched_clock
via an command line parameter

That's a valid restriction for the intended use case, i.e. timing of early
boot process.

Thanks,

tglx