Is there a technical reason why memory ballooning can't return memory to the host?

is there a technical reason why memory ballooning can’t return memory to the host?

In a long quest of mis-understanding memory ballooning, this post got through to me, specifically the notion that ballooning is only intended to deal with guest-to-guest over commit conflict resolution, and nothing else.

it may be, that I am the only person in the world who wants to use my host while also running virtual machines on the same host, if I were a crazy person and went to go build a version of libvirtd/qemu that actually freed the memory reclaimed by a balloon driver back to the system, is that like an absolutely terrible idea?

and if it is a terrible idea, would it be more ideal to make a sort of fake-guest to assign that unused ram to, and join that ram to the system with some kind of terrible swap-backed-by-ramdisk arrangement?

redit user writes:

joey_shabadoos_bro

6 years ago
I think you may be confused about what ballooning is for. It is to reclaim memory from a guest, not increase allocated RAM. When the hypervisor is short on RAM, it inflates the memory usage of a device in a vm that talks to the hypervisor. This causes the guest to free cache and give it to the balloon driver.

The hypervisor now knows that it can use this RAM for other guests suffering from a shortage of memory. This only happens when the host runs out of free memory. If ballooning of guest’s drivers doesn’t free up enough, the host starts to swap.

http://www.linux-kvm.org/page/Projects/auto-ballooning

I’d say no, especially in this day and age with huge pages in TLBs.

I don’t use ballooning with my KVM setup. (no special reason - just never got around to it… they mostly either spin up/down with workload or I actually want them to have a fixed amount of ram reserved and available on demand)…

Also, containers fit in more naturally here if all your workloads are Linux based server type things.

With hyper-v on the desktop where it’s annoyingly aggressive (and years ago with xen) it does (did) return to host.

1 Like