On Mon, Sep 29, 2014 at 9:55 PM, Daniel Micay [off-list ref] wrote:
This introduces the MREMAP_RETAIN flag for preserving the source mapping
when MREMAP_MAYMOVE moves the pages to a new destination. Accesses to
the source location will fault and cause fresh pages to be mapped in.
For consistency, the old_len >= new_len case could decommit the pages
instead of unmapping. However, userspace can accomplish the same thing
via madvise and a coherent definition of the flag is possible without
the extra complexity.
IMO this needs very clear documentation of exactly what it does.
Does it preserve the contents of the source pages? (If so, why?
Aren't you wasting a bunch of time on page faults and possibly
unnecessary COWs?)
Does it work on file mappings? Can it extend file mappings while it moves them?
If you MREMAP_RETAIN a partially COWed private mapping, what happens?
Does it work on special mappings? If so, please prevent it from doing
so. mremapping x86's vdso is a thing, and duplicating x86's vdso
should not become a thing, because x86_32 in particular will become
extremely confused.
--Andy