Re: Live memory allocation?

Avi Kivity
2009-03-29T12:33:45Z

Nolan wrote:
> Windows does zero all memory at boot, and also runs a idle-priority thread in
> the background to zero memory as it is freed. This way it is far less likely to
> need to zero a page to satisfy a memory allocation request. Whether or not this
> is still a win now that people care about power consumption is an open question.
>
> I suspect the difference of behavior between KVM and VMware is related to
> VMware's page sharing. All those zeroed pages can be collapsed into one COW
> zero page. I wouldn't be surprised to learn that VMware has heuristics in the
> page sharing code specifically for windows guests.
>
> 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).

--
error compiling committee.c: too many arguments to function