Why the VMware Balloon driver is necessary

When talking about memory, in virtualised environments, there are basically 3 types:

  • The memory that the guest application sees within the VM [ “Virtual memory” ]
  • The memory that the Operating system sees, virtualised by the hypervisor  [ “Physical memory” ]
  • The physical memory of the hardware [ “Machine memory” ]

Normally (eg in Chips since 80386), operating systems see a virtual abstraction of the physical memory [eg to hide areas of memory which are reserved for IO [eg VGA memory], or to implement virtual address spaces [eg to allow Real mode applications to run without need to be remapped ]. This application level mapping was originally between the first and third levels.

Now, hypervisors provide a second level of mapping. No longer does the OS see the actual physical memory, and some features [such as memory page sharing] can be implemented].

In talking about memory, pages of memory are typically subdivided into different functions. From a physical point of view, any bit of memory is identical to any other. What matters is the OS’ interpretation of what that memory is used for.

eg:

  • Program [Text]
  • Runtime data space [Heap]
  • Runtime program space [Stack]
  • Filesystem Cache
  • Shared memory (for interprocess communication)
  • IO Buffers
  • Driver space, etc
  • Unused (eg Never-used, or no-longer-used memory)

Now here’s the crunch: Only the operating system knows what page is used for what purpose.

From an application point of view, memory can therefore either be in-use, or free. The allocation of memory at the application level is managed by the operating system via system-calls called such as malloc() and freed with free(). However, that’s the top level of abstraction.

In terms of physical memory, it’s never allocated or freed.  eg. A 16GB Windows 2003 physical machine will always have 16GB of memory. Memory is managed by operating systems for application and driver space with lists or tables of pages which are in use, or available for allocation.

But the hypervisor needs to know which pages are in use, and which are uninitialised pages. But as mentioned before, the OS memory space is a black box to the hypervisor. The OS doesn’t inform the hypervisor when a page is no longer in use. The hypervisor needs to force the operating system to be frugal with its memory management.

But this is exactly what a guest VM won’t do. From an OS’ point of view, it doesn’t know it is virtualised, and will grab all the available memory pages (and perhaps use them for something really important [programs], somewhat important [files-system cache], or perhaps never use them at all).

What the balloon driver does is force the guest OS to relinquish unused and less important OS memory [and therefore physical memory] back to the hypervisor so it can be used for more important function [eg Program space in a neighbouring VM].

The things to note are:

  • The hypervisor can allocate memory on first-use to a VM, but cannot reclaim it.
  • The hypervisor only sees allocations, not frees. Because of this, the VM will continue to grow and grow.
  • The balloon driver comes with VMware tools, and is installed by default.
  • The balloon driver is only used in circumstances of total overcommitment of memory
  • The balloon driver protects against wasteful use of resources [eg sizing VMs too large].
  • Swapping isn’t necessarily a consequence of the balloon driver activating [The memory pages it reclaims might just be free].
  • The balloon driver is preferable to the next alternative [Guest OS swapping].

For more information, see VMware TA2627

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: