Repository navigation
Conversation
JartX
force-pushed
the
free-page-reporting
branch
from
October 26, 2026 08:59
d99d5dc to
b998dff
Compare
On macOS, libkrun's balloon madvise()s the pages the guest reports as free, which doesn't release the pages the guest has written to: a VM's phys_footprint only grows, up to the RAM it was given, even after the guest frees the memory. libkrun can give them back by replacing them with fresh memory, and krun_set_balloon_free_page_reporting_mode() selects that (KRUN_FREE_PAGE_REPORTING_MODE_REPLACE). Add --free-page-reporting default|replace to call it. Without the option krunkit doesn't call it, so nothing changes. The function is newer than the rest of the libkrun API krunkit uses, so it's looked up with dlsym() when the option is used: krunkit still starts with a libkrun that doesn't have it, and the option fails with an error that says so. On a 3 GiB guest booted through Colima, writing and freeing 1.5 GiB of tmpfs gave 1364 MiB back to the host with --free-page-reporting replace, and 0 without it. Assisted-by: Claude Code / claude-opus-5.5 Signed-off-by: JartX <sagformas@epdcenter.es>
JartX
force-pushed
the
free-page-reporting
branch
from
October 26, 2026 09:00
b998dff to
9010731
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
--free-page-reporting default|replace, which calls libkrun'skrun_set_balloon_free_page_reporting_mode().On macOS, libkrun's balloon
madvise()s the pages the guest reports as free, which doesn't release the pages the guest has written to. A VM's footprint only grows, up to the RAM it was given, even after the guest frees the memory. libkrun can give those pages back by replacing them with fresh memory (#931 on main). This option lets krunkit, and through it Colima and Podman, turn that on.Without the option krunkit doesn't call the function, so nothing changes. The function is newer than the rest of the libkrun API krunkit uses, so it's looked up with
dlsym()only when the option is given. krunkit still starts with a libkrun that doesn't have it, and the option fails with an error that says what's missing.Draft: this depends on libkrun/libkrun#941, which adds the function to
stable-1.19.x. It can't be merged until a libkrun with it is released.Testing:
cargo test(39 passed, including two new tests),cargo clippyandcargo fmt --checkare clean. With libkrun#941 (f3fec24e) built from source, I booted a 3 GiB guest through Colima with this krunkit, wrote 1.5 GiB to tmpfs and freed it:--free-page-reporting replacereplacewith a libkrun without the function--free-page-reporting needs a libkrun with krun_set_balloon_free_page_reporting_mode()