readahead(8)

✨ readahead(8) β€” System Manager's Manual ✨

Okay bestie, let's talk about readahead(8) πŸ’…πŸŽ€ This is the manual page for the readahead tool, and it's giving "show me the cache receipts" energy πŸ§ΎπŸ’–


🌸 NAME 🌸

readahead β€” Show performance of read-ahead cache ✨

πŸ¦‹ SYNOPSIS πŸ¦‹

readahead [-d DURATION]

πŸ’œ DESCRIPTION πŸ’œ

So this tool shows you how well read-ahead caching is doing on your system under a given load πŸ“Š It's the go-to when something about caching feels sus πŸ•΅οΈβ€β™€οΈ It counts how many pages are sitting in the cache unused, and it also prints a histogram of how long they've been hanging out there ⏳

Lowkey the way it works is it traces the __do_page_cache_readahead() kernel function to track entry and exit in the readahead mechanism in the kernel πŸ” Then it uses the __page_cache_alloc() and mark_page_accessed() functions to figure out the age of each page in the cache, and to see how many are left unaccessed 🫢

Since this uses BPF, only the root user can use this tool πŸ”₯ No cap, so don't even try it as a regular user πŸ’€

πŸ™ˆ NOTE ON KPROBES USAGE πŸ™ˆ

Okay, real talk: this tool uses Kprobes, so it depends on how your Linux kernel was compiled πŸ› οΈ These functions might be inlined, which means they won't be available for Kprobes 😭 To check, look at the vmlinux source and binary and confirm whether inlining is happening πŸ”Ž You can also check /proc/kallsyms on the host and verify that the target functions are present there before using this 🧚

πŸŽ€ REQUIREMENTS πŸŽ€

CONFIG_BPF, bcc πŸ’–

✨ OPTIONS ✨

  • -h β€” Prints the usage message 🌈
  • -d DURATION β€” Traces the read-ahead caching system for DURATION seconds ⏱️

πŸ“ EXAMPLES πŸ“

Trace for 30 seconds and show a histogram of page age (ms) in the read-ahead cache, along with the unused page count πŸ“ˆ

# readahead -d 30

🌈 OVERHEAD 🌈

⚠️ Bestie, watch out! The kernel functions this program instruments could be high-frequency depending on the application's profile (for example, sequential IO) 😱 Please measure and monitor the overhead before leaving this turned on in production environments πŸ™

πŸ“š SOURCE πŸ“š

This originated as a bpftrace tool from the book "BPF Performance Tools", published by Addison Wesley (2019) πŸ“–

http://www.brendangregg.com/bpf-performance-tools-book.html

See the book for more documentation on this tool πŸ€“

This version is in the BCC repository:

https://github.com/iovisor/bcc

Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool πŸ’…

🐧 OS 🐧

Linux 🐧

πŸ§ͺ STABILITY πŸ§ͺ

Unstable - in development 🚧

πŸ‘©β€πŸ’» AUTHOR πŸ‘©β€πŸ’»

Suchakra Sharma 🫢

πŸ‘‘ SEE ALSO πŸ‘‘

readahead(2), madvise(2) πŸ’«


Periodt, that's the whole tea β˜•πŸ’– Source is the bcc/iovisor project, version and date are USER COMMANDS 2020-08-20 πŸŽ€ Stay iconic and keep those caches clean, bestie πŸ¦‹βœ¨