iosnoop(8)
β¨ iosnoop(8) β¨
okay bestie, welcome to iosnoop from the System Manager's Manual section β it's a real one, and it's lowkey iconic. let's get into it π
πΈ NAME πΈ
iosnoop β trace block I/O events as they occur. Uses Linux ftrace.
π¦ SYNOPSIS π¦
iosnoop [-hQst] [-d device] [-i iotype] [-p pid] [-n name] [duration]
π DESCRIPTION π
iosnoop prints block device I/O events as they happen, and it comes with all the useful little details: PID, device, I/O type, block number, I/O size, and latency. it's giving full picture.
This traces disk I/O at the block device interface, using the block: tracepoints. so it can help you characterize the I/O that's being requested for your storage devices and how they're actually performing. and you can also study I/O completions event-by-event for debugging disk and controller I/O scheduling issues. obsessed.
NOTE: using a duration buffers I/O, which reduces overheads, but it also introduces a limit to the number of I/O that will be captured. see the duration section in OPTIONS, bestie, don't skip it. π«Ά
Since this uses ftrace, only the root user can use this tool. root only, no exceptions, that's the vibe. π
π REQUIREMENTS π
FTRACE CONFIG, and the tracepoints block:block_rq_insert, block:block_rq_issue, and block:block_rq_complete β which you may already have enabled and available on recent Linux kernels. And awk. yes, awk. we love her. π
β¨ OPTIONS β¨
-ddevice β Only show I/O issued by this device. (eg,"202,1"). This matches theDEVcolumn in theiosnoopoutput, and is filtered in-kernel.-iiotype β Only show I/O issued that matches this I/O type. This matches theTYPEcolumn in theiosnoopoutput, and wildcards ("*") can be used at the beginning or end (only). Eg,"*R*"matches all reads. This is filtered in-kernel.-pPID β Only show I/O issued by this PID. This filters in-kernel. Note that I/O may be issued indirectly; for example, as the result of a memory allocation, causing dirty buffers (maybe from another PID) to be written to storage. π
With the -Q option, the identified PID is more accurate, however, LATms now includes queueing time (see the -Q option).
-nname β Only show I/O issued by processes with this name. Partial strings and regular expressions are allowed. This is a post-filter, so all I/O is traced and then filtered in user space. As with PID, this includes indirectly issued I/O, and-Qcan be used to improve accuracy (see the-Qoption).-hβ Print usage message. short, sweet, helpful. π-Qβ Use block I/O queue insertion as the start tracepoint (block:block_rq_insert), instead of block I/O issue (block:block_rq_issue). This makes the following changes:COMMandPIDare more likely to identify the origin process, as are-pPID and-nname;STARTsshows queue insert; andLATmsshows I/O time including time spent on the block I/O queue. she's thorough. π-sβ Include a column for the start time (issue time) of the I/O, in seconds. If the-Qoption is used, this is the time the I/O is inserted on the block I/O queue.-tβ Include a column for the completion time of the I/O, in seconds.- duration β Set the duration of tracing, in seconds. Trace output will be buffered and printed at the end. This also reduces overheads by buffering in-kernel, instead of printing events as they occur.
The ftrace buffer has a fixed size per-CPU (see /sys/kernel/debug/tracing/buffer_size_kb). If you think events are missing, try increasing that size (the bufsize_kb setting in iosnoop). With the default setting (4 Mbytes), I'd expect this to happen around 50k I/O. π
π EXAMPLES π
Default output, print I/O activity as it occurs:
# iosnoop
Buffer for 5 seconds (lower overhead) and write to a file:
# iosnoop 5 > outfile
Trace based on block I/O queue insertion, showing queueing time:
# iosnoop -Q
Trace reads only:
# iosnoop -i '*R*'
Trace I/O issued to device 202,1 only:
# iosnoop -d 202,1
Include I/O start and completion timestamps:
# iosnoop -ts
Include I/O queueing and completion timestamps:
# iosnop -Qts
Trace I/O issued when PID 181 was on-CPU only:
# iosnoop -p 181
Trace I/O queued when PID 181 was on-CPU (more accurate), and include queue time:
# iosnoop -Qp 181
π§ FIELDS π§
COMMβ Process name (command) for the PID that was on-CPU when the I/O was issued, or inserted if-Qis used. SeePID. This column is truncated to 12 characters.PIDβ Process ID which was on-CPU when the I/O was issued, or inserted if-Qis used. This will usually be the process directly requesting I/O, however, it may also include indirect I/O. For example, a memory allocation by this PID which causes dirty memory from another PID to be flushed to disk. sneaky.TYPEβ Type of I/O.R=read,W=write,M=metadata,S=sync,A=readahead,F=flush or FUA (force unit access),D=discard,E=secure,N=null (not RWFD).DEVβ Storage device ID.BLOCKβ Disk block for the operation (location, relative to this device).BYTESβ Size of the I/O, in bytes.LATmsβ Latency (time) for the I/O, in milliseconds.
π₯ OVERHEAD π₯
By default, iosnoop works without buffering, printing I/O events as they happen (uses trace_pipe), context switching and consuming CPU to do so. This has a limit of about 10,000 IOPS (depending on your platform), at which point iosnoop will be consuming 1 CPU. The duration mode uses buffering, and can handle much higher IOPS rates, however, the buffer has a limit of about 50,000 I/O, after which events will be dropped. You can tune this with bufsize_kb, which is per-CPU. Also note that the "-n" option is currently post-filtered, so all events are traced. π¬
The overhead may be acceptable in many situations. If it isn't, this tool can be reimplemented in C, or using a different tracer (eg, perf_events, SystemTap, ktap.) you do you, bestie.
π SOURCE π
This is from the perf-tools collection.
https://github.com/brendangregg/perf-tools
Also look under the examples directory for a text file containing example usage, output, and commentary for this tool. it's got lore. π
β OS β
Linux
π STABILITY π
Unstable - in development.
π AUTHOR π
Brendan Gregg
π SEE ALSO π
iolatency(8), iostat(1), lsblk(8)
and that's the whole thing, no cap β this page comes to you from USER COMMANDS, dated 2014-07-12, and it's literally called iosnoop(8). go trace something slay, but like, as root. π«Άβ¨
π¦ where this page comes from
- nixos 26.05: perf-tools-unstable 2017-12-19
- nixpkgs unstable: perf-tools-unstable 2017-12-19
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms