D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
sbin
/
Filename :
xfsdist.bt
back
Copy
#!/usr/bin/env bpftrace // xfsdist Summarize XFS operation latency. // For Linux, uses bpftrace and eBPF. // // This traces four common file system calls: read, write, open, and fsync. // It can be customized to trace more if desired. // // Example of usage: // // # xfsdist.bt // Attaching 9 probes... // Tracing XFS operation latency... Hit Ctrl-C to end. // ^C // // @us[xfs_file_write_iter]: // [8, 16) 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@ | // [16, 32) 2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| // // @us[xfs_file_read_iter]: // [1] 724 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| // [2, 4) 137 |@@@@@@@@@ | // [4, 8) 143 |@@@@@@@@@@ | // [8, 16) 37 |@@ | // [16, 32) 11 | | // [32, 64) 22 |@ | // [64, 128) 7 | | // [128, 256) 0 | | // [256, 512) 485 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | // [512, 1K) 149 |@@@@@@@@@@ | // [1K, 2K) 98 |@@@@@@@ | // [2K, 4K) 85 |@@@@@@ | // [4K, 8K) 27 |@ | // [8K, 16K) 29 |@@ | // [16K, 32K) 25 |@ | // [32K, 64K) 1 | | // [64K, 128K) 0 | | // [128K, 256K) 6 | | // // @us[xfs_file_open]: // [1] 1819 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| // [2, 4) 272 |@@@@@@@ | // [4, 8) 0 | | // [8, 16) 9 | | // [16, 32) 7 | | // // This output shows a bi-modal distribution for read latency, with a faster // mode of 724 reads that took between 0 and 1 microseconds, and a slower // mode of over 485 reads that took between 256 and 512 microseconds. It's // likely that the faster mode was a hit from the in-memory file system cache, // and the slower mode is a read from a storage device (disk). // // This "latency" is measured from when the operation was issued from the VFS // interface to the file system, to when it completed. This spans everything: // block device I/O (disk I/O), file system CPU cycles, file system locks, run // queue latency, etc. This is a better measure of the latency suffered by // applications reading from the file system than measuring this down at the // block device interface. // // Note that this only traces the common file system operations previously // listed: other file system operations (eg, inode operations including // getattr()) are not traced. // // This is a bpftrace version of the bcc tool of the same name. // The bcc version provides command line options to customize the output. // // Copyright 2018 Netflix, Inc. // // 08-Sep-2018 Brendan Gregg Created this. config = { missing_probes = ignore; } BEGIN { printf("Tracing XFS operation latency... Hit Ctrl-C to end.\n"); } kprobe:xfs_file_read_iter, kprobe:xfs_file_write_iter, kprobe:xfs_file_open, kprobe:xfs_file_fsync { @start[tid] = nsecs; @name[tid] = func; } kretprobe:xfs_file_read_iter, kretprobe:xfs_file_write_iter, kretprobe:xfs_file_open, kretprobe:xfs_file_fsync /@start[tid]/ { @us[@name[tid]] = hist((nsecs - @start[tid]) / 1000); delete(@start, tid); delete(@name, tid); } END { clear(@start); clear(@name); }