Monday, August 8, 2011

Memory Management in VM

Memory Over Commitment:-
Transperent Page sharing
Memoery Ballooning
Hypervisor Swapping
Memory Comperssion
----------------------------------------------------
On a physical server MMU is part of Mother board which allocates memoery to OS.
For Virtual machines just like the how Physical have dedicated Hardware MMU to manage memory on the OS.MMU is virtulized for VM using either software using Shadow page tables or Hardware Intel EPT(extended page tables) or AMD RVI (Rapid Virtulized Index).

When a VM starts it has no physical RAM allocated to it and RAM is allocated as needed and recliamed when not in use using Transperent Page sharing,Memoery Ballooning,Hypervisor Swapping and Memory Comperssion 4.1.

Hypervisor  use Pmap  for each VM.Pmap manages what the VM's has to the host Physical Memoery.
Shaow pages tables in Hypervisor handles what Guest VM and Host pysical and SPtables are used by the MMU

http://software.intel.com/en-us/articles/best-practices-for-paravirtualization-enhancements-from-intel-virtualization-technology-ept-and-vt-d/

Hardware Page Table Virtualization provides a hardware assist to memory virtualization, which includes the partitioning and allocation of physical memory among VMs. Memory virtualization causes VMs to see a contiguous address space, which is not actually contiguous within the underlying physical memory. The guest OS stores the mapping between virtual and physical memory addresses in page tables.

Because the guest OSs do not have native direct access to physical system memory, the VMM must perform another level of memory virtualization in order to accommodate multiple VMs simultaneously. That is, mapping must be performed within the VMM between the physical memory and the page tables in the guest OSs. In order to accelerate this additional layer of memory virtualization, both Intel and AMD have announced technologies to provide a hardware assist. Intel's is called Extended Page Tables (EPT), and AMD's is called Nested Page Tables (NPT). These two technologies are very similar at a conceptual level.

Transperent Page sharing:-
Vsphere reclaims memeory by removing redundant memoery pages with identical Content.This is similar to
Dedupe performed on Stroage volumes.Say if you have three VM with 2008 any identiacal meomory among the three is hashed so that memory can be reclaimed through transparent page sharing.

Memoery Ballooning:-
VMEMCTL is loaded into guest OS using VM's tools this puts presure on the Guest OS when hypervisor runs low on memoery .Guest OS invokes its memoery cleanup and reclimation process freeing up pages for the ballon so the physical memoery pages assigned to ballon are free for other VM's.

Hypervisor Swapping.:- more latency becoz host need to swap memeory to disk and free up the Page and memoery.

Memoery Comperssion:
Host memmory Pages swapped out are stored in a compressed format in the host memoery for faster access.


No comments:

Post a Comment