Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 04 Mar 2024 12:07:18 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 277473] Virtio memory ballooning does not return unused memory to host
Message-ID:  <bug-277473-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D277473

            Bug ID: 277473
           Summary: Virtio memory ballooning does not return unused memory
                    to host
           Product: Base System
           Version: 14.0-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: laurent.chardon@gmail.com

The memory ballooning in a FreeBSD kvm/qemu guest does not seem to return t=
he
unused memory to the host.=20
The ballooning seems to happen correctly within FreeBSD, but the host might=
 not
be told properly (that's only my limited understanding as a non-expert).
This is true whether setting the current memory size automatically of manua=
lly.
Here are some scenarios to explain the problem.

=3D=3D=3D Scenario 1

With currentMemory and memory both set to 64GB in the kvm config file

$ vmstat
 procs    memory    page                      disks     faults       cpu
 r  b  w  avm  fre  flt  re  pi  po   fr   sr nd0 pa0   in   sy   cs us sy =
id
 0  0  0 429M  62G 2.3K   0  17   0 3.4K    4   0   0   76 2.2K 1.3K  0  1 =
99

neofetch shows:
Memory: 2272MiB / 65495MiB

On the Linux host, top shows:
    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMM=
AND
  57685 libvirt+  20   0   66.8g  64.2g  26112 S   0.0  51.1   1:01.37
qemu-system-x86

This is all as expected=20

=3D=3D=3D Scenario 2

With currentMemory set to 8G and memory set to 64GB in the kvm config file

$ vmstat
 procs    memory    page                      disks     faults       cpu
 r  b  w  avm  fre  flt  re  pi  po   fr   sr nd0 pa0   in   sy   cs us sy =
id
 0  0  0 429M 5.7G 3.1K   0  23   0 4.6K    4   0   0 1381 3.0K 3.5K  0  4 =
96

and now neofetch shows:
Memory: 59607MiB / 65495MiB

On the Linux host from the 'top' command:

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMM=
AND
  57062 libvirt+  20   0   66.8g  64.2g  26112 S   0.0  51.0   1:32.51
qemu-system-x86

vmstat shows less available memory than in Scenario 1, as expected.
The host however sees no difference in memory usage from FreeBSD compared to
Scenario 1. Expected: the memory usage on the host should have decreased.=20
Interestingly, neofetch sees much more memory usage than previously. I don't
know if it's relevant, but it might be a clue so I'm including this here.

=3D=3D=3D Scenario 3

With currentMemory and memory both set to 64GB in kvm config file, as in
Scenario 1. I type 'sudo virsh setmem FreeBSD 8G' on the host. FreeBSD's vm=
stat
initially shows 64G free, and transitions gradually to 5.7G free, as expect=
ed.=20
On the host side however, there is no change in the memory utilization of t=
he
FreeBSD VM. Expected: the memory usage on the host should have decreased.=20

=3D=3D=3D Test notes

The tests are done on a physical server with 32 cores (2 sockets), 64 threa=
ds,
128GB RAM.=20
The OS is Ubuntu 22.04
Other guests such as Windows and Linux behave as expected in kvm/qemu. The
memory usage inside the guest matches the memory usage seen from the host.
virtio_balloon.ko is compiled in kernel.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-277473-227>