{
  "slug": "madv-remove",
  "term": "MADV_REMOVE",
  "aliases": [
    "Linux MADV_REMOVE"
  ],
  "definition": "MADV_REMOVE is a Linux memory-advice operation that punches a hole in the backing object of an eligible shared mapping without changing the object's logical size.",
  "note": "Backing-object change: Linux v6.14 converts the advised virtual range to a file offset and calls hole punching with KEEP_SIZE. This changes the backing object, not merely the caller's cached view. Reads within the affected part of the object's logical extent return zeros until another write changes it. [linux-madvise-v614] [fallocate-api]\n\nMapping capability: the pinned kernel tests VM_SHARED and VM_MAYWRITE, not current VM_WRITE alone. A presently read-only mapping can retain potential write capability. This is a versioned implementation detail, not permission to ignore file access checks or filesystem support. [linux-mm-v614] [linux-madvise-v614]\n\nStorage limits: whole filesystem blocks may be deallocated while partial blocks are zeroed. Requested bytes therefore need not equal released allocation. Logical removal does not prove secure erasure or power-loss persistence; synchronization remains a separate requirement. [fallocate-api] [fsync-api]\n\nComparison: MADV_DONTNEED can discard a private view without punching a hole in its file; MADV_FREE instead addresses disposable private anonymous memory. The companion analysis separates these contracts from its earlier measured discard experiment. [hesela-advice-scope]\n\nFailure scope: an unmapped gap can produce ENOMEM even when mapped parts were processed. An error is not an unchanged-data guarantee. The v6.14 walker retains earlier effects if a later mapping fails. [linux-madvise-v614]",
  "status": "shipping",
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-09",
  "advantages": [
    {
      "text": "Can deallocate a backing-object range through its mapping while preserving logical length.",
      "citationIds": [
        "linux-madvise-v614",
        "fallocate-api"
      ]
    }
  ],
  "limitations": [
    {
      "text": "Requires an eligible shared mapping and hole-punching support; it changes file content.",
      "citationIds": [
        "linux-madvise-v614",
        "fallocate-api"
      ]
    }
  ],
  "related": [
    "hole-punching",
    "madv-dontneed",
    "madv-free",
    "memory-mapped-file",
    "sparse-file"
  ],
  "citations": [
    {
      "id": "linux-madvise-v614",
      "title": "Linux v6.14: anonymous lazy-free and shared backing-object removal",
      "url": "https://github.com/torvalds/linux/blob/v6.14/mm/madvise.c",
      "accessed": "2026-11-09"
    },
    {
      "id": "linux-mm-v614",
      "title": "Linux v6.14: vma_is_shared_maywrite and mapping capability",
      "url": "https://github.com/torvalds/linux/blob/v6.14/include/linux/mm.h",
      "accessed": "2026-11-09"
    },
    {
      "id": "fallocate-api",
      "title": "Linux man-pages: fallocate(2), hole punching and KEEP_SIZE",
      "url": "https://man7.org/linux/man-pages/man2/fallocate.2.html",
      "accessed": "2026-11-09"
    },
    {
      "id": "fsync-api",
      "title": "Linux man-pages: fsync(2), file-data and metadata synchronization",
      "url": "https://man7.org/linux/man-pages/man2/fsync.2.html",
      "accessed": "2026-11-09"
    },
    {
      "id": "hesela-advice-scope",
      "title": "Hesela: lazy discard is not backing-file removal",
      "url": "https://hesela.com/analyses/mmap-visibility-size-durability/#lazy-discard-backing-store",
      "accessed": "2026-11-09"
    }
  ]
}
