From: Alex Williamson <alex.williamson@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org, gleb@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 0/6] kvm: Growable memory slot array
Date: Wed, 05 Dec 2012 15:57:48 -0700 [thread overview]
Message-ID: <1354748268.3224.57.camel@bling.home> (raw)
In-Reply-To: <20121205213203.GE20260@amt.cnet>
On Wed, 2012-12-05 at 19:32 -0200, Marcelo Tosatti wrote:
> On Mon, Dec 03, 2012 at 04:39:05PM -0700, Alex Williamson wrote:
> > Memory slots are currently a fixed resource with a relatively small
> > limit. When using PCI device assignment in a qemu guest it's fairly
> > easy to exhaust the number of available slots. I posted patches
> > exploring growing the number of memory slots a while ago, but it was
> > prior to caching memory slot array misses and thefore had potentially
> > poor performance. Now that we do that, Avi seemed receptive to
> > increasing the memory slot array to arbitrary lengths. I think we
> > still don't want to impose unnecessary kernel memory consumptions on
> > guests not making use of this, so I present again a growable memory
> > slot array.
> >
> > A couple notes/questions; in the previous version we had a
> > kvm_arch_flush_shadow() call when we increased the number of slots.
> > I'm not sure if this is still necessary. I had also made the x86
> > specific slot_bitmap dynamically grow as well and switch between a
> > direct bitmap and indirect pointer to a bitmap. That may have
> > contributed to needing the flush.
>
> I don't remember. Do you recall what was the argument back then?
> (there must have been some).
I vaguely recall chatting with you on irc about it before posting, so
unfortunately there's no list discussion. It's been almost 2 years, so
it's not surprising we've all forgotten. Here's the original post:
http://article.gmane.org/gmane.linux.kernel/1103962
(click on the subject to get to the thread) That version also included
an optimization to the x86-only slot_bitmap, and it's entirely possible
the flush had more to do with that than the memslots themselves. I
think Avi kind of alludes to this in his first reply that the flushing
is more aggressive than necessary and indicates it could happen only
when crossing BITS_PER_LONG boundaries.
> > I haven't done that yet here
> > because it seems like an unnecessary complication if we have a max
> > on the order of 512 or 1024 entries. A bit per slot isn't a lot of
> > overhead. If we want to go more, maybe we should make it switch.
> > That leads to the final question, we need an upper bound since this
> > does allow consumption of extra kernel memory, what should it be? A
> > PCI bus filled with assigned devices can theorically use up to 2048
> > slots (32 devices * 8 functions * (6 BARs + ROM + possibly split
> > MSI-X BAR)). For this RFC, I don't change the max, just make it
> > grow up to 32 user slots. Untested on anything but x86 so far.
> > Thanks,
>
> Not sure. Some reasonable number based on current usage expectations?
> (can be increased later if necessary).
The first obvious step is to double it to 64 slots. With typical
devices, that would give us 16+ assigned devices. There are already
people bumping into the 8 device limit we set in RHEL, so doubling it
doesn't feel like much headroom.
If we double again to 128 slots then we can likely support 32 typical
devices. That's a full PCI bus of single function devices. That's
probably the first acceptable step.
It looks like each slot on x86_64 is 64bytes (somehow I was throwing
around 72bytes before, not sure where I counted wrong), so we currently
have:
32 user + 4 private slots = 36*64 = 2304
32+4 id_to_index = 36*4 = 144
32+4 entry slot_bitmap = 8
Total = 2456
At 132 (128+4), this becomes 8448 + 528 + 24 = 9000 bytes
We can actually compact struct kvm_memory_slot down to 56 bytes (flags
-> u32, user_alloc -> bool, id -> short), which also cuts id_to_index in
half, so that gives us: 7392 + 264 + 24 = 7680
(I might sacrifice a couple user slots just to make these powers of 2,
ie. 124 user + 4 private = 128, 7440 bytes)
Should we target that as a first step and ignore all this extra
complication? Thanks,
Alex
prev parent reply other threads:[~2012-12-05 22:57 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-03 23:39 [RFC PATCH 0/6] kvm: Growable memory slot array Alex Williamson
2012-12-03 23:39 ` [RFC PATCH 1/6] kvm: Rename KVM_MEMORY_SLOTS -> KVM_USER_MEM_SLOTS Alex Williamson
2012-12-03 23:39 ` [RFC PATCH 2/6] kvm: Make KVM_PRIVATE_MEM_SLOTS optional Alex Williamson
2012-12-03 23:39 ` [RFC PATCH 3/6] kvm: Merge id_to_index into memslots Alex Williamson
2012-12-05 21:22 ` Marcelo Tosatti
2012-12-05 22:58 ` Alex Williamson
2012-12-03 23:39 ` [RFC PATCH 4/6] kvm: Move private memory slots to start of memslots array Alex Williamson
2012-12-05 21:24 ` Marcelo Tosatti
2012-12-05 22:58 ` Alex Williamson
2012-12-03 23:39 ` [RFC PATCH 5/6] kvm: Re-introduce memslots->nmemslots Alex Williamson
2012-12-05 21:26 ` Marcelo Tosatti
2012-12-05 23:02 ` Alex Williamson
2012-12-06 1:45 ` Marcelo Tosatti
2012-12-06 3:51 ` Alex Williamson
2012-12-06 23:58 ` Marcelo Tosatti
2012-12-06 23:59 ` Marcelo Tosatti
2012-12-07 0:07 ` Alex Williamson
2012-12-03 23:39 ` [RFC PATCH 6/6] kvm: Allow memory slots to grow Alex Williamson
2012-12-04 11:48 ` [RFC PATCH 0/6] kvm: Growable memory slot array Gleb Natapov
2012-12-04 15:21 ` Alex Williamson
2012-12-04 15:30 ` Gleb Natapov
2012-12-04 15:39 ` Alex Williamson
2012-12-04 16:42 ` Gleb Natapov
2012-12-04 17:56 ` Alex Williamson
2012-12-04 14:48 ` Takuya Yoshikawa
2012-12-04 15:26 ` Alex Williamson
2012-12-05 21:32 ` Marcelo Tosatti
2012-12-05 22:57 ` Alex Williamson [this message]
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=1354748268.3224.57.camel@bling.home \
--to=alex.williamson@redhat.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.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).