From: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
To: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
Cc: Avi Kivity <avi@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>,
LKML <linux-kernel@vger.kernel.org>, KVM <kvm@vger.kernel.org>
Subject: Re: [PATCH v3 4/6] KVM: introduce id_to_memslot function
Date: Thu, 24 Nov 2011 19:15:36 +0900 [thread overview]
Message-ID: <4ECE1948.2060907@oss.ntt.co.jp> (raw)
In-Reply-To: <4ECE10F8.9070707@gmail.com>
(2011/11/24 18:40), Xiao Guangrong wrote:
...
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3521,7 +3521,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
> if (log->slot>= KVM_MEMORY_SLOTS)
> goto out;
>
> - memslot =&kvm->memslots->memslots[log->slot];
> + memslot = id_to_memslot(kvm->memslots, log->slot);
> r = -ENOENT;
> if (!memslot->dirty_bitmap)
> goto out;
> @@ -3544,15 +3544,16 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
> if (!slots)
> goto out;
> memcpy(slots, kvm->memslots, sizeof(struct kvm_memslots));
> - memslot =&slots->memslots[log->slot];
> - memslot->dirty_bitmap = dirty_bitmap;
> + memslot = id_to_memslot(slots, log->slot);
> memslot->nr_dirty_pages = 0;
> + memslot->dirty_bitmap = dirty_bitmap;
> update_memslots(slots, NULL);
>
> old_slots = kvm->memslots;
> rcu_assign_pointer(kvm->memslots, slots);
> synchronize_srcu_expedited(&kvm->srcu);
> - dirty_bitmap = old_slots->memslots[log->slot].dirty_bitmap;
> + dirty_bitmap = id_to_memslot(old_slots,
> + log->slot)->dirty_bitmap;
You can eliminate this if you use old_slot and new_slot for the two memory slots.
Takuya
> kfree(old_slots);
>
> write_protect_slot(kvm, memslot, dirty_bitmap, nr_dirty_pages);
next prev parent reply other threads:[~2011-11-24 10:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-24 9:36 [PATCH v3 0/6] KVM: optimize memslots searching Xiao Guangrong
2011-11-24 9:37 ` [PATCH v3 1/6] KVM: introduce KVM_MEM_SLOTS_NUM macro Xiao Guangrong
2011-11-24 9:38 ` [PATCH v3 2/6] KVM: introduce update_memslots function Xiao Guangrong
2011-11-24 9:39 ` [PATCH v3 3/6] KVM: introduce kvm_for_each_memslot macro Xiao Guangrong
2011-11-24 9:40 ` [PATCH v3 4/6] KVM: introduce id_to_memslot function Xiao Guangrong
2011-11-24 10:15 ` Takuya Yoshikawa [this message]
2011-11-24 10:23 ` Takuya Yoshikawa
2011-11-24 11:04 ` Xiao Guangrong
2011-11-24 9:40 ` [PATCH v3 5/6] KVM: sort memslots by its size and use line search Xiao Guangrong
2011-11-24 9:41 ` [PATCH v3 6/6] KVM: introduce a table to map slot id to index in memslots array Xiao Guangrong
2011-11-27 12:21 ` [PATCH v3 0/6] KVM: optimize memslots searching Avi Kivity
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=4ECE1948.2060907@oss.ntt.co.jp \
--to=yoshikawa.takuya@oss.ntt.co.jp \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=xiaoguangrong.eric@gmail.com \
--cc=xiaoguangrong@linux.vnet.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).