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 <[email protected]>
> ---
>  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 kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to