KVM: Questions regarding page_track and memory slots
From: David Hildenbrand
Date: Wed Apr 04 2018 - 04:11:33 EST
Hi,
I can see that we allocate under x86 for each KVM memslot
"sizeof(unsigned short) * npages" for page_track.
So 1 byte for each 4096 bytes of memory slot size. This doesn't sound a
lot, but if we have very big memory slots (e.g. for NVDIMM), this can
quickly get out of hand. E.g. for 4TB, we would need 1GB. And this just
means somebody created a big memory slot, not even memory would have to
be populated in that slot.
I can see that the only user is right now kvmgt. My assumption is, that
only a fraction of all memory will be tracked.
1. Do we actually need to track on a per-page level, how many trackers
we have? Is it a valid use case that multiple users track the same page?
(e.g. can't we simply use a bitmap)
2. Is my assumption, that this is actually a sparse "bitmap" true?
Wouldn't something like a radix tree, that grows with the number of
tracked pages, be a better fit?
I am looking right now into creating big memory slots and only assigning
a portion at a time to the guest. So initially, most parts of the big
memory slot would not be accessible by the guest and would not have
backing pages. Of course, I want to minimize the involved size of the
memory slot. An alternative is growing a memory slot atomically. Of
course, the current state of page-track is also a problem for growing a
memory slot atomically (having to copy/grow the array).
Thanks or any insight.
--
Thanks,
David / dhildenb