From: Igor Mammedov <imammedo@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
yoshikawa_takuya_b1@lab.ntt.co.jp
Subject: Re: [PATCH 3/3] kvm: simplify update_memslots invocation
Date: Fri, 14 Nov 2014 15:24:26 +0100 [thread overview]
Message-ID: <20141114152426.397aa1d8@igors-macbook-pro.local> (raw)
In-Reply-To: <1415963522-5255-4-git-send-email-pbonzini@redhat.com>
On Fri, 14 Nov 2014 12:12:02 +0100
Paolo Bonzini <pbonzini@redhat.com> wrote:
> The update_memslots invocation is only needed in one case. Make
> the code clearer by moving it to __kvm_set_memory_region, and
> removing the wrapper around insert_memslot.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> virt/kvm/kvm_main.c | 20 ++++++--------------
> 1 file changed, 6 insertions(+), 14 deletions(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 7bfc842b96d7..a5ed3a9f7522 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -674,8 +674,8 @@ static int kvm_create_dirty_bitmap(struct
> kvm_memory_slot *memslot)
> * takes advantage of having initially sorted array and
> * known changed memslot position.
> */
> -static void insert_memslot(struct kvm_memslots *slots,
> - struct kvm_memory_slot *new)
> +static void update_memslots(struct kvm_memslots *slots,
> + struct kvm_memory_slot *new)
> {
> int id = new->id;
> int i = slots->id_to_index[id];
> @@ -703,14 +703,6 @@ static void insert_memslot(struct kvm_memslots
> *slots, slots->id_to_index[mslots[i].id] = i;
> }
>
> -static void update_memslots(struct kvm_memslots *slots,
> - struct kvm_memory_slot *new)
> -{
> - if (new) {
> - insert_memslot(slots, new);
> - }
> -}
> -
> static int check_memory_region_flags(struct
> kvm_userspace_memory_region *mem) {
> u32 valid_flags = KVM_MEM_LOG_DIRTY_PAGES;
> @@ -726,7 +718,7 @@ static int check_memory_region_flags(struct
> kvm_userspace_memory_region *mem) }
>
> static struct kvm_memslots *install_new_memslots(struct kvm *kvm,
> - struct kvm_memslots *slots, struct kvm_memory_slot
> *new)
> + struct kvm_memslots *slots)
> {
> struct kvm_memslots *old_memslots = kvm->memslots;
>
> @@ -737,7 +729,6 @@ static struct kvm_memslots
> *install_new_memslots(struct kvm *kvm,
> WARN_ON(old_memslots->generation & 1); slots->generation =
> old_memslots->generation + 1;
> - update_memslots(slots, new);
> rcu_assign_pointer(kvm->memslots, slots);
> synchronize_srcu_expedited(&kvm->srcu);
>
> @@ -874,7 +865,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
> slot = id_to_memslot(slots, mem->slot);
> slot->flags |= KVM_MEMSLOT_INVALID;
>
> - old_memslots = install_new_memslots(kvm, slots,
> NULL);
> + old_memslots = install_new_memslots(kvm, slots);
>
> /* slot was deleted or moved, clear iommu mapping */
> kvm_iommu_unmap_pages(kvm, &old);
> @@ -905,7 +896,8 @@ int __kvm_set_memory_region(struct kvm *kvm,
> memset(&new.arch, 0, sizeof(new.arch));
> }
>
> - old_memslots = install_new_memslots(kvm, slots, &new);
> + update_memslots(slots, &new);
> + old_memslots = install_new_memslots(kvm, slots);
>
> kvm_arch_commit_memory_region(kvm, mem, &old, change);
>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
next prev parent reply other threads:[~2014-11-14 14:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-14 11:11 [PATCH 0/3] KVM: simplification to the memslots code Paolo Bonzini
2014-11-14 11:12 ` [PATCH 1/3] kvm: memslots: track id_to_index changes during the insertion sort Paolo Bonzini
2014-11-14 13:34 ` Igor Mammedov
2014-11-14 13:35 ` Radim Krčmář
2014-11-14 14:17 ` Igor Mammedov
2014-11-14 14:41 ` Radim Krčmář
2014-11-14 14:44 ` Paolo Bonzini
2014-11-14 14:29 ` Paolo Bonzini
2014-11-14 14:44 ` Radim Krčmář
2014-11-14 11:12 ` [PATCH 2/3] kvm: commonize allocation of the new memory slots Paolo Bonzini
2014-11-14 14:21 ` Igor Mammedov
2014-11-17 1:49 ` Takuya Yoshikawa
2014-11-14 11:12 ` [PATCH 3/3] kvm: simplify update_memslots invocation Paolo Bonzini
2014-11-14 14:24 ` Igor Mammedov [this message]
2014-11-17 1:56 ` [PATCH 0/3] KVM: simplification to the memslots code Takuya Yoshikawa
2014-11-17 9:23 ` Paolo Bonzini
2014-11-17 9:30 ` Takuya Yoshikawa
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=20141114152426.397aa1d8@igors-macbook-pro.local \
--to=imammedo@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=yoshikawa_takuya_b1@lab.ntt.co.jp \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®