forked from bpftrace/bpftrace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
biosnoop.bt
executable file
·43 lines (38 loc) · 888 Bytes
/
biosnoop.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bpftrace
/*
* biosnoop.bt Block I/O tracing tool, showing per I/O latency.
* For Linux, uses bpftrace, eBPF.
*
* TODO: switch to block tracepoints. Add device, offset, and size columns.
*
* This is a bpftrace version of the bcc tool of the same name.
*
* 15-Nov-2017 Brendan Gregg Created this.
*/
BEGIN
{
printf("%-12s %-16s %-6s %7s\n", "TIME(ms)", "COMM", "PID", "LAT(ms)");
}
kprobe:blk_account_io_start
{
@start[arg0] = nsecs;
@iopid[arg0] = pid;
@iocomm[arg0] = comm;
}
kprobe:blk_account_io_done
/@start[arg0] != 0 && @iopid[arg0] != 0 && @iocomm[arg0] != ""/
{
$now = nsecs;
printf("%-12u %-16s %-6d %7d\n",
elapsed / 1000000, @iocomm[arg0], @iopid[arg0],
($now - @start[arg0]) / 1000000);
delete(@start[arg0]);
delete(@iopid[arg0]);
delete(@iocomm[arg0]);
}
END
{
clear(@start);
clear(@iopid);
clear(@iocomm);
}