D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
usr
/
sbin
/
Filename :
biolatency-kp.bt
back
Copy
#!/usr/bin/env bpftrace // biolatency.bt Block I/O latency as a histogram. // For Linux, uses bpftrace, eBPF. // // This version of the tool uses kprobes to attach to kernel events. // Note that these do not exist or are inlined on newer kernels // (since kernel version 6.4) and therefore this version will not work. // On newer kernels, use biolatency.bt. // // Example of usage: // // # ./biolatency-kp.bt // Attaching 3 probes... // Tracing block device I/O... Hit Ctrl-C to end. // ^C // // @usecs: // [256, 512) 2 | | // [512, 1K) 10 |@ | // [1K, 2K) 426 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| // [2K, 4K) 230 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | // [4K, 8K) 9 |@ | // [8K, 16K) 128 |@@@@@@@@@@@@@@@ | // [16K, 32K) 68 |@@@@@@@@ | // [32K, 64K) 0 | | // [64K, 128K) 0 | | // [128K, 256K) 10 |@ | // // While tracing, this shows that 426 block I/O had a latency of between 1K and 2K // usecs (1024 and 2048 microseconds), which is between 1 and 2 milliseconds. // There are also two modes visible, one between 1 and 2 milliseconds, and another // between 8 and 16 milliseconds: this sounds like cache hits and cache misses. // There were also 10 I/O with latency 128 to 256 ms: outliers. Other tools and // instrumentation, like biosnoop.bt, can shed more light on those outliers. // // This is a bpftrace version of the bcc tool of the same name. // The bcc version provides options to customize the output. // // "biolatency.bt" is an updated version of "biolatency-kp.bt" and does basically // the same thing utilizing the tracepoints instead of kprobes. // // Copyright 2018 Netflix, Inc. // // 13-Sep-2018 Brendan Gregg Created this. config = { missing_probes = ignore; } BEGIN { printf("Tracing block device I/O... Hit Ctrl-C to end.\n"); // If kprobes does not exist, accessing @start in END will result in an error. @start[0] = (uint64)0; } kprobe:blk_account_io_start, kprobe:__blk_account_io_start { @start[arg0] = nsecs; } kprobe:blk_account_io_done, kprobe:__blk_account_io_done /@start[arg0]/ { @usecs = hist((nsecs - @start[arg0]) / 1000); delete(@start, arg0); } END { clear(@start); }