Page cache
The page cache is the kernel-managed memory that holds cached file contents for access and writeback.
Linux iomap manages cached folios and their up-to-date and dirty state. Its direct-I/O path still flushes dirty cached data and invalidates cached ranges where required, so bypassing cached transfers does not eliminate coherence work. [1]
Linux exposes a drop_caches control in the vm sysctl directory. Writing 1 frees clean page cache, 2 frees reclaimable slab objects such as dentries and inodes, and 3 frees both, while 4 (bit 2) silences the log message. Dirty objects are never freed, so flushing beforehand increases what can be dropped. [2]
The control does not limit cache growth, because cached objects are reclaimed automatically when memory is needed elsewhere. Rebuilding dropped objects can cost significant I/O and CPU, so its use outside testing or debugging is not recommended. In Linux v6.16 the default readahead window is 128 KiB, defined as VM_READAHEAD_PAGES. [2] [3]
Relations
- related
- Buffered I/O, Direct I/O, Write-back cache, Writeback error, POSIX_FADV_NOREUSE, POSIX_FADV_DONTNEED, RWF_DONTCACHE, Memory-mapped file, RWF_NOWAIT, POSIX_FADV_WILLNEED, readahead (Linux syscall), mincore, Process I/O accounting, FUSE writeback-cache, FastMap, Working set, Locality of reference, cachestat, cache_ext, Programmable Page Cache (PPC), tmpfs, Dirty-page throttling, Geiger
Advantages
- Can serve reusable file contents from memory. [1]
- Clean cached pages are reclaimed automatically under memory pressure, without manual tuning. [2]
Limitations
- A cached copy is not an independent backup or proof of durable storage. [1]
- Rebuilding dropped cache objects can incur extra I/O and CPU work; clearing caches changes the initial state of a benchmark. [2]
Citations
- Linux v6.17: iomap supported file operations, sections 2.2.1-2.2.3.
- Linux v6.16 documentation: Documentation for /proc/sys/vm/
- Linux v6.16 include/linux/pagemap.h: VM_READAHEAD_PAGES
Sources & caveats
- iomap is the Linux v6.17 iomap operations page, kept from the earlier version.
- vm-sysctl is the Linux v6.16 sysctl vm documentation, read in the drop_caches section on the access date.
- pagemap-src is include/linux/pagemap.h at tag v6.16, read for VM_READAHEAD_PAGES = SZ_128K / PAGE_SIZE.
- 1, 2, 3 and 4 (bit 2) come from vm-sysctl. 128 KiB comes from pagemap-src.