{
  "slug": "posix-fadv-willneed",
  "term": "POSIX_FADV_WILLNEED",
  "aliases": [
    "FADV_WILLNEED"
  ],
  "definition": "POSIX_FADV_WILLNEED is file-access advice announcing that an application expects to read a specified range soon.",
  "note": "The advice covers a region that starts at offset and extends for size bytes. A size of 0 means through the end of the file, although before Linux 2.6.6 it was taken literally as zero bytes. Linux uses this hint to initiate a nonblocking page-cache read, and memory pressure can reduce the amount fetched. The advice is nonbinding; a zero result is not a count of resident bytes. posix_fadvise returns an error number directly on failure. [fadvise-api]\n\nIn Linux v6.17, generic_fadvise rounds the range out to include the first and last partial pages and passes that page count to force_page_cache_readahead. It accepts and ignores advice for DAX or a noop backing device, and returns ESPIPE for a FIFO. Filesystems may override the generic implementation. [fadvise-617]\n\nIn Linux v6.14 the downstream force_page_cache_ra helper bounds explicit prefetch by max(io_pages, ra_pages); requesting through EOF does not promise that all those pages will be loaded. [readahead-614]",
  "advantages": [
    {
      "text": "The hint lets applications overlap useful work with data prefetch; successful submission is not a completion barrier.",
      "citationIds": [
        "fadvise-api"
      ]
    },
    {
      "text": "Kernel support dates from Linux 2.5.60 and the glibc wrapper from glibc 2.2, so the interface is long established.",
      "citationIds": [
        "fadvise-api"
      ]
    }
  ],
  "limitations": [
    {
      "text": "Prefetch advice does not pin the requested data in memory or promise a faster subsequent read.",
      "citationIds": [
        "fadvise-api"
      ]
    },
    {
      "text": "Since Linux 3.18 the underlying fadvise64 system call is optional, depending on CONFIG_ADVISE_SYSCALLS.",
      "citationIds": [
        "fadvise-api"
      ]
    }
  ],
  "related": [
    "posix-fadvise",
    "readahead",
    "rwf-nowait",
    "page-cache",
    "buffered-io",
    "posix-fadv-dontneed",
    "dax",
    "prefetch-wastage",
    "prefetch-trigger-distance"
  ],
  "citations": [
    {
      "id": "fadvise-api",
      "title": "Linux man-pages 6.19: posix_fadvise(2), advice and return conventions",
      "url": "https://man7.org/linux/man-pages/man2/posix_fadvise.2.html",
      "accessed": "2026-10-23"
    },
    {
      "id": "fadvise-617",
      "title": "Linux v6.17: generic_fadvise and filesystem-specific dispatch",
      "url": "https://raw.githubusercontent.com/torvalds/linux/v6.17/mm/fadvise.c",
      "accessed": "2026-10-23"
    },
    {
      "id": "hesela-probe",
      "title": "Hesela: invalid-descriptor API observations, environment and source hashes",
      "url": "https://hesela.dev/research/prefetch-errors/result.json",
      "accessed": "2026-10-17"
    },
    {
      "id": "readahead-614",
      "title": "Linux v6.14 mm/readahead.c: file_ra_state_init, force_page_cache_ra and ractl_max_pages",
      "url": "https://github.com/torvalds/linux/blob/v6.14/mm/readahead.c",
      "accessed": "2026-11-08"
    }
  ],
  "status": "shipping",
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-11",
  "provenance": [
    "fadvise-api is the Linux man-pages 6.19 posix_fadvise(2) page, re-read for the region semantics, the 2.6.6 zero-length fix, WILLNEED behavior and the version history.",
    "fadvise-617 is mm/fadvise.c at v6.17, re-read on git.kernel.org at the same tag for page rounding, the DAX and noop-device branch and the FIFO check.",
    "hesela-probe is a three-call invalid-descriptor probe of posix_fadvise, readahead and preadv2 error channels. It is not a prefetch or filesystem-support benchmark.",
    "The posix-fadv-dontneed entry links here because it is the opposite advice on the same interface.",
    "2026-11-08: reviewed the downstream v6.14 prefetch bound; softened an unconditional nonblocking/fetched-range advantage. No measured speedup."
  ]
}
