Projects/auto-ballooning

From KVM
Revision as of 21:37, 11 December 2012 by LuizCapitulino (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Auto-ballooning

When a kvm host is running out of memory, the host 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 those scenarios, the hypervisor (eg. QEMU) could automatically inflate the guest's balloon (thus returning memory to the host). This will also require a method for automatically deflating the guest's memory, so that fairness is ensured and the guest kernel doesn't run itself into trouble.

The object 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) automatically inflates the guest balloon when the host kernel is under memory pressure. On the other hand, when the guest kernel is under memory pressure, it will automatically try to deflate its balloon (which possibly may have been inflated by the hypervisor).

It's expected that automatic inflate and deflate can balance each other.

Next sections describe the implementation details of this idea.

auto-inflate

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

1. A host kernel API to let user-space processes know when the kernel is facing memory pressure

2. 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:

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

Status