swapin(8)

πŸ“¦ version 0.36.1, in alpine 3.24, nixpkgs unstable, opensuse-leap 16.0

🫧 NAME 🫧

okay so the manual name is swapin, and it's a BCC/eBPF tool that counts swapins by process ✨ swapin is the whole vibe.

Quick heads up, this page lives in the System Manager's Manual section 8 (swapin(8)) πŸ’…

✨ SYNOPSIS ✨

swapin
  • -h, --help β€” show the help message and bounce πŸ™ˆ
  • -T, --notime β€” skip the timestamp column (HH:MM:SS) πŸ•’

πŸ’– DESCRIPTION πŸ’–

okay so bestie, this tool counts swapins by process, so you can see exactly which process is getting hit by swapping (if you've got swap devices in use) πŸ₯Ί this can explain a seriously big chunk of app latency, especially if something started swapping because the system is under memory pressure. main character energy for debugging πŸ’€

how it works: it traces the swap_readpage() kernel function using dynamic instrumentation πŸ¦‹

⚠️ hot take, but this tool might need maintenance to keep working if that function changes in later kernels. so don't be shocked if it breaks someday 😭

and since it uses BPF, only the root user can run it. sorry not sorry πŸ”

πŸŽ€ REQUIREMENTS πŸŽ€

you'll need CONFIG_BPF and BCC ✨

🌸 EXAMPLES 🌸

Count swapins by process, with per-second summaries:

# swapin

🧚 FIELDS 🧚

  • 1st β€” the process name 🏷️
  • 2nd β€” the process ID πŸ”’
  • 3rd β€” the count of swapins during that interval πŸ“ˆ

πŸ”₯ OVERHEAD πŸ”₯

the rate of swapins should be low (it's bounded by swap device IOPS), so the overhead of this tool is expected to be negligible. basically zero drama πŸ’…

πŸ“ SOURCE πŸ“

okay this one's a good story πŸ₯Ή it 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

go read the book for more docs on this tool, it's iconic πŸ“š

the version you're looking at is in the BCC repository:

https://github.com/iovisor/bcc

also, peek in the bcc distribution for a companion _examples.txt file. it has example usage, output, and commentary for this tool, so iykyk 🫢

🌈 OS 🌈

Linux only 🐧

🫠 STABILITY 🫠

Unstable - in development. so it's still cooking 🍳

πŸ‘‘ AUTHOR πŸ‘‘

Brendan Gregg is the queen behind this one πŸ‘Έ

πŸ¦‹ SEE ALSO πŸ¦‹

swapon(8) πŸ’œ


and that's a wrap, bestie πŸŽ€ this was the USER COMMANDS manual page, last updated 2019-07-05, for swapin(8) πŸ’–βœ¨