Give memory unused for an hour back to the host

damon_reclaim pages out memory that hasn't been touched for an hour, whatever
memory is free, so virtio-balloon free page reporting can return it to the
host. The test VM in the README gets a balloon device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Job79andClaude Opus 5.5 committed 2026-11-14 22:43:54 +01:00
1 parent 92a21ae607
commit f3dfbb4f78
2 files changed
+9 -2

No files matched your search

+1 -1
View File
@@ -33,6 +33,6 @@ mkosi build
```sh ```sh
qemu-img convert -O qcow2 mkosi.output/git-runner_<version>.raw test.qcow2 && qemu-img resize test.qcow2 40G qemu-img convert -O qcow2 mkosi.output/git-runner_<version>.raw test.qcow2 && qemu-img resize test.qcow2 40G
cp /usr/share/edk2/ovmf/OVMF_VARS.fd vars.fd cp /usr/share/edk2/ovmf/OVMF_VARS.fd vars.fd
qemu-kvm -m 8G -smp 4 -cpu host -nic user,model=virtio-net-pci -drive file=test.qcow2,if=virtio \ qemu-kvm -m 8G -smp 4 -cpu host -nic user,model=virtio-net-pci -drive file=test.qcow2,if=virtio -device virtio-balloon-pci,free-page-reporting=on \
-drive if=pflash,format=raw,readonly=on,file=/usr/share/edk2/ovmf/OVMF_CODE.fd -drive if=pflash,format=raw,file=vars.fd -drive if=pflash,format=raw,readonly=on,file=/usr/share/edk2/ovmf/OVMF_CODE.fd -drive if=pflash,format=raw,file=vars.fd
``` ```
+8 -1
View File
@@ -53,13 +53,20 @@ Locale=C.UTF-8
UnifiedKernelImageFormat=%i_%v UnifiedKernelImageFormat=%i_%v
# The console on screen and serial port, the machine ID from the VM's firmware (/etc is read-only; # The console on screen and serial port, the machine ID from the VM's firmware (/etc is read-only;
# mkosi.extra/etc/machine-id is empty, so no boot counts as the first), no systemd-firstboot # mkosi.extra/etc/machine-id is empty, so no boot counts as the first), no systemd-firstboot
# questions (gitea-runner-setup asks its own), and KSPP hardening (the last four). # questions (gitea-runner-setup asks its own), freeing memory unused for an hour (damon_reclaim, in
# µs; the watermarks make it run whatever memory is free), so the host can take it back
# (virtio-balloon free page reporting), and KSPP hardening (the last four).
KernelCommandLine= KernelCommandLine=
console=tty0 console=tty0
console=ttyS0,115200n8 console=ttyS0,115200n8
quiet quiet
systemd.machine_id=firmware systemd.machine_id=firmware
systemd.firstboot=no systemd.firstboot=no
damon_reclaim.enabled=Y
damon_reclaim.min_age=3600000000
damon_reclaim.wmarks_high=1000
damon_reclaim.wmarks_mid=999
damon_reclaim.wmarks_low=0
slab_nomerge slab_nomerge
init_on_alloc=1 init_on_alloc=1
randomize_kstack_offset=on randomize_kstack_offset=on