From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
"Andrew Cooper" <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>,
Claudemir Todo Bom <claudemir@todobom.com>
Subject: Re: [PATCH v2 3/3] x86/time: don't move TSC backwards in time_calibration_tsc_rendezvous()
Date: Mon, 8 Feb 2021 14:19:26 +0100 [thread overview]
Message-ID: <YCE6XlA14A2Qsq8H@Air-de-Roger> (raw)
In-Reply-To: <ae8d8e02-9d2e-a26e-9321-cae0640a0dee@suse.com>
On Mon, Feb 08, 2021 at 12:22:25PM +0100, Jan Beulich wrote:
> On 08.02.2021 10:38, Roger Pau Monné wrote:
> > On Mon, Feb 01, 2021 at 01:43:28PM +0100, Jan Beulich wrote:
> >> ---
> >> Since CPU0 reads its TSC last on the first iteration, if TSCs were
> >> perfectly sync-ed there shouldn't ever be a need to update. However,
> >> even on the TSC-reliable system I first tested this on (using
> >> "tsc=skewed" to get this rendezvous function into use in the first
> >> place) updates by up to several thousand clocks did happen. I wonder
> >> whether this points at some problem with the approach that I'm not (yet)
> >> seeing.
> >
> > I'm confused by this, so on a system that had reliable TSCs, which
> > you forced to remove the reliable flag, and then you saw big
> > differences when doing the rendezvous?
> >
> > That would seem to indicate that such system doesn't really have
> > reliable TSCs?
>
> I don't think so, no. This can easily be a timing effect from the
> heavy cache line bouncing involved here.
>
> What I'm worried here seeing these updates is that I might still
> be moving TSCs backwards in ways observable to the rest of the
> system (i.e. beyond the inherent property of the approach), and
> this then getting corrected by a subsequent rendezvous. But as
> said - I can't see what this could result from, and hence I'm
> inclined to assume these are merely effects I've not found a
> good explanation for so far.
I'm slightly worried by this, maybe because I'm misunderstanding part
of the TSC sync stuff.
So you forced a system that Xen would otherwise consider to have a
reliable TSC (one that doesn't need a calibration rendezvous) into
doing the calibration rendezvous, and then the skew seen is quite big.
I would expect such skew to be minimal? As we would otherwise consider
the system to not need calibration at all.
This makes me wonder if the system does indeed need such calibration
(which I don't think so), or if the calibration that we actually try
to do is quite bogus?
> >> @@ -1719,9 +1737,12 @@ static void time_calibration_tsc_rendezv
> >> while ( atomic_read(&r->semaphore) > total_cpus )
> >> cpu_relax();
> >> }
> >> +
> >> + /* Just in case a read above ended up reading zero. */
> >> + tsc += !tsc;
> >
> > Won't that be worthy of an ASSERT_UNREACHABLE? I'm not sure I see how
> > tsc could be 0 on a healthy system after the loop above.
>
> It's not forbidden for the firmware to set the TSCs to some
> huge negative value. Considering the effect TSC_ADJUST has on
> the actual value read by RDTSC, I think I did actually observe
> a system coming up this way, because of (not very helpful)
> TSC_ADJUST setting by firmware. So no, no ASSERT_UNREACHABLE()
> here.
But then the code here will loop 5 times, and it's not possible for
those 5 loops to read a TSC value of 0? I could see it reading 0 on
one of the iterations but not in all of them.
Thanks, Roger.
next prev parent reply other threads:[~2021-02-08 13:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-01 12:41 [PATCH v2 0/3] x86/time: calibration rendezvous adjustments Jan Beulich
2021-02-01 12:42 ` [PATCH v2 1/3] x86/time: change initiation of the calibration timer Jan Beulich
2021-02-05 16:00 ` Roger Pau Monné
2021-02-01 12:43 ` [PATCH v2 2/3] x86/time: adjust time recording time_calibration_tsc_rendezvous() Jan Beulich
2021-02-05 16:15 ` Roger Pau Monné
2021-02-08 10:56 ` Jan Beulich
2021-02-08 11:05 ` Roger Pau Monné
2021-02-08 11:50 ` Jan Beulich
2021-02-08 16:39 ` Roger Pau Monné
2021-02-01 12:43 ` [PATCH v2 3/3] x86/time: don't move TSC backwards in time_calibration_tsc_rendezvous() Jan Beulich
2021-02-02 8:16 ` Jan Beulich
2021-02-08 9:38 ` Roger Pau Monné
2021-02-08 11:22 ` Jan Beulich
2021-02-08 13:19 ` Roger Pau Monné [this message]
2021-02-08 13:59 ` Jan Beulich
2021-02-08 16:33 ` Roger Pau Monné
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=YCE6XlA14A2Qsq8H@Air-de-Roger \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=claudemir@todobom.com \
--cc=jbeulich@suse.com \
--cc=wl@xen.org \
--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 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.