Skip to content

CONCEPT Cited by 2 sources

Linux page cache

Definition

Linux page cache is the kernel's in-memory cache of file-system pages; buffer cache is its sibling for block-device I/O (often merged into page cache on modern kernels). Together they consume otherwise-free memory to accelerate subsequent reads and writes — and Linux aggressively uses all available memory for this, reclaiming it transparently when applications demand it.

The free -m confusion

free -m shows something like:

             total       used       free     shared    buffers     cached
Mem:        245998      24545     221453         83         59        541
-/+ buffers/cache:      23944     222053
Swap:            0          0          0

The top row's used column counts page-cache-consumed memory as "used," which makes the system look low on memory even when most of that memory is reclaimable at any time. The -/+ buffers/cache row subtracts the buffer + page cache from used, giving the accounting that actually predicts whether allocations will succeed.

Netflix's framing:

The "-/+ buffers/cache" provides less confusing values for used and free memory. Linux uses free memory for the caches, but can reclaim it quickly if applications need it. So in a way the cached memory should be included in the free memory column, which this line does.

See also linuxatemyram.com — a whole website dedicated to this confusion.

When low page cache is a problem

Near-zero buffers or cached is a signal to check with iostat:

  • Without cached pages, every application read hits the disk.
  • Without buffer cache, every block I/O roundtrip hits media.
  • Expect rising disk I/O (r/s, rkB/s), rising %util, rising await, and probably elevated %iowait.

If the host intentionally runs memory-hungry applications (JVM heaps, in-memory databases, large mmap'd files) the page cache will naturally be small; check whether the host is actually swapping (si / so > 0 in vmstat) — that's the real memory-pressure signal.

ZFS-on-Linux complicates free -m

Netflix's note:

It can be additionally confusing if ZFS on Linux is used, as we do for some services, as ZFS has its own file system cache that isn't reflected properly by the free -m columns. It can appear that the system is low on free memory, when that memory is in fact available for use from the ZFS cache as needed.

ZFS maintains its own ARC (Adaptive Replacement Cache) outside the Linux page cache. free -m reports the ARC as "used" without a separate breakdown; you have to read /proc/spl/kstat/zfs/arcstats or use arc_summary to see actual reclaimable capacity. The principle is the same — the memory is available — but standard Linux tooling undercounts it.

Reclaim mechanics

When applications malloc / mmap demand pages, the kernel's page-frame-reclaim code (kswapd, direct reclaim) frees clean cached pages first (zero-cost — no write-back needed) and only resorts to writing back dirty pages or evicting anonymous memory to swap when clean cache is exhausted. This makes page-cache claim essentially free from the application's perspective — until swap pressure begins.

Seen in

  • sources/2025-07-29-netflix-linux-performance-analysis-in-60-secondsfree -m is command #7. The checklist focuses interpretation on the -/+ buffers/cache row plus the ZFS caveat. Explicit rule: "we just want to check that these aren't near-zero in size, which can lead to higher disk I/O."
  • sources/2025-07-08-planetscale-caching — Ben Dicken canonicalises the Linux page cache as the lower tier of Postgres's double-buffered cache stack: "Postgres relies heavily on the operating system's filesystem page cache, which caches disk pages at the kernel level. This creates a double-buffering system where data can exist in both Postgres's shared_buffers and the OS page cache." The canonical 25%-of-RAM rule for shared_buffers leaves the remainder of physical memory for the OS page cache to operate on. See concepts/postgres-shared-buffers-double-buffering. This is the explicit Postgres-dependency view of the page cache, complementary to the 2025-07-29 observability-tool view.
  • concepts/io-wait — low page cache → higher disk I/O → elevated %iowait.
  • concepts/use-method — the memory dimension of USE: page cache utilisation, saturation (swap), errors (OOM kills).
  • systems/iostat — the follow-up tool when cache looks low.
Last updated · 319 distilled / 1,201 read