forked from bpftrace/bpftrace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbiosnoop.bt
executable file
·45 lines (39 loc) · 983 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
44
45
#!/usr/bin/env bpftrace
/*
* biosnoop.bt Block I/O tracing tool, showing per I/O latency.
* For Linux, uses bpftrace, eBPF.
*
* TODO: Add offset and size columns.
*
* This is a bpftrace version of the bcc tool of the same name.
*/
BEGIN
{
printf("%-12s %-14s %-16s %-6s %7s\n",
"TIME(ms)", "DISK ID", "COMM", "PID", "LAT(ms)");
printf(" MAJOR MINOR\n")
}
tracepoint:block:block_io_start
{
$key = (args.dev, args.sector);
@start[$key] = nsecs;
@iopid[$key] = pid;
}
tracepoint:block:block_io_done
/@start[args.dev, args.sector] != 0 && @iopid[args.dev, args.sector] != 0 && args.comm != ""/
{
$key = (args.dev, args.sector);
$now = nsecs;
$major = args.dev >> 20;
$minor = args.dev & ((1 << 20) - 1);
printf("%-12u %-5d %-8d %-16s %-6d %7d\n",
elapsed / 1e6, $major, $minor, args.comm, @iopid[$key],
($now - @start[$key]) / 1e6);
delete(@start, $key);
delete(@iopid, $key);
}
END
{
clear(@start);
clear(@iopid);
}