From: Sasha Levin <levinsasha928@gmail.com>
To: Pekka Enberg <penberg@kernel.org>
Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com,
gorcunov@gmail.com
Subject: Re: [PATCH] kvm tools: Wait for all VCPU threads to exit while rebooting
Date: Thu, 11 Aug 2011 13:14:58 +0300 [thread overview]
Message-ID: <1313057698.3456.10.camel@lappy> (raw)
In-Reply-To: <CAOJsxLHM3yepX7E+znRbLnvACkEbd-RrtZ0uMVxP1qeQydjwCw@mail.gmail.com>
On Thu, 2011-08-11 at 13:02 +0300, Pekka Enberg wrote:
> On Thu, Aug 11, 2011 at 12:47 PM, Sasha Levin <levinsasha928@gmail.com> wrote:
> > This patch changes kvm_cpu__reboot() behaviour to block until all VCPU
> > threads have ended, this allows us to assume that the guest is stopped
> > when the function has returned.
> >
> > This fixes errors on close caused by releasing KVM_RUN structure while
> > VCPUs were still running.
> >
> > Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> > ---
> > tools/kvm/kvm-cpu.c | 10 ++++++++--
> > 1 files changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/kvm/kvm-cpu.c b/tools/kvm/kvm-cpu.c
> > index 2f5d23c..64c0997 100644
> > --- a/tools/kvm/kvm-cpu.c
> > +++ b/tools/kvm/kvm-cpu.c
> > @@ -421,7 +421,13 @@ static void kvm_cpu__handle_coalesced_mmio(struct kvm_cpu *cpu)
> >
> > void kvm_cpu__reboot(void)
> > {
> > - pthread_kill(kvm_cpus[0]->thread, SIGKVMEXIT);
> > + int i;
> > +
> > + for (i = 0; i < KVM_NR_CPUS; i++)
> > + if (kvm_cpus[i]) {
> > + pthread_kill(kvm_cpus[i]->thread, SIGKVMEXIT);
> > + pthread_join(kvm_cpus[i]->thread, NULL);
> > + }
>
> Wouldn't it be better to first pthread_kill() all CPUs first and do
> pthread_join() in separate loop? That should be faster especially if
> there's lots of CPUs.
Actually, we don't even need a pthread_kill() there. I'll send a new
version :)
--
Sasha.
next prev parent reply other threads:[~2011-08-11 10:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-11 9:47 [PATCH] kvm tools: Add MSI-X support to virtio-net Sasha Levin
2011-08-11 9:47 ` [PATCH] kvm tools: Wait for all VCPU threads to exit while rebooting Sasha Levin
2011-08-11 10:02 ` Pekka Enberg
2011-08-11 10:14 ` Sasha Levin [this message]
2011-08-11 9:56 ` [PATCH] kvm tools: Add MSI-X support to virtio-net Pekka Enberg
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=1313057698.3456.10.camel@lappy \
--to=levinsasha928@gmail.com \
--cc=asias.hejun@gmail.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=penberg@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox