On Wed, Oct 31, 2012 at 10:40:57AM +0800, Huang Zhiteng wrote:
> On Wed, Oct 31, 2012 at 10:07 AM, Vishvananda Ishaya
> <vishvana...@gmail.com> wrote:
> >
> > On Oct 30, 2012, at 7:01 PM, Huang Zhiteng <winsto...@gmail.com> wrote:
> >
> >> I'd suggest the same ratio too.  But besides memory overcommitment, I
> >> suspect this issue is also related to how KVM do memory allocation (it
> >> doesn't do actual allocation of the entire memory for guest when
> >> booting). I've seen compute node reported more memory than it should
> >> have (e.g. 4G node has two 1GB instances running but still report >3GB
> >> free memory) because libvirt driver calculates free memory simply
> >> based on /proc/meminfo, which doesn't reflect how many memory guests
> >> are intended to use.
> >
> > Ah interesting, if this is true then this is a bug we should try to fix.
> > I was under the impression that it allocated all of the memory unless
> > you were using virtio_balloon, but I haven't verified.
>
> I'm pretty sure about this.  Can anyone from RedHat confirm this is
> how KVM works?

Yes, that is correct. KVM only allocates memory when the guest actually
touches each page. For Linux guests this means that when the guest boots
up very little memory is actally allocated on the host. For Windows guests
you would typically see all memory allocated imediately, since the Windows
kernel will memset() the entire of RAM to zero on startup.

Also if you are using explicit huge pages for KVM it will allocate all
RAM upfront, but this is not the default - we use transparant/automatic
huge pages normally which still allocates on demand. Finally if you have
passed any PCI devices through to the guest, all guest RAM will be mlock()d
on the host so it can't even overcommit to swap.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

_______________________________________________
Mailing list: https://launchpad.net/~openstack
Post to     : openstack@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openstack
More help   : https://help.launchpad.net/ListHelp

Reply via email to