Tomasz Wendlandt

Avatar

Tech blog

Linux 2.6.32 Kernel Samepage Merging and Virtualization

W niedawno wydanym Kernelu 2.6.32 dodano ciekawy ficzer z punktu widzenia wirtualizacji – Kernel Samepage Merging, wcześniej znany jako Kernel Shared Memory. Specjalny daemon kernel, ksmd skanuje pamięć w poszukiwaniu takich samych stron, które można zastąpić pojedyńczym wpisem. Jak podaje http://kernelnewbies.org przyczynia się to do bardzo dużego obniżenia zużycia pamięci w środowiskach wirtualizowanych.

Modern operative systems already use memory sharing extensively, for example forked processes share initially with its parent all the memory, there are shared libraries, etc. Virtualization however can’t benefit easily from memory sharing. Even when all the VMs are running the same OS with the same kernel and libraries the host kernel can’t know that a lot of those pages are identical and can be shared. KSM allows to share those pages. The KSM kernel daemon, ksmd, periodically scans areas of user memory, looking for pages of identical content which can be replaced by a single write-protected page (which is automatically COW’ed if a process wants to update it). Not all the memory is scanned, the areas to look for candidates for merging are specified by userspace apps using madvise(2): madvise(addr, length, MADV_MERGEABLE).

The result is a dramatic decrease in memory usage in virtualization environments. In a virtualization server, Red Hat found that thanks to KSM, KVM can run as many as 52 Windows XP VMs with 1 GB of RAM each on a server with just 16 GB of RAM. Because KSM works transparently to userspace apps, it can be adopted very easily, and provides huge memory savings for free to current production systems. It was originally developed for use with KVM, but it can be also used with any other virtualization system – or even in non virtualization workloads, for example applications that for some reason have several processes using lots of memory that could be shared.

http://lwn.net/Articles/306704/
http://lwn.net/Articles/330589/

No Comments, Comment or Ping

Reply to “Linux 2.6.32 Kernel Samepage Merging and Virtualization”

Poznań

  • Mist
  • Temperature: -1°C
  • Visibility: 5km
  • Conditions: Mist
  • Clouds: Broken Clouds at 1158m
  • Wind: ESE at 11 km/h
  • Barometer: 1030 hPa
  • Humidity: 86.2%
  • Sunrise: 8:07 GMT+2
  • Sunset: 20:14 GMT+2