From: Dario Faggioli <dario.faggioli@citrix.com>
To: "Wu, Feng" <feng.wu@intel.com>, Jan Beulich <JBeulich@suse.com>
Cc: "george.dunlap@eu.citrix.com" <george.dunlap@eu.citrix.com>,
"andrew.cooper3@citrix.com" <andrew.cooper3@citrix.com>,
"Tian, Kevin" <kevin.tian@intel.com>,
"keir@xen.org" <keir@xen.org>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH 0/3] VMX: Properly handle pi descriptor and per-cpu blocking list
Date: Fri, 24 Jun 2016 09:22:32 +0200 [thread overview]
Message-ID: <1466752952.18398.81.camel@citrix.com> (raw)
In-Reply-To: <E959C4978C3B6342920538CF579893F01972E170@SHSMSX103.ccr.corp.intel.com>
[-- Attachment #1.1: Type: text/plain, Size: 3527 bytes --]
On Fri, 2016-06-24 at 06:11 +0000, Wu, Feng wrote:
> > -----Original Message-----
> > From: Dario Faggioli [mailto:dario.faggioli@citrix.com]
> > No, because we call cpu_disable_scheduler() from __cpu_disable(),
> > only
> > when system state is SYS_STATE_suspend already, and hence we take
> > the
> > then branch of the 'if', which does never return an error.
> Thanks for the elaboration. I find __cpu_disable() can be called with
> system state not being SYS_STATE_suspend. Here is my experiment:
>
> 1. Launch a guest and pin vCPU 3 to pCPU 3 (which makes the
> experiment simpler)
> 2. offline pCPU 3 via "xen-hptool cpu-offline 3"
>
Ah, yes, of course. I should have included cpu-hot(un)plug in my
analysis in the first place, sorry for not doing so.
> The call path of the above steps is:
> arch_do_sysctl()
> -> cpu_down_helper()
> -> cpu_down()
> -> take_cpu_down()
> -> __cpu_disable()
> -> cpu_disable_scheduler() (enter the 'else' part)
>
Right, and the important part is this one:
> int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu)
> {
>
> ......
>
> point 1
>
> for_each_cpu ( i, &allbutself )
> tasklet_schedule_on_cpu(&per_cpu(stopmachine_tasklet, i), i);
>
> point 2
> ......
>
> }
>
> at point 1 above,
> vCPU3->runstate.state: 0, vCPU3->is_running: 1
> while at point 2 above:
> vCPU3->runstate.state: 1, vCPU3->is_running: 0
>
This is exactly as you describe. cpu hotplug is done in stop machine
context. Check the comment close to the definition of stop_machine_run:
/**
* stop_machine_run: freeze the machine on all CPUs and run this function
* @fn: the function to run
* @data: the data ptr for the @fn()
* @cpu: the cpu to run @fn() on (or all, if @cpu == NR_CPUS).
*
* Description: This causes every other cpu to enter a safe point, with
* each of which disables interrupts, and finally interrupts are disabled
* on the current CPU. The result is that none is holding a spinlock
* or inside any other preempt-disabled region when @fn() runs.
*
* This can be thought of as a very heavy write lock, equivalent to
* grabbing every spinlock in the kernel. */
As you discovered yourself, this is achieved by forcing the execution
of a tasklet on all the pcpus, which include pCPU 3 of your example.
So, vCPU 3 was running, but then some called stop_machine_run(), which
causes the descheduling of vCPU 3, and the execution of the stopmachine
tasklet.
Thet's why you find is_running to be 0, and that's why we never return
EAGAIN.
> I tested it for many times and got the same result. I am not sure the
> vcpu
> state transition just happens to occurs here or not? If the
> transition doesn't
> happen and is_running is still 1 when we get vcpu_migrate() in
> cpu_disable_scheduler() in the above case, should it be a problem?
>
I'm not sure what you mean here (in particular with "just happen to
occur"). If you're wondering whether the fact that vCPU 3 gets
descheduled happens by chance or by design, it's indeed the latter, and
so, no, we don't have a problem with this code path.
Regards,
Dario
--
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-06-24 7:22 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-20 8:53 [PATCH 0/3] VMX: Properly handle pi descriptor and per-cpu blocking list Feng Wu
2016-05-20 8:53 ` [PATCH 1/3] VMX: Properly adjuest the status of pi descriptor Feng Wu
2016-05-23 5:15 ` Tian, Kevin
2016-05-23 5:27 ` Wu, Feng
2016-05-23 6:52 ` Tian, Kevin
2016-05-23 7:16 ` Wu, Feng
2016-05-23 9:03 ` Jan Beulich
2016-05-23 9:21 ` Wu, Feng
2016-05-23 11:04 ` Jan Beulich
2016-05-23 12:30 ` Jan Beulich
2016-05-20 8:53 ` [PATCH 2/3] VMX: Make hook pi_do_resume always available Feng Wu
2016-05-23 12:32 ` Jan Beulich
2016-05-23 12:51 ` Dario Faggioli
2016-05-20 8:53 ` [PATCH 3/3] VMX: Remove the vcpu from the per-cpu blocking list after domain termination Feng Wu
2016-05-23 5:19 ` Tian, Kevin
2016-05-23 5:48 ` Wu, Feng
2016-05-23 6:54 ` Tian, Kevin
2016-05-23 9:08 ` Jan Beulich
2016-05-23 9:17 ` Wu, Feng
2016-05-23 10:35 ` Wu, Feng
2016-05-23 11:11 ` Jan Beulich
2016-05-23 12:24 ` Wu, Feng
2016-05-23 12:46 ` Jan Beulich
2016-05-23 13:41 ` Wu, Feng
2016-05-23 12:30 ` Dario Faggioli
2016-05-23 13:32 ` Wu, Feng
2016-05-23 14:45 ` Dario Faggioli
2016-05-23 12:35 ` Jan Beulich
2016-05-23 13:33 ` Wu, Feng
2016-05-20 10:27 ` [PATCH 0/3] VMX: Properly handle pi descriptor and per-cpu blocking list Jan Beulich
2016-05-20 10:46 ` Wu, Feng
2016-05-23 8:08 ` Jan Beulich
2016-05-23 8:44 ` Wu, Feng
2016-05-23 8:51 ` Jan Beulich
2016-05-23 12:39 ` Dario Faggioli
2016-05-24 10:07 ` Wu, Feng
2016-05-24 13:33 ` Wu, Feng
2016-05-24 14:46 ` Dario Faggioli
2016-05-25 13:28 ` Wu, Feng
2016-05-24 14:02 ` Dario Faggioli
2016-05-25 12:39 ` Wu, Feng
2016-06-23 12:33 ` Wu, Feng
2016-06-23 15:11 ` Dario Faggioli
2016-06-24 6:11 ` Wu, Feng
2016-06-24 7:22 ` Dario Faggioli [this message]
2016-06-24 7:59 ` Wu, Feng
2016-06-24 10:27 ` Dario Faggioli
2016-06-24 13:25 ` Wu, Feng
2016-06-24 23:43 ` Dario Faggioli
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=1466752952.18398.81.camel@citrix.com \
--to=dario.faggioli@citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=feng.wu@intel.com \
--cc=george.dunlap@eu.citrix.com \
--cc=keir@xen.org \
--cc=kevin.tian@intel.com \
--cc=xen-devel@lists.xen.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.