All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Tatashin <pasha.tatashin@oracle.com>
To: tglx@linutronix.de
Cc: Steven Sistare <steven.sistare@oracle.com>,
	Daniel Jordan <daniel.m.jordan@oracle.com>,
	linux@armlinux.org.uk, schwidefsky@de.ibm.com,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	John Stultz <john.stultz@linaro.org>,
	sboyd@codeaurora.org, x86@kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	mingo@redhat.com, hpa@zytor.com, douly.fnst@cn.fujitsu.com,
	peterz@infradead.org, prarit@redhat.com, feng.tang@intel.com,
	Petr Mladek <pmladek@suse.com>,
	gnomes@lxorguk.ukuu.org.uk, linux-s390@vger.kernel.org
Subject: Re: [PATCH v12 09/11] x86/tsc: prepare for early sched_clock
Date: Tue, 26 Jun 2018 15:47:51 -0400	[thread overview]
Message-ID: <CAGM2rebiy7fMssEvnxj9DLNN-SGzgULh7iuMfe4=dgF89H5DFQ@mail.gmail.com> (raw)
In-Reply-To: <CAGM2reYQ23XhQHAOO0Oo8MGvgrjpNZPZkwp+wwsU8Fb+jfANyA@mail.gmail.com>

On Tue, Jun 26, 2018 at 2:42 PM Pavel Tatashin
<pasha.tatashin@oracle.com> wrote:
>
> Hi Thomas,
>
> On Tue, Jun 26, 2018 at 11:44 AM Thomas Gleixner <tglx@linutronix.de> wrote:
> >
> > Pavel,
> >
> > first of all, sorry for my last outburst. I just was in a lousy mood after
> > staring into too much half baken stuff and failed to make myself stay away
> > from the computer.
>
> Thank you.
>
> >
> > On Sun, 24 Jun 2018, Thomas Gleixner wrote:
> > > On Sat, 23 Jun 2018, Pavel Tatashin wrote:
> > > And this early init sequence also needs to pull over the tsc adjust
> > > magic. So tsc_early_delay_calibrate() which should btw. be renamed to
> > > tsc_early_init() should have:
> > >
> > > {
> > >       cpu_khz = x86_platform.calibrate_cpu();
> > >         tsc_khz = x86_platform.calibrate_tsc();
> > >
> > >         tsc_khz = tsc_khz ? : cpu_khz;
> > >         if (!tsc_khz)
> > >                 return;
> > >
> > >         /* Sanitize TSC ADJUST before cyc2ns gets initialized */
> > >         tsc_store_and_check_tsc_adjust(true);
> > >
> > >       calc_lpj(tsc_khz);
> > >
> > >       tsc_sched_clock_init();
> > > }
> >
> > Peter made me look deeper into this and there are a few issues, which I
> > missed, depending on when some of the resources become available. So we
> > probably cannot hook all of this into tsc_early_delay_calibrate().
> >
> > I have an idea how to distangle it and we'll end up in a staged approach,
> > which looks like this:
> >
> >     1) Earliest one (not sure how early yet)
> >
> >        Attempt to use MSR/CPUID. If not running on a hypervisor this can
> >        try the quick PIT calibration, but nothing else.
> >
> >     2) Post init_hypervisor_platform()
> >
> >        An attempt to use the hypervisor data can be made.
> >
> >     3) Post early_acpi_boot_init()
> >
> >        This can do PIT/HPET based calibration
> >
> >     4) Post x86_dtb_init()
> >
> >        PIT/PMTIMER based calibration
> >
> > Once tsc_khz is known, no further attempts of calibration are made. I'll
> > look into that later tonight.
>
> I think, there are no reasons to try staged attempts. It usually gets
> harder to maintain overtime. In my opinion it is best if do it in two
> tries, as right now, but just cleaner. The first attempt we get a
> crude result, using the lowest denominator to which current logic
> might fallback if something else is not available that early in boot:
> i.e cpu calibration loop in native_calibrate_cpu() but later get
> something better. Also, even if early clock does not work because we
> could not get tsc early, it is not a problem, we still will probably
> determine it later during tsc_init call.

Actually, nevermind, I looked through the code again, it seems that if
we get early tsc frequency we can keep it, but otherwise just try it
again at later time when in tsc_init(). So, no need for
cyc2ns_reinit_boot(). I still think no need for staged attempts, but
try in two different places: in tsc_init_early() -> works? use that
tsc frequency later, does not try again in tsc_init(), and use the new
one.

In tsc_init we can have something like this:
void __init tsc_init(void)
{
        if (!boot_cpu_has(X86_FEATURE_TSC))
                return;

        /* See if we were not able to determine tsc frequency early,
but can now */
        if (!tsc_khz && determine_cpu_tsc_frequncies()) {
              /* Sanitize TSC ADJUST before cyc2ns gets initialized */
              tsc_store_and_check_tsc_adjust(true);
               cyc2ns_init_boot_cpu();
        }
        ....

}

Pavel

  reply	other threads:[~2018-06-26 19:47 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-21 21:25 [PATCH v12 00/11] Early boot time stamps for x86 Pavel Tatashin
2018-06-21 21:25 ` [PATCH v12 01/11] x86: text_poke() may access uninitialized struct pages Pavel Tatashin
2018-06-21 21:37   ` Randy Dunlap
2018-06-25  8:14   ` Peter Zijlstra
2018-06-25  8:39     ` Thomas Gleixner
2018-06-25  9:09       ` Peter Zijlstra
2018-06-25  9:18         ` Thomas Gleixner
2018-06-25  9:22           ` Peter Zijlstra
2018-06-25 12:32             ` Pavel Tatashin
2018-06-25 13:48               ` Peter Zijlstra
2018-06-25 14:06                 ` Pavel Tatashin
2018-06-21 21:25 ` [PATCH v12 02/11] x86: initialize static branching early Pavel Tatashin
2018-06-23  9:16   ` Borislav Petkov
2018-06-23 13:11     ` Pavel Tatashin
2018-06-21 21:25 ` [PATCH v12 03/11] x86/tsc: redefine notsc to behave as tsc=unstable Pavel Tatashin
2018-06-23 13:32   ` Thomas Gleixner
2018-06-21 21:25 ` [PATCH v12 04/11] kvm/x86: remove kvm memblock dependency Pavel Tatashin
2018-06-23 13:36   ` Thomas Gleixner
2018-07-05 16:12   ` Paolo Bonzini
2018-07-06  9:24     ` Thomas Gleixner
2018-07-06  9:36       ` Paolo Bonzini
2018-07-06  9:45         ` Thomas Gleixner
2018-07-06 10:08           ` Paolo Bonzini
2018-07-06 10:44             ` Thomas Gleixner
2018-07-06 10:50               ` Thomas Gleixner
2018-07-06 15:03                 ` Pavel Tatashin
2018-07-06 15:09                   ` Paolo Bonzini
2018-06-21 21:25 ` [PATCH v12 05/11] s390/time: add read_persistent_wall_and_boot_offset() Pavel Tatashin
2018-06-25  7:07   ` Martin Schwidefsky
2018-06-25 12:45     ` Pavel Tatashin
2018-06-21 21:25 ` [PATCH v12 06/11] time: replace read_boot_clock64() with read_persistent_wall_and_boot_offset() Pavel Tatashin
2018-06-23 13:49   ` Thomas Gleixner
2018-06-21 21:25 ` [PATCH v12 07/11] s390/time: remove read_boot_clock64() Pavel Tatashin
2018-06-21 21:25 ` [PATCH v12 08/11] ARM/time: " Pavel Tatashin
2018-06-23 13:52   ` Thomas Gleixner
2018-06-21 21:25 ` [PATCH v12 09/11] x86/tsc: prepare for early sched_clock Pavel Tatashin
2018-06-23 16:50   ` Thomas Gleixner
2018-06-23 18:49     ` Pavel Tatashin
2018-06-23 20:11     ` Thomas Gleixner
2018-06-23 21:29       ` Pavel Tatashin
2018-06-23 23:38         ` Thomas Gleixner
2018-06-24  2:43           ` Pavel Tatashin
2018-06-24  7:30             ` Thomas Gleixner
2018-06-26 15:42           ` Thomas Gleixner
2018-06-26 18:42             ` Pavel Tatashin
2018-06-26 19:47               ` Pavel Tatashin [this message]
2018-06-28  7:31               ` Thomas Gleixner
2018-06-28 10:43                 ` Thomas Gleixner
2018-06-28 11:46                   ` Peter Zijlstra
2018-06-28 12:27                     ` Thomas Gleixner
2018-06-28 19:42                   ` Pavel Tatashin
2018-06-29  7:30                     ` Thomas Gleixner
2018-06-29  8:57                       ` Pavel Tatashin
2018-07-03 20:59                         ` Thomas Gleixner
2018-07-02 17:18                       ` Konrad Rzeszutek Wilk
2018-06-29 14:30                   ` Andy Shevchenko
2018-06-29 17:50                     ` Andy Shevchenko
2018-07-09 23:16                   ` Boris Ostrovsky
2018-06-21 21:25 ` [PATCH v12 10/11] sched: early boot clock Pavel Tatashin
2018-06-25  8:55   ` Peter Zijlstra
2018-06-25 12:44     ` Pavel Tatashin
2018-06-25 19:23     ` Pavel Tatashin
2018-06-26  9:00       ` Peter Zijlstra
2018-06-26 11:27         ` Pavel Tatashin
2018-06-26 11:51           ` Pavel Tatashin
2018-06-26 15:07           ` Peter Zijlstra
2018-06-21 21:25 ` [PATCH v12 11/11] x86/tsc: use tsc early Pavel Tatashin
2018-06-23 16:56   ` Thomas Gleixner
2018-06-23 21:38     ` Pavel Tatashin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGM2rebiy7fMssEvnxj9DLNN-SGzgULh7iuMfe4=dgF89H5DFQ@mail.gmail.com' \
    --to=pasha.tatashin@oracle.com \
    --cc=daniel.m.jordan@oracle.com \
    --cc=douly.fnst@cn.fujitsu.com \
    --cc=feng.tang@intel.com \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hpa@zytor.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=prarit@redhat.com \
    --cc=sboyd@codeaurora.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=steven.sistare@oracle.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.