Debian Codegraph @

testsuite/systemtap.examples/lwtools/bitesize-nd.stp

raw
1 #!/usr/bin/stap
2 /*
3 * bitesize-nd.stp Measure storage (bio) I/O size distribution.
4 * For Linux, uses SystemTap (non-debuginfo).
5 *
6 * USAGE: ./bitesize-nd.stp
7 *
8 * This script uses the kernel tracepoint block_rq_insert. The output includes
9 * the name of the process or thread that was on-CPU when the I/O request was
10 * inserted on the issue queue.
11 *
12 * From systemtap-lwtools: https://github.com/brendangregg/systemtap-lwtools
13 *
14 * See the corresponding man page (in systemtap-lwtools) for more info.
15 *
16 * Copyright (C) 2015 Brendan Gregg.
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * 01-Feb-2015 Brendan Gregg Created this.
29 */
30
31 global sz;
32
33 probe begin
34 {
35 printf("Tracing block I/O... Hit Ctrl-C to end.\n");
36 }
37
38 probe kernel.trace("block_rq_insert") {
39 /*
40 * You aren't supposed to access __data_len directly as it is internal,
41 * but I don't see another way...
42 */
43 sz[execname()] <<< $rq->__data_len;
44 }
45
46 probe end
47 {
48 printf("\nI/O size (bytes):\n\n");
49 foreach (name in sz+) {
50 printf("process name: %s\n", name);
51 print(@hist_log(sz[name]));
52 }
53 delete sz;
54 }