writeback.bt(8)

πŸ“¦ version 0.17.0, in debian bookworm

πŸ’– writeback.bt πŸ’–

okay bestie, so this is writeback.bt from section 8 of the System Manager's Manual, and it's literally one of the most useful little gremlins in the bpftrace toolkit. no cap.


✨ NAME ✨

writeback.bt β€” trace file system writeback events with details. uses bpftrace/eBPF. πŸ¦‹


🌸 SYNOPSIS 🌸

writeback.bt

that's it. no flags, no args, just vibes and root privileges. πŸ’…


πŸ’œ DESCRIPTION πŸ’œ

so what this does is it traces when your file system's dirtied pages get flushed to disk by kernel writeback, and then it prints out all the deets β€” like when the event happened, and how long the event took. super main character behavior tbh.

why do you care? because it's great for correlating those times with other performance problems. if there's a match? that's your clue that the problem might be caused by writeback. πŸ•΅οΈβ€β™€οΈ

and here's the tea: how quickly the kernel does writeback is tunable. check the kernel docs, like, for example vm.dirty_writeback_centisecs.

it's doing all this using two tracepoints:

  • tracepoint:writeback:writeback_start
  • tracepoint:writeback:writeback_written
⚠️ okay important: since this uses BPF, only the root user can use this tool. no root, no writeback tea. periodt.

πŸŽ€ REQUIREMENTS πŸŽ€

  • CONFIG_BPF
  • bpftrace

both. you need both. it's giving "dynamic duo". πŸ‘‘


⭐ EXAMPLES ⭐

trace all writeback events with timestamps and latency details:

# writeback.bt

yes queen, that's the whole example. she's simple, she's effective. 🌈


πŸ”₯ FIELDS πŸ”₯

here's what each column is serving, bestie:

  • TIME β€” the time that the writeback event completed, in %H:%M:%S format.
  • DEVICE β€” device name in major:minor number format.
  • PAGES β€” pages written during writeback.
  • REASON β€” reason for the writeback event. this may be "background", "vmscan", "sync", "periodic", etc.
  • ms β€” duration of the writeback event in milliseconds.

πŸ¦‹ OVERHEAD πŸ¦‹

since writeback events are expected to be infrequent β€” like, less than <10/sec β€” the overhead of this tool is expected to be negligible, near 0%. so you can lowkey just leave it running. obsessed. ✨


πŸ’– SOURCE πŸ’–

this is from bpftrace.

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 the director's cut. 🎬


🌸 OS 🌸

Linux


πŸ’… STABILITY πŸ’…

Unstable β€” in development.

(so like, she's growing. be nice to her. πŸ™ˆ)


πŸ‘‘ AUTHOR πŸ‘‘

Brendan Gregg


🫢 SEE ALSO 🫢


and that's the whole page, bestie!! this was writeback.bt(8) from the USER COMMANDS section, dated 2018-09-14. go forth and trace those writebacks, you absolute icon. πŸ’œβœ¨πŸŽ€

πŸ“¦ where this page comes from