[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110107115527.GA13196@amt.cnet>
Date: Fri, 7 Jan 2011 09:55:27 -0200
From: Marcelo Tosatti <mtosatti@...hat.com>
To: Xiao Guangrong <xiaoguangrong@...fujitsu.com>
Cc: Avi Kivity <avi@...hat.com>, LKML <linux-kernel@...r.kernel.org>,
KVM <kvm@...r.kernel.org>
Subject: Re: [PATCH v2 2/3] KVM: send IPI to vcpu only when it's in guest mode
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@...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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists