Linux 6.5 Brings New "cachestat" Syscall For Querying Page Cache Stats Of A File

Written by Michael Larabel in Linux Kernel on 7 July 2023 at 01:00 PM EDT. 1 Comment
A new system call found in Linux 6.5 is "cachestat" that allows user-space to query page cache statistics for a file in order to make more informed decisions.

There already is the "mincore" system call for determining whether pages are resident in memory while cachestat is allowing for querying of more page cache statistics and aims to provide greater scalability. The cachestat system call will report the number of cached pages / dirty pages / pages marked for writeback / evicted pages / recently evicted pages. The cachestat system call patches have gone through many revisions while finally were picked up last week for the Linux 6.5 kernel.

cachestat man page

A number of possible user-space use-cases were previously outlined in the former patch series on the kernel mailing list:
* Allowing database to decide whether to perform an index scan or direct table queries based on the in-memory cache state of the index.

* Visibility into the writeback algorithm, for performance issues diagnostic.

* Workload-aware writeback pacing: estimating IO fulfilled by page cache (and IO to be done) within a range of a file, allowing for more frequent syncing when and where there is IO capacity, and batching when there is not.

* Computing memory usage of large files/directory trees, analogous to the du tool for disk usage.

The cachestat system call was merged as part of the MM updates for Linux 6.5.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via

Popular News This Week