Re: [PATCH] kvm: Fix memory slot generation updates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 23 Dec 2012 10:55:06 +0200
Gleb Natapov <gleb@xxxxxxxxxx> wrote:

> Applied, thanks. What about this small cleanup on to of the patch:

Looks nice!  Hope to see this applied as well.

Thanks,
	Takuya

> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 14cbae8..e45c20c 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -702,6 +702,17 @@ static int check_memory_region_flags(struct kvm_userspace_memory_region *mem)
>  	return 0;
>  }
>  
> +static struct kvm_memslots *install_new_memslots(struct kvm *kvm,
> +		struct kvm_memslots *slots, struct kvm_memory_slot *new)
> +{
> +	struct kvm_memslots *old_memslots = kvm->memslots;
> +
> +	update_memslots(slots, new, kvm->memslots->generation);
> +	rcu_assign_pointer(kvm->memslots, slots);
> +	synchronize_srcu_expedited(&kvm->srcu);
> +	return old_memslots; 
> +}
> +
>  /*
>   * Allocate some memory and give it an address in the guest physical address
>   * space.
> @@ -820,11 +831,8 @@ int __kvm_set_memory_region(struct kvm *kvm,
>  		slot = id_to_memslot(slots, mem->slot);
>  		slot->flags |= KVM_MEMSLOT_INVALID;
>  
> -		update_memslots(slots, NULL, kvm->memslots->generation);
> +		old_memslots = install_new_memslots(kvm, slots, NULL);
>  
> -		old_memslots = kvm->memslots;
> -		rcu_assign_pointer(kvm->memslots, slots);
> -		synchronize_srcu_expedited(&kvm->srcu);
>  		/* slot was deleted or moved, clear iommu mapping */
>  		kvm_iommu_unmap_pages(kvm, &old);
>  		/* From this point no new shadow pages pointing to a deleted,
> @@ -868,10 +876,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
>  		memset(&new.arch, 0, sizeof(new.arch));
>  	}
>  
> -	update_memslots(slots, &new, kvm->memslots->generation);
> -	old_memslots = kvm->memslots;
> -	rcu_assign_pointer(kvm->memslots, slots);
> -	synchronize_srcu_expedited(&kvm->srcu);
> +	old_memslots = install_new_memslots(kvm, slots, &new);
>  
>  	kvm_arch_commit_memory_region(kvm, mem, old, user_alloc);
>  
> --
> 			Gleb.


-- 
Takuya Yoshikawa <takuya.yoshikawa@xxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux