From: Avi Kivity <avi@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>,
LKML <linux-kernel@vger.kernel.org>, KVM <kvm@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] KVM: send IPI to vcpu only when it's in guest mode
Date: Sun, 09 Jan 2011 12:00:10 +0200 [thread overview]
Message-ID: <4D29872A.608@redhat.com> (raw)
In-Reply-To: <20110107115527.GA13196@amt.cnet>
On 01/07/2011 01:55 PM, Marcelo Tosatti wrote:
> On Fri, Jan 07, 2011 at 03:47:51PM +0800, Xiao Guangrong wrote:
> > We can interrupt the vcpu only when it's running in guest mode
> > to reduce IPI
> >
> > It looks like only ia64 and x86 need to send IPI to other vcpus, so
> > i only add the implementation of 'vcpu->guest_mode' in ia64, but i
> > don't know ia64 well, please point out the right way for me if the
> > implementation is incorrect
> >
> > Also reorganize struct kvm_vcpu to make ->guest_mode and ->requests
> > in the same cache line explicitly.
> >
> > Signed-off-by: Xiao Guangrong<xiaoguangrong@cn.fujitsu.com>
> > ---
> > arch/ia64/kvm/kvm-ia64.c | 2 ++
> > arch/x86/kvm/x86.c | 6 +++++-
> > include/linux/kvm_host.h | 9 +++++----
> > virt/kvm/kvm_main.c | 7 ++++++-
> > 4 files changed, 18 insertions(+), 6 deletions(-)
> >
>
> > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> > index b1b6cbb..a475264 100644
> > --- a/virt/kvm/kvm_main.c
> > +++ b/virt/kvm/kvm_main.c
> > @@ -153,7 +153,12 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req)
> > if (kvm_make_check_request(req, vcpu))
> > continue;
> > cpu = vcpu->cpu;
> > - if (cpus != NULL&& cpu != -1&& cpu != me)
> > +
> > + /* Set ->requests bit before we read ->guest_mode */
> > + smp_mb();
> > +
> > + if (cpus != NULL&& cpu != -1&& cpu != me&&
> > + atomic_read(&vcpu->guest_mode))
> > cpumask_set_cpu(cpu, cpus);
>
> Don't think this is safe, since guest_mode does not imply that a vcpu
> has received the IPI, only that IPI has been sent (see kvm_vcpu_kick).
>
> And make_all_cpus_request must guarantee all target vcpus are out of
> guest mode before it returns.
>
Good catch. We could remove the atomic_xchg() in kvm_vcpu_kick(), but
need to think of any drawbacks to that.
Maybe we could replace guest_mode with a three value variable: in guest,
outside guest, and transitioning out of guest. So kvm_vcpu_kick()
avoids the IPI on the last two, while make_all_cpus_request() only
avoids an IPI if outside guest mode.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2011-01-09 10:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-07 7:46 [PATCH v2 1/3] KVM: fix rcu usage warning in kvm_arch_vcpu_ioctl_set_sregs() Xiao Guangrong
2011-01-07 7:47 ` [PATCH v2 2/3] KVM: send IPI to vcpu only when it's in guest mode Xiao Guangrong
2011-01-07 11:55 ` Marcelo Tosatti
2011-01-09 10:00 ` Avi Kivity [this message]
2011-01-07 7:48 ` [PATCH v2 3/3] KVM: make make_all_cpus_request() lockless Xiao Guangrong
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=4D29872A.608@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=xiaoguangrong@cn.fujitsu.com \
/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.