]> git.ipfire.org Git - thirdparty/glibc.git/blame - manual/probes.texi
manual: Update struct sockaddr_in, struct sockaddr_sin6 description
[thirdparty/glibc.git] / manual / probes.texi
CommitLineData
3ea5be54 1@node Internal Probes
9d0a979e 2@c @node Internal Probes, Tunables, Threads, Top
3ea5be54
AO
3@c %MENU% Probes to monitor libc internal behavior
4@chapter Internal probes
5
6In order to aid in debugging and monitoring internal behavior,
7@theglibc{} exposes nearly-zero-overhead SystemTap probes marked with
8the @code{libc} provider.
9
10These probes are not part of the @glibcadj{} stable ABI, and they are
11subject to change or removal across releases. Our only promise with
12regard to them is that, if we find a need to remove or modify the
13arguments of a probe, the modified probe will have a different name, so
14that program monitors relying on the old probe will not get unexpected
15arguments.
16
17@menu
18* Memory Allocation Probes:: Probes in the memory allocation subsystem
10e1cf6b 19* Mathematical Function Probes:: Probes in mathematical functions
7b3436d4 20* Non-local Goto Probes:: Probes in setjmp and longjmp
3ea5be54
AO
21@end menu
22
23@node Memory Allocation Probes
24@section Memory Allocation Probes
25
26These probes are designed to signal relatively unusual situations within
4d84e6ad 27the virtual memory subsystem of @theglibc{}.
3ea5be54 28
322dea08
AO
29@deftp Probe memory_sbrk_more (void *@var{$arg1}, size_t @var{$arg2})
30This probe is triggered after the main arena is extended by calling
31@code{sbrk}. Argument @var{$arg1} is the additional size requested to
32@code{sbrk}, and @var{$arg2} is the pointer that marks the end of the
33@code{sbrk} area, returned in response to the request.
34@end deftp
35
36@deftp Probe memory_sbrk_less (void *@var{$arg1}, size_t @var{$arg2})
37This probe is triggered after the size of the main arena is decreased by
38calling @code{sbrk}. Argument @var{$arg1} is the size released by
39@code{sbrk} (the positive value, rather than the negative value passed
40to @code{sbrk}), and @var{$arg2} is the pointer that marks the end of
41the @code{sbrk} area, returned in response to the request.
42@end deftp
43
44@deftp Probe memory_heap_new (void *@var{$arg1}, size_t @var{$arg2})
45This probe is triggered after a new heap is @code{mmap}ed. Argument
46@var{$arg1} is a pointer to the base of the memory area, where the
47@code{heap_info} data structure is held, and @var{$arg2} is the size of
48the heap.
49@end deftp
50
51@deftp Probe memory_heap_free (void *@var{$arg1}, size_t @var{$arg2})
52This probe is triggered @emph{before} (unlike the other sbrk and heap
53probes) a heap is completely removed via @code{munmap}. Argument
54@var{$arg1} is a pointer to the heap, and @var{$arg2} is the size of the
55heap.
56@end deftp
57
58@deftp Probe memory_heap_more (void *@var{$arg1}, size_t @var{$arg2})
59This probe is triggered after a trailing portion of an @code{mmap}ed
60heap is extended. Argument @var{$arg1} is a pointer to the heap, and
61@var{$arg2} is the new size of the heap.
62@end deftp
63
64@deftp Probe memory_heap_less (void *@var{$arg1}, size_t @var{$arg2})
65This probe is triggered after a trailing portion of an @code{mmap}ed
66heap is released. Argument @var{$arg1} is a pointer to the heap, and
67@var{$arg2} is the new size of the heap.
68@end deftp
69
35fed6f1
AO
70@deftp Probe memory_malloc_retry (size_t @var{$arg1})
71@deftpx Probe memory_realloc_retry (size_t @var{$arg1}, void *@var{$arg2})
72@deftpx Probe memory_memalign_retry (size_t @var{$arg1}, size_t @var{$arg2})
35fed6f1
AO
73@deftpx Probe memory_calloc_retry (size_t @var{$arg1})
74These probes are triggered when the corresponding functions fail to
75obtain the requested amount of memory from the arena in use, before they
76call @code{arena_get_retry} to select an alternate arena in which to
77retry the allocation. Argument @var{$arg1} is the amount of memory
78requested by the user; in the @code{calloc} case, that is the total size
79computed from both function arguments. In the @code{realloc} case,
80@var{$arg2} is the pointer to the memory area being resized. In the
81@code{memalign} case, @var{$arg2} is the alignment to be used for the
82request, which may be stricter than the value passed to the
10ad46bc
OB
83@code{memalign} function. A @code{memalign} probe is also used by functions
84@code{posix_memalign, valloc} and @code{pvalloc}.
35fed6f1
AO
85
86Note that the argument order does @emph{not} match that of the
87corresponding two-argument functions, so that in all of these probes the
88user-requested allocation size is in @var{$arg1}.
89@end deftp
90
655673f3
AO
91@deftp Probe memory_arena_retry (size_t @var{$arg1}, void *@var{$arg2})
92This probe is triggered within @code{arena_get_retry} (the function
93called to select the alternate arena in which to retry an allocation
94that failed on the first attempt), before the selection of an alternate
95arena. This probe is redundant, but much easier to use when it's not
96important to determine which of the various memory allocation functions
97is failing to allocate on the first try. Argument @var{$arg1} is the
98same as in the function-specific probes, except for extra room for
99padding introduced by functions that have to ensure stricter alignment.
100Argument @var{$arg2} is the arena in which allocation failed.
101@end deftp
102
3ea5be54
AO
103@deftp Probe memory_arena_new (void *@var{$arg1}, size_t @var{$arg2})
104This probe is triggered when @code{malloc} allocates and initializes an
105additional arena (not the main arena), but before the arena is assigned
106to the running thread or inserted into the internal linked list of
107arenas. The arena's @code{malloc_state} internal data structure is
108located at @var{$arg1}, within a newly-allocated heap big enough to hold
109at least @var{$arg2} bytes.
110@end deftp
111
6999d38c
AO
112@deftp Probe memory_arena_reuse (void *@var{$arg1}, void *@var{$arg2})
113This probe is triggered when @code{malloc} has just selected an existing
114arena to reuse, and (temporarily) reserved it for exclusive use.
115Argument @var{$arg1} is a pointer to the newly-selected arena, and
116@var{$arg2} is a pointer to the arena previously used by that thread.
117
4d84e6ad 118This occurs within
6999d38c
AO
119@code{reused_arena}, right after the mutex mentioned in probe
120@code{memory_arena_reuse_wait} is acquired; argument @var{$arg1} will
121point to the same arena. In this configuration, this will usually only
122occur once per thread. The exception is when a thread first selected
123the main arena, but a subsequent allocation from it fails: then, and
8e52276e 124only then, may we switch to another arena to retry that allocation, and
6999d38c 125for further allocations within that thread.
51942fca 126@end deftp
6999d38c 127
6999d38c
AO
128@deftp Probe memory_arena_reuse_wait (void *@var{$arg1}, void *@var{$arg2}, void *@var{$arg3})
129This probe is triggered when @code{malloc} is about to wait for an arena
130to become available for reuse. Argument @var{$arg1} holds a pointer to
131the mutex the thread is going to wait on, @var{$arg2} is a pointer to a
132newly-chosen arena to be reused, and @var{$arg3} is a pointer to the
133arena previously used by that thread.
134
4d84e6ad 135This occurs within
6999d38c
AO
136@code{reused_arena}, when a thread first tries to allocate memory or
137needs a retry after a failure to allocate from the main arena, there
138isn't any free arena, the maximum number of arenas has been reached, and
139an existing arena was chosen for reuse, but its mutex could not be
140immediately acquired. The mutex in @var{$arg1} is the mutex of the
141selected arena.
51942fca 142@end deftp
6999d38c 143
6999d38c
AO
144@deftp Probe memory_arena_reuse_free_list (void *@var{$arg1})
145This probe is triggered when @code{malloc} has chosen an arena that is
146in the free list for use by a thread, within the @code{get_free_list}
4d84e6ad 147function. The argument @var{$arg1} holds a pointer to the selected arena.
6999d38c
AO
148@end deftp
149
3ea5be54
AO
150@deftp Probe memory_mallopt (int @var{$arg1}, int @var{$arg2})
151This probe is triggered when function @code{mallopt} is called to change
152@code{malloc} internal configuration parameters, before any change to
153the parameters is made. The arguments @var{$arg1} and @var{$arg2} are
154the ones passed to the @code{mallopt} function.
155@end deftp
0653427f
AO
156
157@deftp Probe memory_mallopt_mxfast (int @var{$arg1}, int @var{$arg2})
158This probe is triggered shortly after the @code{memory_mallopt} probe,
159when the parameter to be changed is @code{M_MXFAST}, and the requested
160value is in an acceptable range. Argument @var{$arg1} is the requested
161value, and @var{$arg2} is the previous value of this @code{malloc}
162parameter.
163@end deftp
164
165@deftp Probe memory_mallopt_trim_threshold (int @var{$arg1}, int @var{$arg2}, int @var{$arg3})
8e52276e 166This probe is triggered shortly after the @code{memory_mallopt} probe,
0653427f
AO
167when the parameter to be changed is @code{M_TRIM_THRESHOLD}. Argument
168@var{$arg1} is the requested value, @var{$arg2} is the previous value of
169this @code{malloc} parameter, and @var{$arg3} is nonzero if dynamic
170threshold adjustment was already disabled.
171@end deftp
172
173@deftp Probe memory_mallopt_top_pad (int @var{$arg1}, int @var{$arg2}, int @var{$arg3})
174This probe is triggered shortly after the @code{memory_mallopt} probe,
175when the parameter to be changed is @code{M_TOP_PAD}. Argument
176@var{$arg1} is the requested value, @var{$arg2} is the previous value of
177this @code{malloc} parameter, and @var{$arg3} is nonzero if dynamic
178threshold adjustment was already disabled.
179@end deftp
180
181@deftp Probe memory_mallopt_mmap_threshold (int @var{$arg1}, int @var{$arg2}, int @var{$arg3})
182This probe is triggered shortly after the @code{memory_mallopt} probe,
183when the parameter to be changed is @code{M_MMAP_THRESHOLD}, and the
184requested value is in an acceptable range. Argument @var{$arg1} is the
185requested value, @var{$arg2} is the previous value of this @code{malloc}
186parameter, and @var{$arg3} is nonzero if dynamic threshold adjustment
187was already disabled.
188@end deftp
189
190@deftp Probe memory_mallopt_mmap_max (int @var{$arg1}, int @var{$arg2}, int @var{$arg3})
191This probe is triggered shortly after the @code{memory_mallopt} probe,
192when the parameter to be changed is @code{M_MMAP_MAX}. Argument
193@var{$arg1} is the requested value, @var{$arg2} is the previous value of
194this @code{malloc} parameter, and @var{$arg3} is nonzero if dynamic
195threshold adjustment was already disabled.
196@end deftp
197
0653427f
AO
198@deftp Probe memory_mallopt_perturb (int @var{$arg1}, int @var{$arg2})
199This probe is triggered shortly after the @code{memory_mallopt} probe,
200when the parameter to be changed is @code{M_PERTURB}. Argument
201@var{$arg1} is the requested value, and @var{$arg2} is the previous
202value of this @code{malloc} parameter.
203@end deftp
204
205@deftp Probe memory_mallopt_arena_test (int @var{$arg1}, int @var{$arg2})
206This probe is triggered shortly after the @code{memory_mallopt} probe,
207when the parameter to be changed is @code{M_ARENA_TEST}, and the
208requested value is in an acceptable range. Argument @var{$arg1} is the
209requested value, and @var{$arg2} is the previous value of this
4d84e6ad 210@code{malloc} parameter.
0653427f
AO
211@end deftp
212
213@deftp Probe memory_mallopt_arena_max (int @var{$arg1}, int @var{$arg2})
214This probe is triggered shortly after the @code{memory_mallopt} probe,
215when the parameter to be changed is @code{M_ARENA_MAX}, and the
216requested value is in an acceptable range. Argument @var{$arg1} is the
217requested value, and @var{$arg2} is the previous value of this
4d84e6ad 218@code{malloc} parameter.
0653427f
AO
219@end deftp
220
221@deftp Probe memory_mallopt_free_dyn_thresholds (int @var{$arg1}, int @var{$arg2})
222This probe is triggered when function @code{free} decides to adjust the
223dynamic brk/mmap thresholds. Argument @var{$arg1} and @var{$arg2} are
224the adjusted mmap and trim thresholds, respectively.
225@end deftp
10e1cf6b 226
d5c3fafc
DD
227@deftp Probe memory_tunable_tcache_max_bytes (int @var{$arg1}, int @var{$arg2})
228This probe is triggered when the @code{glibc.malloc.tcache_max}
229tunable is set. Argument @var{$arg1} is the requested value, and
230@var{$arg2} is the previous value of this tunable.
231@end deftp
232
233@deftp Probe memory_tunable_tcache_count (int @var{$arg1}, int @var{$arg2})
234This probe is triggered when the @code{glibc.malloc.tcache_count}
235tunable is set. Argument @var{$arg1} is the requested value, and
236@var{$arg2} is the previous value of this tunable.
237@end deftp
238
239@deftp Probe memory_tunable_tcache_unsorted_limit (int @var{$arg1}, int @var{$arg2})
240This probe is triggered when the
241@code{glibc.malloc.tcache_unsorted_limit} tunable is set. Argument
242@var{$arg1} is the requested value, and @var{$arg2} is the previous
243value of this tunable.
244@end deftp
245
bcdaad21
DD
246@deftp Probe memory_tcache_double_free (void *@var{$arg1}, int @var{$arg2})
247This probe is triggered when @code{free} determines that the memory
248being freed has probably already been freed, and resides in the
249per-thread cache. Note that there is an extremely unlikely chance
250that this probe will trigger due to random payload data remaining in
251the allocated memory matching the key used to detect double frees.
252This probe actually indicates that an expensive linear search of the
253tcache, looking for a double free, has happened. Argument @var{$arg1}
254is the memory location as passed to @code{free}, Argument @var{$arg2}
255is the tcache bin it resides in.
256@end deftp
257
10e1cf6b
SP
258@node Mathematical Function Probes
259@section Mathematical Function Probes
260
261Some mathematical functions fall back to multiple precision arithmetic for
262some inputs to get last bit precision for their return values. This multiple
263precision fallback is much slower than the default algorithms and may have a
264significant impact on application performance. The systemtap probe markers
265described in this section may help you determine if your application calls
266mathematical functions with inputs that may result in multiple-precision
267arithmetic.
268
269Unless explicitly mentioned otherwise, a precision of 1 implies 24 bits of
270precision in the mantissa of the multiple precision number. Hence, a precision
271level of 32 implies 768 bits of precision in the mantissa.
272
10e1cf6b 273@deftp Probe slowatan2 (int @var{$arg1}, double @var{$arg2}, double @var{$arg3}, double @var{$arg4})
d35f1e80
WN
274This probe is triggered when the @code{atan2} function is called with
275an input that results in multiple precision computation. Argument
276@var{$arg1} is the precision with which computation succeeded.
277Arguments @var{$arg2} and @var{$arg3} are inputs to the @code{atan2}
278function and @var{$arg4} is the computed result.
10e1cf6b
SP
279@end deftp
280
281@deftp Probe slowatan2_inexact (int @var{$arg1}, double @var{$arg2}, double @var{$arg3}, double @var{$arg4})
d35f1e80
WN
282This probe is triggered when the @code{atan} function is called with
283an input that results in multiple precision computation and none of
284the multiple precision computations result in an accurate result.
285Argument @var{$arg1} is the maximum precision with which computations
286were performed. Arguments @var{$arg2} and @var{$arg3} are inputs to
287the @code{atan2} function and @var{$arg4} is the computed result.
10e1cf6b
SP
288@end deftp
289
290@deftp Probe slowatan (int @var{$arg1}, double @var{$arg2}, double @var{$arg3})
d35f1e80
WN
291This probe is triggered when the @code{atan} function is called with
292an input that results in multiple precision computation. Argument
293@var{$arg1} is the precision with which computation succeeded.
294Argument @var{$arg2} is the input to the @code{atan} function and
295@var{$arg3} is the computed result.
10e1cf6b
SP
296@end deftp
297
298@deftp Probe slowatan_inexact (int @var{$arg1}, double @var{$arg2}, double @var{$arg3})
d35f1e80
WN
299This probe is triggered when the @code{atan} function is called with
300an input that results in multiple precision computation and none of
301the multiple precision computations result in an accurate result.
302Argument @var{$arg1} is the maximum precision with which computations
303were performed. Argument @var{$arg2} is the input to the @code{atan}
304function and @var{$arg3} is the computed result.
10e1cf6b
SP
305@end deftp
306
307@deftp Probe slowtan (double @var{$arg1}, double @var{$arg2})
d35f1e80
WN
308This probe is triggered when the @code{tan} function is called with an
309input that results in multiple precision computation with precision
31032. Argument @var{$arg1} is the input to the function and @var{$arg2}
311is the computed result.
10e1cf6b 312@end deftp
f3fd2628
SP
313
314@deftp Probe slowasin (double @var{$arg1}, double @var{$arg2})
d35f1e80
WN
315This probe is triggered when the @code{asin} function is called with
316an input that results in multiple precision computation with precision
31732. Argument @var{$arg1} is the input to the function and @var{$arg2}
318is the computed result.
f3fd2628
SP
319@end deftp
320
321@deftp Probe slowacos (double @var{$arg1}, double @var{$arg2})
d35f1e80
WN
322This probe is triggered when the @code{acos} function is called with
323an input that results in multiple precision computation with precision
32432. Argument @var{$arg1} is the input to the function and @var{$arg2}
325is the computed result.
f3fd2628
SP
326@end deftp
327
328@deftp Probe slowsin (double @var{$arg1}, double @var{$arg2})
d35f1e80
WN
329This probe is triggered when the @code{sin} function is called with an
330input that results in multiple precision computation with precision
33132. Argument @var{$arg1} is the input to the function and @var{$arg2}
332is the computed result.
f3fd2628
SP
333@end deftp
334
335@deftp Probe slowcos (double @var{$arg1}, double @var{$arg2})
d35f1e80
WN
336This probe is triggered when the @code{cos} function is called with an
337input that results in multiple precision computation with precision
33832. Argument @var{$arg1} is the input to the function and @var{$arg2}
339is the computed result.
f3fd2628
SP
340@end deftp
341
342@deftp Probe slowsin_dx (double @var{$arg1}, double @var{$arg2}, double @var{$arg3})
d35f1e80
WN
343This probe is triggered when the @code{sin} function is called with an
344input that results in multiple precision computation with precision
34532. Argument @var{$arg1} is the input to the function, @var{$arg2} is
346the error bound of @var{$arg1} and @var{$arg3} is the computed result.
f3fd2628
SP
347@end deftp
348
349@deftp Probe slowcos_dx (double @var{$arg1}, double @var{$arg2}, double @var{$arg3})
d35f1e80
WN
350This probe is triggered when the @code{cos} function is called with an
351input that results in multiple precision computation with precision
35232. Argument @var{$arg1} is the input to the function, @var{$arg2} is
353the error bound of @var{$arg1} and @var{$arg3} is the computed result.
f3fd2628 354@end deftp
7b3436d4
WN
355
356@node Non-local Goto Probes
357@section Non-local Goto Probes
358
359These probes are used to signal calls to @code{setjmp}, @code{sigsetjmp},
360@code{longjmp} or @code{siglongjmp}.
361
362@deftp Probe setjmp (void *@var{$arg1}, int @var{$arg2}, void *@var{$arg3})
363This probe is triggered whenever @code{setjmp} or @code{sigsetjmp} is
364called. Argument @var{$arg1} is a pointer to the @code{jmp_buf}
365passed as the first argument of @code{setjmp} or @code{sigsetjmp},
366@var{$arg2} is the second argument of @code{sigsetjmp} or zero if this
367is a call to @code{setjmp} and @var{$arg3} is a pointer to the return
368address that will be stored in the @code{jmp_buf}.
369@end deftp
370
371@deftp Probe longjmp (void *@var{$arg1}, int @var{$arg2}, void *@var{$arg3})
372This probe is triggered whenever @code{longjmp} or @code{siglongjmp}
cf822e3c 373is called. Argument @var{$arg1} is a pointer to the @code{jmp_buf}
7b3436d4
WN
374passed as the first argument of @code{longjmp} or @code{siglongjmp},
375@var{$arg2} is the return value passed as the second argument of
376@code{longjmp} or @code{siglongjmp} and @var{$arg3} is a pointer to
377the return address @code{longjmp} or @code{siglongjmp} will return to.
378
379The @code{longjmp} probe is triggered at a point where the registers
380have not yet been restored to the values in the @code{jmp_buf} and
381unwinding will show a call stack including the caller of
382@code{longjmp} or @code{siglongjmp}.
383@end deftp
384
385@deftp Probe longjmp_target (void *@var{$arg1}, int @var{$arg2}, void *@var{$arg3})
386This probe is triggered under the same conditions and with the same
387arguments as the @code{longjmp} probe.
388
389The @code{longjmp_target} probe is triggered at a point where the
390registers have been restored to the values in the @code{jmp_buf} and
391unwinding will show a call stack including the caller of @code{setjmp}
392or @code{sigsetjmp}.
393@end deftp