File: Useful_Scripts-threadtimes.xml

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; 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 (93 lines) | stat: -rw-r--r-- 2,999 bytes parent folder | download | duplicates (9)
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
<?xml version='1.0'?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
]>


	<section id="threadtimessect">
		<title>Determining Time Spent in Kernel and User Space</title>
<indexterm>
<primary>script examples</primary>
<secondary>determining time spent in kernel and user space</secondary>
</indexterm>

<indexterm>
<primary>examples of SystemTap scripts</primary>
<secondary>determining time spent in kernel and user space</secondary>
</indexterm>

<indexterm>
<primary>determining time spent in kernel and user space</primary>
<secondary>examples of SystemTap scripts</secondary>
</indexterm>
<indexterm>
	<primary>time spent in kernel/user space, determining</primary>
	<secondary>examples of SystemTap scripts</secondary>
</indexterm>
<indexterm>
	<primary>kernel and user space, determining time spent in</primary>
	<secondary>examples of SystemTap scripts</secondary>
</indexterm>
<indexterm>
	<primary>user and kernel space, determining time spent in</primary>
	<secondary>examples of SystemTap scripts</secondary>
</indexterm>

<remark>
	http://sourceware.org/systemtap/examples/profiling/thread-times.stp
</remark>


<para>This section illustrates how to determine the amount of time any given thread is spending in either kernel or user-space.</para>

<formalpara id="threadtimes">
		<title>thread-times.stp</title>
<para>
<programlisting><xi:include parse="text" href="../testsuite/systemtap.examples/profiling/thread-times.stp" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
</para>
</formalpara>
<indexterm>
	<primary>script examples</primary>
	<secondary>CPU ticks</secondary>
</indexterm>

<indexterm>
	<primary>examples of SystemTap scripts</primary>
	<secondary>CPU ticks</secondary>
</indexterm>

<indexterm>
	<primary>CPU ticks</primary>
	<secondary>examples of SystemTap scripts</secondary>
</indexterm>

<para><xref linkend="threadtimes"/> lists the top 20 processes currently taking up CPU time within a 5-second sample, along with the total number of CPU ticks made during the sample. The output of this script also notes the percentage of CPU time each process used, as well as whether that time was spent in kernel space or user space. </para>

<para><xref linkend="threadtimesoutput"/> contains a 5-second sample of the output for <xref linkend="threadtimes"/>:</para>

<example id="threadtimesoutput">
	<title><xref linkend="threadtimes"/> Sample Output</title>
<screen>  tid   %user %kernel (of 20002 ticks)
    0   0.00%  87.88%
32169   5.24%   0.03%
 9815   3.33%   0.36%
 9859   0.95%   0.00%
 3611   0.56%   0.12%
 9861   0.62%   0.01%
11106   0.37%   0.02%
32167   0.08%   0.08%
 3897   0.01%   0.08%
 3800   0.03%   0.00%
 2886   0.02%   0.00%
 3243   0.00%   0.01%
 3862   0.01%   0.00%
 3782   0.00%   0.00%
21767   0.00%   0.00%
 2522   0.00%   0.00%
 3883   0.00%   0.00%
 3775   0.00%   0.00%
 3943   0.00%   0.00%
 3873   0.00%   0.00%</screen>
</example>

	</section>