map-sync · shipping

MAP_SYNC

MAP_SYNC is a Linux mmap flag for DAX files that keeps writable mapped data at its file offset after a crash when used with CPU persistence instructions.

Related Observatory article: Read on hesela.com

MAP_SYNC and the MAP_SHARED_VALIDATE mapping type it requires were added in Linux 4.15. Files without DAX support fail the mapping with EOPNOTSUPP. While memory is mapped writable, the data stays visible in the same file at the same offset after a crash, which with appropriate CPU instructions gives a cheaper path to persistence than a file sync call. [1]

The flag does not issue a persistence operation for each store, and a mapping contract is not multi-write atomicity. A persist call in the persistent memory development kit flushes the range and then drains, guarantees durability on return and is neither atomic nor transactional. [2]

The CPU work depends on the power-fail protected domain. When it covers only the memory controller, cache lines must be flushed and usually fenced. When it also covers CPU caches, flushes are unnecessary but barriers may still be needed for ordering. Without persistent memory, msync or fsync writes back at page granularity. [4]

Relations

related
Direct Access, Persistent memory, Persistence ordering, Crash consistency, Persistence domain

Advantages

  • Lets an application persist mapped writes with cache-line flushes and a fence instead of a page-granularity sync system call. [1, 4]

Limitations

  • A plain MAP_SHARED mapping silently ignores the flag, so a successful mapping without validation does not prove the guarantee. [1]
  • Stores can become persistent before the application calls a persist function, so recovery code cannot assume unflushed data is absent. [2]

Citations

  1. Linux man-pages. mmap(2), MAP_SYNC and MAP_SHARED_VALIDATE. (accessed 2026-10-22)
  2. PMDK 1.13.1. pmem2_get_persist_fn(3): early persistence and non-transactional semantics. (accessed 2026-10-22)
  3. PMDK 1.13.1. libpmem2(7): page, cache-line and byte store granularity. (accessed 2026-10-22)

Further reading

  1. Hesela. Persistent memory: DAX is not a durable commit. (accessed 2026-10-13)
Sources & caveats
  • mmap-docs is the Linux man-pages mmap(2) page, re-read on 2026-10-22 in the MAP_SYNC and MAP_SHARED_VALIDATE entries.
  • Linux 4.15 and EOPNOTSUPP come from mmap-docs.
  • pmdk-persist is the PMDK 1.13.1 pmem2_get_persist_fn(3) manual page, re-read on 2026-10-22.
  • pmdk-granularity is the PMDK 1.13.1 libpmem2(7) manual page, read on 2026-10-22 in the GRANULARITY section.
  • Neither mmap-docs nor the GRANULARITY section of pmdk-granularity states a cache-line or page size in bytes, so the note gives no byte granularity.

JSON: /data/terms/map-sync.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. MAP_SYNC. Hesela. 2026-10-22. https://hesela.dev/terms/map-sync/