From: Dario Faggioli <raistlin@linux.it>
To: Jan Beulich <JBeulich@suse.com>
Cc: Sergey Dyasli <sergey.dyasli@citrix.com>,
Kevin Tian <kevin.tian@intel.com>,
Igor Druzhinin <igor.druzhinin@citrix.com>,
AndrewCooper <Andrew.Cooper3@citrix.com>,
anshul makkar <anshulmakkar@gmail.com>,
"jun.nakajima@intel.com" <jun.nakajima@intel.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v2 1/2] VMX: fix VMCS race on context-switch paths
Date: Thu, 09 Nov 2017 15:16:02 +0100 [thread overview]
Message-ID: <1510236962.4517.220.camel@linux.it> (raw)
In-Reply-To: <5A04616F020000780018D92D@prv-mh.provo.novell.com>
[-- Attachment #1.1: Type: text/plain, Size: 2804 bytes --]
On Thu, 2017-11-09 at 06:08 -0700, Jan Beulich wrote:
> > > > On 09.11.17 at 12:01, <raistlin@linux.it> wrote:
> >
> > pCPU1
> > =====
> > current == vCPU1
> > context_switch(next == idle)
> > !! __context_switch() is skipped
> > vcpu_migrate(vCPU1)
> > anything_that_uses_or_touches_context()
> >
> > So, it must be anything_that_uses_or_touches_context() --knowing it
> > will be reading or touching the pCPU context-- that syncs the
> > state,
> > before using or touching it (which is, e.g., what Jan's patch
> > does).
>
> Well, generally after the vcpu_migrate(vCPU1) above we expect
> nothing to happen at all on the pCPU, until another (non-idle)
> vCPU gets scheduled onto it.
>
Ah, yes, my bad! What if I take vcpu_migrate() out of the above exec-
trace (which is what I wanted to do in my email already)?
pCPU1
=====
current == vCPU1
context_switch(next == idle)
!! __context_switch() is skipped
anything_that_uses_or_touches_context()
Point being, is the underlying and general "issue" here, really bound
to migrations, or is it something intrinsic of lazy context switch? I'm
saying it's the latter.
That being said, sure it makes sense to assume that, if we migrated the
vCPU from pCPU1 to pCPU2, it's highly unlikely that it will resume the
execution on pCPU1, and hence there is no point in leaving its context
there, and we could very well sync. It's a reasonable best-effort
measure, but can we rely on it for correctness? I don't think we can.
And generalizing the idea enough that we could then rely on it for
correctness, tends to be close enough to not doing lazy context switch
at all, I think.
> The problem is with tasklet / softirq
> (and hence also RCU) work.
>
Yes.
> Tasklets already take care of this by
> calling sync_local_execstate() before calling the handler. But
> for softirqs this isn't really an option; I'm surprised to see that
> tasklet code does this independently of what kind of tasklet that
> is.
>
Good point. Weird indeed.
> Softirq tasklets aren't used very often, so I wonder if we have
> a latent bug here. Otoh, if this was actually fine, adding a similar
> call to rcu_do_batch() (or its caller) would be an option, I think.
>
We can have a look.
What about the effect on performance, though?
I mean, assuming that lazy context switch does a good job, with respect
to that, by avoiding synching in enough case where it is actually not
necessary, how do things change if we start to sync at any softirq,
even when the handler would have not required that?
Regards,
Dario
--
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 127 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-11-09 14:16 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-16 11:10 [PATCH v2 0/2] x86: context switch handling adjustments Jan Beulich
2017-02-16 11:15 ` [PATCH v2 1/2] VMX: fix VMCS race on context-switch paths Jan Beulich
2017-02-16 12:27 ` Andrew Cooper
2017-02-16 12:35 ` Jan Beulich
2017-02-17 3:48 ` Tian, Kevin
2017-02-17 8:40 ` Sergey Dyasli
2017-02-17 9:01 ` Jan Beulich
2017-10-27 17:42 ` Igor Druzhinin
2017-11-02 19:46 ` Igor Druzhinin
2017-11-07 8:07 ` Jan Beulich
2017-11-07 14:24 ` Igor Druzhinin
2017-11-07 14:55 ` Jan Beulich
2017-11-07 15:52 ` Igor Druzhinin
2017-11-07 16:31 ` Jan Beulich
2017-11-09 10:05 ` Jan Beulich
2017-11-09 10:36 ` Dario Faggioli
2017-11-09 12:58 ` Jan Beulich
2017-11-09 9:54 ` Dario Faggioli
2017-11-09 10:17 ` Jan Beulich
2017-11-09 10:36 ` Sergey Dyasli
2017-11-09 11:01 ` Dario Faggioli
2017-11-09 13:08 ` Jan Beulich
2017-11-09 14:16 ` Dario Faggioli [this message]
2017-11-09 14:39 ` Jan Beulich
2017-11-09 16:38 ` Jan Beulich
2017-11-09 10:39 ` Dario Faggioli
2017-11-07 15:16 ` Jan Beulich
2017-02-16 11:16 ` [PATCH v2 2/2] x86: package up context switch hook pointers Jan Beulich
2017-02-16 11:23 ` Andrew Cooper
2017-02-17 3:49 ` Tian, Kevin
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=1510236962.4517.220.camel@linux.it \
--to=raistlin@linux.it \
--cc=Andrew.Cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=anshulmakkar@gmail.com \
--cc=igor.druzhinin@citrix.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=sergey.dyasli@citrix.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).