{
  "slug": "map-sync",
  "term": "MAP_SYNC",
  "aliases": [],
  "definition": "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.",
  "note": "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. [mmap-docs]\n\nThe 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. [pmdk-persist]\n\nThe 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. [pmdk-granularity]",
  "status": "shipping",
  "advantages": [
    {
      "text": "Lets an application persist mapped writes with cache-line flushes and a fence instead of a page-granularity sync system call.",
      "citationIds": [
        "mmap-docs",
        "pmdk-granularity"
      ]
    }
  ],
  "limitations": [
    {
      "text": "A plain MAP_SHARED mapping silently ignores the flag, so a successful mapping without validation does not prove the guarantee.",
      "citationIds": [
        "mmap-docs"
      ]
    },
    {
      "text": "Stores can become persistent before the application calls a persist function, so recovery code cannot assume unflushed data is absent.",
      "citationIds": [
        "pmdk-persist"
      ]
    }
  ],
  "related": [
    "dax",
    "persistent-memory",
    "persistence-ordering",
    "crash-consistency",
    "persistence-domain"
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-10-22",
  "citations": [
    {
      "id": "mmap-docs",
      "title": "Linux man-pages. mmap(2), MAP_SYNC and MAP_SHARED_VALIDATE.",
      "url": "https://man7.org/linux/man-pages/man2/mmap.2.html",
      "accessed": "2026-10-22"
    },
    {
      "id": "pmdk-persist",
      "title": "PMDK 1.13.1. pmem2_get_persist_fn(3): early persistence and non-transactional semantics.",
      "url": "https://github.com/pmem/pmdk/blob/1.13.1/doc/libpmem2/pmem2_get_persist_fn.3.md",
      "accessed": "2026-10-22"
    },
    {
      "id": "hesela-pmem",
      "title": "Hesela. Persistent memory: DAX is not a durable commit.",
      "url": "https://hesela.com/analyses/pmem-persistence-domains-dax/",
      "accessed": "2026-10-13"
    },
    {
      "id": "pmdk-granularity",
      "title": "PMDK 1.13.1. libpmem2(7): page, cache-line and byte store granularity.",
      "url": "https://github.com/pmem/pmdk/blob/1.13.1/doc/libpmem2/libpmem2.7.md",
      "accessed": "2026-10-22"
    }
  ],
  "provenance": [
    "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."
  ]
}
