xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Joao Martins <joao.m.martins@oracle.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v5 3/5] x86/time: implement tsc as clocksource
Date: Fri, 23 Sep 2016 08:58:23 -0600	[thread overview]
Message-ID: <57E55F2F0200007800112068@prv-mh.provo.novell.com> (raw)
In-Reply-To: <1474627367-8185-4-git-send-email-joao.m.martins@oracle.com>

>>> On 23.09.16 at 12:42, <joao.m.martins@oracle.com> wrote:
> Recent x86/time changes improved a lot of the monotonicity in xen
> timekeeping, making it much harder to observe time going backwards.
> Although platform timer can't be expected to be perfectly in sync with
> TSC and so get_s_time won't be guaranteed to always return
> monotonically increasing values across cpus. This is the case in some
> of the boxes I am testing with, observing sometimes ~100 warps (of
> very few nanoseconds each) after a few hours.
> 
> This patch introduces support for using TSC as platform time source
> which is the highest resolution time and most performant to get.
> Though there are also several problems associated with its usage, and
> there isn't a complete (and architecturally defined) guarantee that
> all machines will provide reliable and monotonic TSC in all cases (I
> believe Intel to be the only that can guarantee that?). For this reason
> it's not used unless administrator changes "clocksource" boot option
> to "tsc". Initializing TSC clocksource requires all CPUs up to have
> the tsc reliability checks performed. init_xen_time is called before
> all CPUs are up, so for example we would start with HPET (or ACPI,
> PIT) at boot time, and switch later to TSC. The switch then happens on
> verify_tsc_reliability initcall that is invoked when all CPUs are up.
> When attempting to initialize TSC we also check for time warps and if
> it has invariant TSC. Note that while we deem reliable a CONSTANT_TSC
> with no deep C-states, it might not always be the case, so we're
> conservative and allow TSC to be used as platform timer only with
> invariant TSC. Additionally we check if CPU Hotplug isn't meant to be
> performed on the host which will either be when max vcpus and
> num_present_cpu are the same. This is because a newly hotplugged CPU
> may not satisfy the condition of having all TSCs synchronized - so
> when having tsc clocksource being used we allow offlining CPUs but not
> onlining any ones back. Finally we prevent TSC from being used as
> clocksource on multiple sockets because it isn't guaranteed to be
> invariant. Further relaxing of this last requirement is added in a
> separate patch, such that we allow vendors with such guarantee to use
> TSC as clocksource. In case any of these conditions is not met, we
> keep the clocksource that was previously initialized on init_xen_time.
> 
> Since b64438c7c ("x86/time: use correct (local) time stamp in
> constant-TSC calibration fast path") updates to cpu time use local
> stamps, which means platform timer is only used to seed the initial
> cpu time. We further introduce a new rendezvous function
> (nop_rendezvous) which doesn't require synchronization between master
> and slave CPUS and just reads calibration_rendezvous struct and writes
> it down the stime and stamp to the cpu_calibration struct to be used
> later on. With clocksource=tsc there is no need to be in sync with
> another clocksource, so we reseed the local/master stamps to be values
> of TSC and update the platform time stamps accordingly. Time
> calibration is set to 1sec after we switch to TSC, thus these stamps
> are reseeded to also ensure monotonic returning values right after the
> point we switch to TSC. This is to remove the possibility of having
> inconsistent readings in this short period (i.e. until calibration
> fires).
> 
> Signed-off-by: Joao Martins <joao.m.martins@oracle.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

with one further adjustment (no need to re-send):

> --- a/docs/misc/xen-command-line.markdown
> +++ b/docs/misc/xen-command-line.markdown
> @@ -264,9 +264,13 @@ minimum of 32M, subject to a suitably aligned and sized contiguous
>  region of memory being available.
>  
>  ### clocksource
> -> `= pit | hpet | acpi`
> +> `= pit | hpet | acpi | tsc`
>  
>  If set, override Xen's default choice for the platform timer.
> +Having TSC as platform timer requires being explicitly set. This is because
> +TSC can only be safely used if CPU hotplug isn't performed on the system. In
> +some platforms, "maxcpus" parameter may require further adjustment to the
> +number of online cpus.

I think I'll re-write this last sentence to "On some platforms,
the "maxcpus" option may need to be used to further adjust the
number of allowed CPUs."

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-09-23 14:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-23 10:42 [PATCH v5 0/5] x86/time: PVCLOCK_TSC_STABLE_BIT support Joao Martins
2016-09-23 10:42 ` [PATCH v5 1/5] x86/time: refactor init_platform_time() Joao Martins
2016-09-23 10:42 ` [PATCH v5 2/5] x86/time: refactor read_platform_stime() Joao Martins
2016-09-23 10:42 ` [PATCH v5 3/5] x86/time: implement tsc as clocksource Joao Martins
2016-09-23 14:58   ` Jan Beulich [this message]
2016-09-23 10:42 ` [PATCH v5 4/5] x86/time: implement PVCLOCK_TSC_STABLE_BIT Joao Martins
2016-09-23 10:42 ` [PATCH v5 5/5] x86/time: extend "tsc" param with "stable:socket" Joao Martins
2016-09-23 15:00   ` Jan Beulich

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=57E55F2F0200007800112068@prv-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=joao.m.martins@oracle.com \
    --cc=xen-devel@lists.xenproject.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).