readahead · shipping · also readahead(2)

readahead (Linux syscall)

The Linux readahead syscall requests advance loading of a file range into the page cache without advancing the open file description's offset.

Related Observatory article: Read on hesela.com

Ranges are handled in whole pages and stop at end of file. Success returns zero, not a fetched-byte count; errors return -1 and set errno. EBADF reports a descriptor that is invalid or not open for reading, and EINVAL a file type that does not support the call. Subsequent reads benefit only if data arrives in time and remains cached. The call exists since Linux 2.4.13 and glibc 2.3. [1]

The call may block while locating blocks through filesystem metadata, including the documented ext2/ext3/ext4 indirect-block case. Background data reads therefore do not establish a hard nonblocking-call guarantee. [1]

The backing-device budget is not an absolute ceiling for every read. Linux v6.14 initializes per-open state from it; SEQUENTIAL doubles that state, and large demand requests can use io_pages. [4] [5]

Explicit prefetch is also bounded: force_page_cache_ra limits the requested page count to max(io_pages, ra_pages) before chunking. Success does not certify whole-range residency. [4]

ATA drive read look-ahead is a separate device feature, not this file-to-page-cache syscall. hdparm -A controls that feature; -a controls software filesystem readahead. [6]

Relations

related
POSIX_FADV_WILLNEED, RWF_NOWAIT, Page cache, Buffered I/O, Prefetch wastage, Prefetch trigger distance, POSIX_FADV_RANDOM, POSIX_FADV_SEQUENTIAL, ATA read look-ahead, Informed prefetching

Advantages

  • Because the file offset is left unchanged, prefetching does not disturb a reader that shares the open file description. [1]

Limitations

  • This Linux-specific interface is distinct from the general automatic read-ahead policy triggered by ordinary reads. [1]
  • On some 32-bit architectures the system call signature differs, and portable callers need _FILE_OFFSET_BITS defined as 64. [1]

Citations

  1. Linux man-pages 6.19: readahead(2), ranges, return values and metadata blocking (accessed 2026-10-23)
  2. Linux v6.14 mm/readahead.c: file_ra_state_init, force_page_cache_ra and ractl_max_pages (accessed 2026-11-08)
  3. Linux v6.14 mm/fadvise.c: generic advice and SEQUENTIAL budget (accessed 2026-11-08)
  4. hdparm(8): separate -a software readahead and -A drive read-lookahead controls (accessed 2026-11-14)

Further reading

  1. Linux 7.3: Documentation/ABI/stable/sysfs-block, read_ahead_kb (accessed 2026-10-23)
  2. Linux 7.3: include/linux/pagemap.h, VM_READAHEAD_PAGES (accessed 2026-10-23)
Sources & caveats
  • readahead-api is the Linux man-pages 6.19 readahead(2) page, re-read for page rounding, return values, errors, history and the metadata blocking bug.
  • sysfs-block is the stable block-device sysfs ABI in Linux 7.3, read for the read_ahead_kb attribute.
  • pagemap is include/linux/pagemap.h in Linux 7.3, read for the VM_READAHEAD_PAGES default.
  • The posix-fadv-noreuse entry links here because POSIX_FADV_NOREUSE leaves the readahead window size unchanged while other advice values alter it.
  • 2026-11-08 correction: replaced unconditional device-cap wording and default-size implication with version-pinned budget/dispatch distinctions. Source review, not a kernel benchmark.

JSON: /data/terms/readahead.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. readahead (Linux syscall). Hesela. 2026-11-14. https://hesela.dev/terms/readahead/