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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
// memory/vm related tapset
// Copyright (C) 2005, 2006 IBM Corp.
// Copyright (C) 2006 Intel Corporation.
//
// This file is part of systemtap, and is free software. You can
// redistribute it and/or modify it under the terms of the GNU General
// Public License (GPL); either version 2, or (at your option) any
// later version.
///<chapter id="memory_stp">
/// <title>Memory Tapset</title>
/// <para>
/// This family of probe points is used to probe page fault events.
/// It contains the following probe points:
/// </para>
///<formalpara id="vm.pagefault">
/// <title>vm.pagefault</title>
/// <indexterm><primary>vm.pagefault</primary></indexterm>
/// <para>
/// Records that a page fault occurred.
/// The context is the process which triggered the fault.</para>
///</formalpara>
///<para>
/// <variablelist><title>Arguments:</title>
/// <varlistentry><term>address</term>
/// <listitem><para>
/// The address of the faulting memory access.
/// </para></listitem>
/// </varlistentry>
/// <varlistentry><term>write_access</term>
/// <listitem><para>
/// Indicates whether this was a write.
/// </para></listitem>
/// </varlistentry>
/// </variablelist>
///</para>
probe vm.pagefault = kernel.function("__handle_mm_fault@mm/memory.c") ?,
kernel.function("handle_mm_fault@mm/memory.c") ?
{
write_access = $write_access
address = $address
}
///<formalpara id="vm.pagefault.return">
/// <title>vm.pagefault.return</title>
/// <indexterm><primary>vm.pagefault.return</primary></indexterm>
/// <para>
/// Records type of fault that occurred.
/// The context is the process which triggered the fault.
/// </para>
///</formalpara>
///<para>
/// <variablelist><title>Arguments:</title>
/// <varlistentry><term>fault_type</term>
/// <listitem><para>The possible values of fault_type are:
/// <table frame='all'><title>Fault values</title>
/// <tgroup cols='3' align='left' colsep='1' rowsep='1'>
/// <colspec colname='Define'/>
/// <colspec colname='Value'/>
/// <colspec colname='Reason'/>
/// <thead>
/// <row><entry>Define</entry><entry>Value</entry><entry>Reason</entry></row>
/// </thead>
/// <tbody>
/// <row>
/// <entry>VM_FAULT_OOM</entry>
/// <entry>0</entry>
/// <entry>out of memory</entry>
/// </row>
/// <row>
/// <entry>VM_FAULT_SIGBUS</entry>
/// <entry>1</entry>
/// <entry>if not oom, minor, or major fault, this val</entry>
/// </row>
/// <row>
/// <entry>VM_FAULT_MINOR</entry>
/// <entry>2</entry>
/// <entry>no blocking operation to handle fault</entry>
/// </row>
/// <row>
/// <entry>VM_FAULT_MAJOR</entry>
/// <entry>3</entry>
/// <entry>required blocking operation to handle fault</entry>
/// </row>
/// </tbody>
/// </tgroup>
/// </table>
/// </para></listitem>
/// </varlistentry>
/// </variablelist>
///</para>
probe vm.pagefault.return = kernel.function("__handle_mm_fault@mm/memory.c").return ?,
kernel.function("handle_mm_fault@mm/memory.c").return ?
{
fault_type = $return
}
/* Return which node the given address belongs to in a NUMA system */
function addr_to_node:long(addr:long) %{ /* pure */
int nid;
int pfn = __pa(THIS->addr) >> PAGE_SHIFT;
for_each_online_node(nid)
if ( NODE_DATA(nid)->node_start_pfn <= pfn &&
pfn < (NODE_DATA(nid)->node_start_pfn +
NODE_DATA(nid)->node_spanned_pages) )
{
THIS->__retvalue = nid;
break;
}
%}
/* Return whether a page to be copied is a zero page. */
function _IS_ZERO_PAGE:long(from:long, vaddr:long) %{ /* pure */
THIS->__retvalue = (THIS->from == (long) ZERO_PAGE(THIS->vaddr));
%}
///<formalpara id="vm.write_shared">
/// <title>vm.write_shared</title>
/// <indexterm><primary>vm.write_shared</primary></indexterm>
/// <para>
/// Fires when a process attempts to write to a shared page.
/// If a copy is necessary, this will be followed by a
/// <xref linkend="vm.write_shared_copy"/>.
/// The context is the process attempting the write.
/// </para>
///</formalpara>
///<para>
/// <variablelist><title>Arguments:</title>
/// <varlistentry><term>address</term>
/// <listitem><para>The address of the shared write.</para></listitem>
/// </varlistentry>
/// </variablelist>
///</para>
probe vm.write_shared = kernel.function("do_wp_page") {
address = $address
}
///<formalpara id="vm.write_shared_copy">
/// <title>vm.write_shared_copy</title>
/// <indexterm><primary>vm.write_shared_copy</primary></indexterm>
/// <para>
/// Fires when a write to a shared page requires a page copy.
/// This is always preceded by a <xref linkend="vm.write_shared"/>.
/// The context is the process attempting the write.
///</para>
///</formalpara>
///<para>
/// <variablelist><title>Arguments:</title>
/// <varlistentry><term>address</term>
/// <listitem><para>
/// The address of the shared write.
/// </para></listitem>
/// </varlistentry>
/// <varlistentry><term>zero</term>
/// <listitem><para>
/// Boolean indicating whether it is a zero page
/// (can do a clear instead of a copy).
/// </para></listitem>
/// </varlistentry>
/// </variablelist>
///</para>
/* probe vm.write_shared_copy
*
* Fires when a write to a shared page requires a page copy. This is
* always preceded by a vm.shared_write.
*
* Context:
* The process attempting the write.
*
* Arguments:
* address - the address of the shared write.
* zero - boolean indicating whether it is a zero page
* (can do a clear instead of a copy).
*/
probe vm.write_shared_copy = kernel.function("copy_cow_page")? {
address = $address
zero = _IS_ZERO_PAGE($from, address);
}
///<formalpara id="vm.mmap">
/// <title>vm.mmap</title>
/// <indexterm><primary>vm.mmap</primary></indexterm>
/// <para>
/// Fires when an mmap is requested.
/// The context is the process calling mmap.
/// </para>
///</formalpara>
///<para>
/// <variablelist><title>Arguments:</title>
/// <varlistentry><term>address</term>
/// <listitem><para>The requested address.</para></listitem>
/// </varlistentry>
/// <varlistentry><term>length</term>
/// <listitem><para>The length of the memory segment.</para></listitem>
/// </varlistentry>
/// </variablelist>
///</para>
/* probe vm.mmap
*
* Fires when an mmap is requested.
*
* Context:
* The process calling mmap.
*
* Arguments:
* address - the requested address
* length - the length of the memory segment
*/
probe vm.mmap = kernel.function("do_mmap"), kernel.function("do_mmap2")? {
address = $addr
length = $len
}
///<formalpara id="vm.munmap">
/// <title>vm.munmap</title>
/// <indexterm><primary>vm.munmap</primary></indexterm>
/// <para>Fires when an munmap is requested.</para>
///</formalpara>
///<para>
/// <variablelist><title>Arguments:</title>
/// <varlistentry><term>address</term>
/// <listitem><para>The requested address.</para></listitem>
/// </varlistentry>
/// <varlistentry><term>length</term>
/// <listitem><para>The length of the memory segment.</para></listitem>
/// </varlistentry>
/// </variablelist>
///</para>
/* probe vm.munmap
*
* Fires when an munmap is requested.
*
* Context:
* The process calling munmap.
*
* Arguments:
* address - the requested address
* length - the length of the memory segment
*/
probe vm.munmap = kernel.function("do_munmap") {
address = $start
length = $len
}
///<formalpara id="vm.brk">
/// <title>vm.brk</title>
/// <indexterm><primary>vm.brk</primary></indexterm>
/// <para>Fires when a brk is requested (resizing a heap).</para>
///</formalpara>
///<para>
/// <variablelist><title>Arguments:</title>
/// <varlistentry><term>address</term>
/// <listitem><para>The requested address.</para></listitem>
/// </varlistentry>
/// <varlistentry><term>length</term>
/// <listitem><para>The length of the memory segment.</para></listitem>
/// </varlistentry>
/// </variablelist>
///</para>
/* probe vm.brk
*
* Fires when a brk is requested (resizing a heap).
*
* Context:
* The process calling brk.
*
* Arguments:
* address - the requested address
* length - the length of the memory segment
*/
probe vm.brk = kernel.function("do_brk") {
address = $addr
length = $len
}
///<formalpara id="vm.oom_kill">
/// <title>vm.oom_kill</title>
/// <indexterm><primary>vm.oom_kill</primary></indexterm>
/// <para>Fires when a thread is targetted by the OOM killer.</para>
///</formalpara>
///<para>
/// <variablelist><title>Arguments:</title>
/// <varlistentry><term>task</term>
/// <listitem><para>The task being killed.</para></listitem>
/// </varlistentry>
/// </variablelist>
///</para>
/* probe vm.oom_kill
*
* Fires when a thread is targetted by the OOM killer.
*
* Context:
* The process that tried to consume more memory, and thus
* triggered the OOM. (correct?)
*
* Arguments:
* task - the task being killed
*/
probe vm.oom_kill = kernel.function("__oom_kill_task") {
task = $p
}
///</chapter>
|