On 21/05/2025 05:22, Nguyễn Hữu Khôi wrote:
> Hello.
>
> I have an OpenStack instance that was using 14GB out of 16GB of
> memory. Later, when it was using only 4GB, I checked the QEMU process
> on the compute node, and it was still consuming 14GB, this means
> memory isn't released when usage decreases.
correct this is the current designed behavior.
while the mem balloon is enable there has never been support for using
that to free unallcoated memory when teh guest frees pages
the men-ballon was originally added in nova purely to allow gathering
guest memory statistics.
if your over allocating memory in nova your required to have sufficient
swap space so that the kernel can page out the inactive memory.
>
> Do we have solutions for this? I use Ubuntu 24.04 instances.
It would be a new RFE
its not one that we have not consiered before but its just never been a
priority since this is not how we expect to over subsribe.
we over subscribe via swap space. runing nova without swap leads to the
python interpreture usign more memory then required
otherwise, that partly why we do not recommend running without swap even
if guest memory oversubscribe is not planned.
since swap shoudl alwasy be present on compute nodes it the natural
extension prefer it for oversubscribtion and let the kernel
manage paging then maintaining another agent or requireing you to use an
external one.
libvirt has gained some funtionality in thsi space that i have consiered
writign a patch to enable
https://libvirt.org/formatdomain.html#memory-balloon-device
specificly
```
autodeflate
The optional autodeflate attribute allows to enable/disable (values
"on"/"off", respectively) the ability of the QEMU virtio memory
balloon to release some memory at the last moment before a guest's
process get killed by Out of Memory killer. Since 1.3.1, QEMU and
KVM only
freePageReporting
The optional freePageReporting attribute allows to enable/disable
("on"/"off", respectively) the ability of the QEMU virtio memory
balloon to return unused pages back to the hypervisor to be used by
other guests or processes. Please note that despite its name it has
no effect on free memory as reported by virDomainMemoryStats()
and/or virsh dommemstat. Since 6.9.0, QEMU and KVM only
```
auto deflate would make sent to enable unconditionally in an opnestack
env for deomains not using file or hugepage backed memory.
freePageReporting is the value that peaked my interest on this topic
most recently. in caracal we finally got our min libvirt version high enough
to be able to use it un contiontally as well.
thats the feature you want and its not hard to add i just have not had
time to work on this lately.
if you want to submit a patch to work on those i think this could be
covered as a small specless blueprint.
prior to caracal this would have been much more painfail to enabel as
nova woudl have needed to implement an agent to do the memroy freeign.
that is what proxymox and ovirt have done in the past to get the same
effect.
now that libvirt has native support we can just turn it on and let it do
it on our behalf.
>
> Nguyen Huu Khoi