swapin.bt(8)
π« swapin.bt(8) β the count-swapins-by-process baddie π«
okay bestie, so this is a page from the System Manager's Manual and it's all about swapin.bt, a lil bpftrace/eBPF tool that counts swapins by process. she's lowkey niche but highkey useful. let's get into it π«Ά
β¨ NAME β¨
swapin.bt β count swapins by process. Uses bpftrace/eBPF.
πΈ SYNOPSIS πΈ
swapin
that's it. that's the whole vibe. no flags, no drama π
π¦ DESCRIPTION π¦
so what does she do? this tool counts swapins by process, which shows you which process is getting wrecked by swapping (if swap devices are even in use, that is). and ngl, that matters a lot, because if a process started swapping due to memory pressure on the system, that can explain a significant source of application latency. like, the "why is my app so slow" mystery? sometimes it's just this. π
the way it works is by tracing the swap_readpage() kernel function using dynamic instrumentation. real cute, real effective. but heads up: this tool may need maintenance to keep working if that function changes in later kernels. so if it breaks someday, that's why, no cap.
and since this uses BPF, only the root user can use this tool. root energy required, sorry bestie π
π REQUIREMENTS π
you're gonna need:
CONFIG_BPFbpftrace
that's the whole guest list.
β EXAMPLES β
count swapins by process, showing per-second summaries:
# swapin.bt
obsessed. periodt.
π FIELDS π
three columns, three lil pieces of info, let's go:
- 1st β the process name.
- 2nd β the process ID.
- 3rd β the count of swapins during that interval.
π₯ OVERHEAD π₯
good news: the rate of swapins should be low (it's bounded by swapin device IOPS), such that the overhead of this tool is expected to be negligible. so she's polite, she doesn't eat your CPU, she just vibes. β¨
π SOURCE π
this tool originated 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, iykyk π
this version lives in the bpftrace repository:
https://github.com/iovisor/bpftrace
also, look in the bpftrace distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. it's giving bonus content fr fr π
π§ OS π§
Linux
π STABILITY π
Unstable β in development. she's a work in progress, and honestly? same.
π AUTHOR π
Brendan Gregg
π SEE ALSO π
and that's the whole page, bestie!! this one was from the USER COMMANDS section, dated 2019-07-05, and it goes by swapin.bt(8). thanks for reading my little manpage TED talk, mwah πβ¨
π¦ where this page comes from
- debian bookworm: bpftrace 0.17.0-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms