File: bitesize-nd.stp

package info (click to toggle)
systemtap 5.1-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 47,964 kB
  • sloc: cpp: 80,838; ansic: 54,757; xml: 49,725; exp: 43,665; sh: 11,527; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (54 lines) | stat: -rwxr-xr-x 1,543 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/stap
/*
 * bitesize-nd.stp	Measure storage (bio) I/O size distribution.
 *			For Linux, uses SystemTap (non-debuginfo).
 *
 * USAGE: ./bitesize-nd.stp
 *
 * This script uses the kernel tracepoint block_rq_insert. The output includes
 * the name of the process or thread that was on-CPU when the I/O request was
 * inserted on the issue queue.
 *
 * From systemtap-lwtools: https://github.com/brendangregg/systemtap-lwtools
 *
 * See the corresponding man page (in systemtap-lwtools) for more info.
 *
 * Copyright (C) 2015 Brendan Gregg.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * 01-Feb-2015	Brendan Gregg	Created this.
 */

global sz;

probe begin
{
	printf("Tracing block I/O... Hit Ctrl-C to end.\n");
}

probe kernel.trace("block_rq_insert") {
	/*
	 * You aren't supposed to access __data_len directly as it is internal,
	 * but I don't see another way...
	 */
	sz[execname()] <<< $rq->__data_len;
}

probe end
{
	printf("\nI/O size (bytes):\n\n");
	foreach (name in sz+) {
		printf("process name: %s\n", name);
		print(@hist_log(sz[name]));
	} 
	delete sz;
}