From f3dfbb4f78d521a277ccacd344339811191feb3e Mon Sep 17 00:00:00 2001 From: Job79 Date: Sat, 14 Nov 2026 22:43:34 +0100 Subject: [PATCH] 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 --- README.md | 2 +- mkosi.conf | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 13ba6f3..dcb79c5 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,6 @@ mkosi build ```sh qemu-img convert -O qcow2 mkosi.output/git-runner_.raw test.qcow2 && qemu-img resize test.qcow2 40G 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 ``` diff --git a/mkosi.conf b/mkosi.conf index 72a6b2b..52ef971 100644 --- a/mkosi.conf +++ b/mkosi.conf @@ -53,13 +53,20 @@ Locale=C.UTF-8 UnifiedKernelImageFormat=%i_%v # 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 -# 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= console=tty0 console=ttyS0,115200n8 quiet systemd.machine_id=firmware 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 init_on_alloc=1 randomize_kstack_offset=on