vmm: Revert "vmm: create memfd for private mappings" - #8246
Conversation
This reverts commit ced3762. This change lead to a serious memory regression when not using hugepages or shared=on. `MAP_PRIVATE` creates an anonymous memory allocation for every page written when the backing store is a file. This CoW behaviour is useful but leads to double allocations when the backing store is an empty file created by `memfd_create()`. When the page is written to, the CoW semantics require a real page to be created in the memory for the memfd (previously before the page was touched they would all point to the zero page). This real page is filled with zeroes because in theory this page would be accessible via read/write syscalls on the FD even though in our implementation it is only ever `mmap()`ed. The intention of the commit was to enable `fallocate()` to be used to punch holes but that would only affect the inaccessible backing page and the page in the CoW anonymous memory would be unaffected. Leading it likely not to have the desired effect. Fixes: cloud-hypervisor#8211 Signed-off-by: Rob Bradford <[email protected]>
|
I also considered fixing it by using |
|
@phip1611 It's strange how this didn't affect the Windows runs on the PR itself or later ones. Nor was it picked up by the |
weltling
left a comment
There was a problem hiding this comment.
I've been experimenting with this for several hours, too. The OOM symptom
could be fixed by readding MAP_ANONYMOUS, but that would undermine the initial intention for fallocate. The behaviors probably need to be tied to the console options, so then corresponding flags combinations would be used.
Thanks!
This reverts commit ced3762.
This change lead to a serious memory regression when not using hugepages
or shared=on.
MAP_PRIVATEcreates an anonymous memory allocation for every pagewritten when the backing store is a file. This CoW behaviour is useful
but leads to double allocations when the backing store is an empty file
created by
memfd_create(). When the page is written to, the CoWsemantics require a real page to be created in the memory for the memfd
(previously before the page was touched they would all point to the zero
page). This real page is filled with zeroes because in theory this page
would be accessible via read/write syscalls on the FD even though in our
implementation it is only ever
mmap()ed.The intention of the commit was to enable
fallocate()to be used topunch holes but that would only affect the inaccessible backing page and
the page in the CoW anonymous memory would be unaffected. Leading it
likely not to have the desired effect.
Fixes: #8211
Signed-off-by: Rob Bradford [email protected]