madv-remove · shipping · also Linux MADV_REMOVE

MADV_REMOVE

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.

Related Observatory article: MADV_REMOVE on hesela.com

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. [1] [3]

Mapping 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. [2] [1]

Storage 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. [3] [4]

Comparison: 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. [5]

Failure 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. [1]

Relations

related
Hole punching, MADV_DONTNEED, MADV_FREE, Memory-mapped file, Sparse file

Advantages

  • Can deallocate a backing-object range through its mapping while preserving logical length. [1, 3]

Limitations

  • Requires an eligible shared mapping and hole-punching support; it changes file content. [1, 3]

Citations

  1. Linux v6.14: anonymous lazy-free and shared backing-object removal (accessed 2026-11-09)
  2. Linux v6.14: vma_is_shared_maywrite and mapping capability (accessed 2026-11-09)
  3. Linux man-pages: fallocate(2), hole punching and KEEP_SIZE (accessed 2026-11-09)
  4. Linux man-pages: fsync(2), file-data and metadata synchronization (accessed 2026-11-09)
  5. Hesela: lazy discard is not backing-file removal (accessed 2026-11-09)

JSON: /data/terms/madv-remove.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. MADV_REMOVE. Hesela. 2026-11-09. https://hesela.dev/terms/madv-remove/