Projects/auto-ballooning

From KVM
Revision as of 09:05, 12 December 2012 by LuizCapitulino (talk | contribs)

Auto-ballooning

When a Linux host is running out of memory, the kernel will take action to reclaim memory. This action may be detrimental to kvm guests performace (eg. swapping) or even extreme to the point where the kernel kills user-space processes (which could be a kvm guest itself or a virt stack component).

To help avoiding this situation, a kvm guest could automatically inflate its balloon (thus returning memory to the host) when the host is facing memory pressure. Likewise, a kvm guest could automatically deflate its balloon when the guest itself is facing memory pressure (maybe due to automatic inflate).

The goal of this page is to collect ideas on how to implement auto-ballooning. Currently, there is only one proposal, which is the "automatic balance" idea, mostly designed by Rik van Riel.

Automatic balance

In automatic balance, the hypervisor (eg. QEMU) must have a way to detect that the host is under memory pressure. When this happens, QEMU could automatically inflate the guest's balloon to some value (say 10MB). When it's the guest that's facing memory pressure, its balloon driver could automatically deflate the memory balloon.

It's expected that inflate and deflate will balance each other over time.

Next sections describe the implementation details of this idea.

auto-inflate

There are two components needed to make auto-inflate work.

  • A (host) kernel API to let user-space processes know when the kernel is facing memory pressure
  • QEMU changes to use the host kernel API, and to inflate the guest's balloon when the host kernel is facing memory pressure

auto-deflate

Only one component is needed for auto-deflate

  • The guest virtio-balloon driver must be changed to automatically deflate the balloon when the guest is facing memory pressure

status

FIXME: add tree.

testing

FIXME: describe.