Re: [PATCH v10 7/7] x86/tsc: use tsc early

From: Thomas Gleixner
Date: Tue Jun 19 2018 - 18:53:00 EST


On Fri, 15 Jun 2018, Pavel Tatashin wrote:
> This patch adds early clock feature to x86 platforms.

See Documentation about 'This patch' .... We already know that this is a
patch otherwise it would not be marked as such ...

> +/*
> + * Finish clock for early time stamps, and hand over to permanent clock by
> + * setting __sched_clock_offset appropriately for continued time keeping.
> + */
> +static void __init tsc_early_fini(void)
> +{
> + unsigned long long t;
> + unsigned long r;
> +
> + t = -cyc2ns_early.cyc2ns_offset;
> + r = do_div(t, NSEC_PER_SEC);
> +
> + __sched_clock_offset = sched_clock_early() - sched_clock();

As this is called _AFTER_ the TSC initialization which also includes
sanitizing of TSC_ADJUST, this can result in a complete bogus
__sched_clock_offset because sched_clock_early() will return nonsense when
TSC_ADJUST has been modified.

> + pr_info("early sched clock is finished, offset [%lld.%09lds]\n", t, r);

That only gives useful information when the machine boots cold and when the
machine has a sane BIOS. So it's almost guaranteed to print useless
information.

Thanks,

tglx