forked from bpftrace/bpftrace
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbiostacks.bt
More file actions
94 lines (90 loc) · 2.57 KB
/
Copy pathbiostacks.bt
File metadata and controls
94 lines (90 loc) · 2.57 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env bpftrace
// biostacks - Show disk I/O latency with initialization stacks.
//
// See BPF Performance Tools, Chapter 9, for an explanation of this tool.
//
// Example of usage:
//
// # ./biostacks.bt
// Attaching 5 probes...
// Tracing block I/O with init stacks. Hit Ctrl-C to end.
// ^C
//
// @usecs[
// blk_account_io_start+1
// blk_mq_make_request+1102
// generic_make_request+292
// submit_bio+115
// _xfs_buf_ioapply+798
// xfs_buf_submit+101
// xlog_bdstrat+43
// xlog_sync+705
// xlog_state_release_iclog+108
// _xfs_log_force+542
// xfs_log_force+44
// xfsaild+428
// kthread+289
// ret_from_fork+53
// ]:
// [64K, 128K) 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
//
// [...]
//
// @usecs[
// blk_account_io_start+1
// blk_mq_make_request+707
// generic_make_request+292
// submit_bio+115
// xfs_add_to_ioend+455
// xfs_do_writepage+758
// write_cache_pages+524
// xfs_vm_writepages+190
// do_writepages+75
// __writeback_single_inode+69
// writeback_sb_inodes+481
// __writeback_inodes_wb+103
// wb_writeback+625
// wb_workfn+384
// process_one_work+478
// worker_thread+50
// kthread+289
// ret_from_fork+53
// ]:
// [8K, 16K) 560 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
// [16K, 32K) 218 |@@@@@@@@@@@@@@@@@@@@ |
// [32K, 64K) 26 |@@ |
// [64K, 128K) 2 | |
// [128K, 256K) 53 |@@@@ |
// [256K, 512K) 60 |@@@@@ |
//
// This output shows the most frequent stack was XFS writeback, with latencies
// between 8 and 512 microseconds. The other stack included here shows an XFS
// log sync.
//
// Copyright (c) 2019 Brendan Gregg.
// This was originally created for the BPF Performance Tools book
// published by Addison Wesley. ISBN-13: 9780136554820
// When copying or porting, include this comment.
BEGIN
{
printf("Tracing block I/O with init stacks. Hit Ctrl-C to end.\n");
}
tracepoint:block:block_io_start
{
$key = (args.dev,args.sector);
@reqstack[$key] = kstack;
@reqts[$key] = nsecs;
}
tracepoint:block:block_rq_issue
/@reqts[args.dev,args.sector]/
{
$key = (args.dev,args.sector);
@usecs[@reqstack[$key]] = hist(nsecs - @reqts[$key]);
delete(@reqstack, $key);
delete(@reqts, $key);
}
END
{
clear(@reqstack);
clear(@reqts);
}