From: Avi Kivity <avi@redhat.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
mtosatti@redhat.com, xiaoguangrong@cn.fujitsu.com
Subject: Re: [RFC PATCH 2/3] kvm: Allow memory slot array to grow on demand
Date: Sun, 27 Feb 2011 11:44:49 +0200 [thread overview]
Message-ID: <4D6A1D11.2060008@redhat.com> (raw)
In-Reply-To: <1298570896.6140.35.camel@x201>
On 02/24/2011 08:08 PM, Alex Williamson wrote:
> > > @@ -207,7 +206,7 @@ struct kvm_mmu_page {
> > > * One bit set per slot which has memory
> > > * in this shadow page.
> > > */
> > > - DECLARE_BITMAP(slot_bitmap, KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS);
> > > + unsigned long *slot_bitmap;
> >
> > What about
> >
> > union {
> > DECLARE_BITMAP(direct_slot_bitmap, BITS_PER_LONG);
> > unsigned long *indirect_slot_bitmap;
> > };
> >
> > to make the hackery below more explicit?
>
> Yeah, it need something to make the hackery go down easier. I was
> actually thinking about:
>
> unsigned long *slot_bitmap;
> DECLARE_BITMAP(direct_slot_bitmap, BITS_PER_LONG);
>
> Where we'd then just set:
>
> slot_bitmap =&direct_slot_bitmap;
>
> It wastes 8 bytes, and pushes the cache a little harder, but still helps
> the locality and makes the usage more consistent.
unsigned long *sp_slot_bitmap(struct kvm_mmu_page *sp) { ... }
gives you the best of both worlds.
> >
> > We don't support failing kvm_mmu_get_page(). See
> > mmu_memory_cache_alloc() and mmu_topup_memory_caches().
>
> Hmm, apparently my search stopped at __direct_map() calling
> kvm_mmu_get_page() and handling an error.
That's dead code (was there from the very first commit into mmu.c).
> > >
> > > r = -ENOMEM;
> > > - slots = kzalloc(sizeof(struct kvm_memslots), GFP_KERNEL);
> > > +
> > > + if (mem->slot>= kvm->memslots->nmemslots) {
> > > + nmemslots = mem->slot + 1;
> > > + flush = true;
> >
> > Isn't flush here a little too agressive? Shouldn't we flush only if we
> > cross the BITS_PER_LONG threshold?
>
> Perhaps, but is that overly exploiting our knowledge about the bitmap
> implementation? I figured better to error too aggressively than too
> lazy since this is a rare event already.
I'm worried about the screen-clearing using the vga window at
0xa[08]000. If that works without too much flushing, then we're fine.
On second thoughts we're likely fine even if we do flush, since it's in
a tight loop so it takes very little work to reestablish the dropped sptes.
> > > @@ -1832,6 +1854,8 @@ static long kvm_vm_ioctl(struct file *filp,
> > > sizeof kvm_userspace_mem))
> > > goto out;
> > >
> > > + kvm_userspace_mem.slot += KVM_PRIVATE_MEM_SLOTS;
> > > +
> >
> > Slightly uneasy about this, but no real objection.
>
> If you have better ideas, let me know. This reminds me to ask about
> this chunk:
>
> @@ -671,7 +674,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
>
> /* Check for overlaps */
> r = -EEXIST;
> - for (i = 0; i< KVM_MEMORY_SLOTS; ++i) {
> + for (i = KVM_PRIVATE_MEM_SLOTS; i< kvm->memslots->nmemslots; ++i) {
> struct kvm_memory_slot *s =&kvm->memslots->memslots[i];
>
> if (s == memslot || !s->npages)
>
> I kept the same behavior as previous, but it highlights that we're not
> checking for overlaps between private slots and anything else. Existing
> bug? Thanks,
Yes, possibly serious. Who knows what happens if we create a page using
one slot and remove it via another?
Let's go write some Visual Basic.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2011-02-27 9:45 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-22 8:08 [PATCH 0/7] KVM: optimize memslots searching and cache GPN to GFN Xiao Guangrong
2011-02-22 8:09 ` [PATCH 1/7] KVM: cleanup memslot_id function Xiao Guangrong
2011-02-22 8:10 ` [PATCH 2/7] KVM: introduce KVM_MEM_SLOTS_NUM macro Xiao Guangrong
2011-02-22 8:11 ` [PATCH 1/3] KVM: introduce memslots_updated function Xiao Guangrong
2011-02-22 8:12 ` [PATCH 4/7] KVM: sort memslots and use binary search to search the right slot Xiao Guangrong
2011-02-22 14:25 ` Avi Kivity
2011-02-22 14:54 ` Alex Williamson
2011-02-22 18:54 ` [RFC PATCH 0/3] Weight-balanced binary tree + KVM growable memory slots using wbtree Alex Williamson
2011-02-22 18:55 ` [RFC PATCH 1/3] Weight-balanced tree Alex Williamson
2011-02-23 13:09 ` Avi Kivity
2011-02-23 17:02 ` Alex Williamson
2011-02-23 17:08 ` Avi Kivity
2011-02-23 20:19 ` Alex Williamson
2011-02-24 23:04 ` Andrew Morton
2011-02-22 18:55 ` [RFC PATCH 2/3] kvm: Allow memory slot array to grow on demand Alex Williamson
2011-02-24 10:39 ` Avi Kivity
2011-02-24 18:08 ` Alex Williamson
2011-02-27 9:44 ` Avi Kivity [this message]
2011-02-22 18:55 ` [RFC PATCH 3/3] kvm: Use weight-balanced tree for memory slot management Alex Williamson
2011-02-22 18:59 ` [RFC PATCH 0/3] Weight-balanced binary tree + KVM growable memory slots using wbtree Alex Williamson
2011-02-23 1:56 ` Alex Williamson
2011-02-23 13:12 ` Avi Kivity
2011-02-23 18:06 ` Alex Williamson
2011-02-23 19:28 ` Alex Williamson
2011-02-24 10:06 ` Avi Kivity
2011-02-24 17:35 ` Alex Williamson
2011-02-27 9:54 ` Avi Kivity
2011-02-28 23:04 ` Alex Williamson
2011-03-01 15:03 ` Avi Kivity
2011-03-01 18:20 ` Alex Williamson
2011-03-02 13:31 ` Avi Kivity
2011-03-01 19:47 ` Marcelo Tosatti
2011-03-02 13:34 ` Avi Kivity
2011-02-24 10:04 ` Avi Kivity
2011-02-23 1:30 ` [PATCH 4/7] KVM: sort memslots and use binary search to search the right slot Xiao Guangrong
2011-02-22 8:13 ` [PATCH 5/7] KVM: cache the last used slot Xiao Guangrong
2011-02-22 14:26 ` Avi Kivity
2011-02-22 8:15 ` [PATCH 6/7] KVM: cleanup traversal used slots Xiao Guangrong
2011-02-22 8:16 ` [PATCH 7/7] KVM: MMU: cache guest page number to guest frame number Xiao Guangrong
2011-02-22 14:32 ` Avi Kivity
2011-02-23 1:38 ` Xiao Guangrong
2011-02-23 9:28 ` 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=4D6A1D11.2060008@redhat.com \
--to=avi@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=xiaoguangrong@cn.fujitsu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.