Re: [PATCH 2/6] kvm.git allow reading aliases with mmu_lock

Marcelo Tosatti
2008-07-28T21:46:23Z

On Fri, Jul 25, 2008 at 04:26:39PM +0200, Andrea Arcangeli wrote:
> This allows the mmu notifier code to run unalias_gfn with only the
> mmu_lock held. Only alias writes need the mmu_lock held. Readers will
> either take the slots_lock in read mode or the mmu_lock.
>
> Signed-off-by: Andrea Arcangeli <andrea@qumranet.com>
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index f7726a0..ddaf960 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -1515,6 +1515,7 @@ static int kvm_vm_ioctl_set_memory_alias(struct kvm *kvm,
> goto out;
>
> down_write(&kvm->slots_lock);
> + spin_lock(&kvm->mmu_lock);
>
> p = &kvm->arch.aliases[alias->slot];
> p->base_gfn = alias->guest_phys_addr >> PAGE_SHIFT;
> @@ -1526,6 +1527,7 @@ static int kvm_vm_ioctl_set_memory_alias(struct kvm *kvm,
> break;
> kvm->arch.naliases = n;
>
> + spin_unlock(&kvm->mmu_lock);
> kvm_mmu_zap_all(kvm);
>
> up_write(&kvm->slots_lock);
> --

Looks good.