Memory mirroring for a ring buffer on Linux Memory mirroring for a ring buffer on Linux linux linux

Memory mirroring for a ring buffer on Linux


This is not possible to achieve with anonymous mappings. You can, however, use memfd_create(2) or create a temporary file on tmpfs (so that it won't ever be stored to disk, except by "swapping") and do shared mappings on that file descriptor, adjacent to each other.

remap_file_pages(2) is just a performance hack and not any more powerful than classic mmap/mremap calls, and it can't operate on anonymous mappings either.

Related: Linux mremap without freeing the old mapping?