Re: Live memory allocation?

Tomasz Chmielewski
2009-03-30T13:40:32Z

Avi Kivity schrieb:

(...)

>> Perhaps KSM would help you? Alternately, a heuristic that scanned for
>> (and
>> collapsed) fully zeroed pages when a page is faulted in for the first
>> time could
>> catch these.
>>
>
> ksm will indeed collapse these pages. Lighter-weight alternatives exist
> -- ballooning (need a Windows driver), or, like you mention, a simple
> scanner that looks for zero pages and drops them. That could be
> implemented within qemu (with some simple kernel support for dropping
> zero pages atomically, say madvise(MADV_DROP_IFZERO).

From KSM description I can conclude that it "allows dynamicly sharing
identical memory pages between one or more processes".

What about cache/buffers sharing between the host kernel and running
processes?

If I'm not mistaken, right now, memory is "wasted" by caching the same
data by host and guest kernels.

For example, let's say we have a host with 2 GB RAM and it runs a 1 GB
guest.
If we read ~900 MB file_1 (block device) on guest, then:
- guest's kernel will cache file_1
- host's kernel will cache the same area of file_1 (block device)

Now, if we want to read ~900 MB file_2 (or lots of files with that
size), cache for file_1 will be emptied on both guest and host as we
read file_2.
Ideal situation would be if host and guest caches could be "shared", to
a degree (and have both file_1 and file_2 in memory, doesn't matter if
it's guest or host).

--
Tomasz Chmielewski