Fix careless merge.
[glibc.git] / manual / probes.texi
blob1a45c69b9148e92bbb6b5bd0bc644c1d6c093525
1 @node Internal Probes
2 @c @node Internal Probes, , POSIX Threads, Top
3 @c %MENU% Probes to monitor libc internal behavior
4 @chapter Internal probes
6 In order to aid in debugging and monitoring internal behavior,
7 @theglibc{} exposes nearly-zero-overhead SystemTap probes marked with
8 the @code{libc} provider.
10 These probes are not part of the @glibcadj{} stable ABI, and they are
11 subject to change or removal across releases.  Our only promise with
12 regard to them is that, if we find a need to remove or modify the
13 arguments of a probe, the modified probe will have a different name, so
14 that program monitors relying on the old probe will not get unexpected
15 arguments.
17 @menu
18 * Memory Allocation Probes::  Probes in the memory allocation subsystem
19 @end menu
21 @node Memory Allocation Probes
22 @section Memory Allocation Probes
24 These probes are designed to signal relatively unusual situations within
25 the virtual memory subsystem of @theglibc{}.  The location and the
26 availability of some probes depend on whether per-thread arenas are
27 enabled (the default) or disabled at the time @theglibc{} is compiled.
29 @deftp Probe memory_sbrk_more (void *@var{$arg1}, size_t @var{$arg2})
30 This 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
36 @deftp Probe memory_sbrk_less (void *@var{$arg1}, size_t @var{$arg2})
37 This probe is triggered after the size of the main arena is decreased by
38 calling @code{sbrk}.  Argument @var{$arg1} is the size released by
39 @code{sbrk} (the positive value, rather than the negative value passed
40 to @code{sbrk}), and @var{$arg2} is the pointer that marks the end of
41 the @code{sbrk} area, returned in response to the request.
42 @end deftp
44 @deftp Probe memory_heap_new (void *@var{$arg1}, size_t @var{$arg2})
45 This 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
48 the heap.
49 @end deftp
51 @deftp Probe memory_heap_free (void *@var{$arg1}, size_t @var{$arg2})
52 This probe is triggered @emph{before} (unlike the other sbrk and heap
53 probes) 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
55 heap.
56 @end deftp
58 @deftp Probe memory_heap_more (void *@var{$arg1}, size_t @var{$arg2})
59 This probe is triggered after a trailing portion of an @code{mmap}ed
60 heap 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
64 @deftp Probe memory_heap_less (void *@var{$arg1}, size_t @var{$arg2})
65 This probe is triggered after a trailing portion of an @code{mmap}ed
66 heap 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
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})
73 @deftpx Probe memory_valloc_retry (size_t @var{$arg1})
74 @deftpx Probe memory_pvalloc_retry (size_t @var{$arg1})
75 @deftpx Probe memory_calloc_retry (size_t @var{$arg1})
76 These probes are triggered when the corresponding functions fail to
77 obtain the requested amount of memory from the arena in use, before they
78 call @code{arena_get_retry} to select an alternate arena in which to
79 retry the allocation.  Argument @var{$arg1} is the amount of memory
80 requested by the user; in the @code{calloc} case, that is the total size
81 computed from both function arguments.  In the @code{realloc} case,
82 @var{$arg2} is the pointer to the memory area being resized.  In the
83 @code{memalign} case, @var{$arg2} is the alignment to be used for the
84 request, which may be stricter than the value passed to the
85 @code{memalign} function.
87 Note that the argument order does @emph{not} match that of the
88 corresponding two-argument functions, so that in all of these probes the
89 user-requested allocation size is in @var{$arg1}.
90 @end deftp
92 @deftp Probe memory_arena_retry (size_t @var{$arg1}, void *@var{$arg2})
93 This probe is triggered within @code{arena_get_retry} (the function
94 called to select the alternate arena in which to retry an allocation
95 that failed on the first attempt), before the selection of an alternate
96 arena.  This probe is redundant, but much easier to use when it's not
97 important to determine which of the various memory allocation functions
98 is failing to allocate on the first try.  Argument @var{$arg1} is the
99 same as in the function-specific probes, except for extra room for
100 padding introduced by functions that have to ensure stricter alignment.
101 Argument @var{$arg2} is the arena in which allocation failed.
102 @end deftp
104 @deftp Probe memory_arena_new (void *@var{$arg1}, size_t @var{$arg2})
105 This probe is triggered when @code{malloc} allocates and initializes an
106 additional arena (not the main arena), but before the arena is assigned
107 to the running thread or inserted into the internal linked list of
108 arenas.  The arena's @code{malloc_state} internal data structure is
109 located at @var{$arg1}, within a newly-allocated heap big enough to hold
110 at least @var{$arg2} bytes.
111 @end deftp
113 @deftp Probe memory_arena_reuse (void *@var{$arg1}, void *@var{$arg2})
114 This probe is triggered when @code{malloc} has just selected an existing
115 arena to reuse, and (temporarily) reserved it for exclusive use.
116 Argument @var{$arg1} is a pointer to the newly-selected arena, and
117 @var{$arg2} is a pointer to the arena previously used by that thread.
119 When per-thread arenas are enabled, this occurs within
120 @code{reused_arena}, right after the mutex mentioned in probe
121 @code{memory_arena_reuse_wait} is acquired; argument @var{$arg1} will
122 point to the same arena.  In this configuration, this will usually only
123 occur once per thread.  The exception is when a thread first selected
124 the main arena, but a subsequent allocation from it fails: then, and
125 only then, may we switch to another arena to retry that allocations, and
126 for further allocations within that thread.
128 When per-thread arenas are disabled, this occurs within
129 @code{arena_get2}, whenever the mutex for the previously-selected arena
130 cannot be immediately acquired.
131 @end deftp
133 @deftp Probe memory_arena_reuse_wait (void *@var{$arg1}, void *@var{$arg2}, void *@var{$arg3})
134 This probe is triggered when @code{malloc} is about to wait for an arena
135 to become available for reuse.  Argument @var{$arg1} holds a pointer to
136 the mutex the thread is going to wait on, @var{$arg2} is a pointer to a
137 newly-chosen arena to be reused, and @var{$arg3} is a pointer to the
138 arena previously used by that thread.
140 When per-thread arenas are enabled, this occurs within
141 @code{reused_arena}, when a thread first tries to allocate memory or
142 needs a retry after a failure to allocate from the main arena, there
143 isn't any free arena, the maximum number of arenas has been reached, and
144 an existing arena was chosen for reuse, but its mutex could not be
145 immediately acquired.  The mutex in @var{$arg1} is the mutex of the
146 selected arena.
148 When per-thread arenas are disabled, this occurs within
149 @code{arena_get2}, when a thread first tries to allocate memory or the
150 mutex of the arena it previously used could not be immediately acquired,
151 and none of the existing arenas could be immediately reserved for
152 exclusive use.  The mutex in @var{$arg1} is that of the list of arenas,
153 and since the arena won't have been selected yet, @var{$arg2} will be
154 @code{NULL}.
155 @end deftp
157 @deftp Probe memory_arena_reuse_free_list (void *@var{$arg1})
158 This probe is triggered when @code{malloc} has chosen an arena that is
159 in the free list for use by a thread, within the @code{get_free_list}
160 function.  This probe is only available when @code{malloc} is configured
161 to use per-thread arenas.  The argument @var{$arg1} holds a pointer to
162 the selected arena.
163 @end deftp
165 @deftp Probe memory_arena_reuse_realloc (void *@var{$arg1})
166 This probe is triggered within @code{realloc}, as the arena of the
167 current thread is changed to match that in which the given address was
168 allocated.  This probe is @emph{not} available when @code{malloc} is
169 configured to use per-thread arenas.  The argument @var{$arg1} holds a
170 pointer to the newly-selected arena.
171 @end deftp
173 @deftp Probe memory_mallopt (int @var{$arg1}, int @var{$arg2})
174 This probe is triggered when function @code{mallopt} is called to change
175 @code{malloc} internal configuration parameters, before any change to
176 the parameters is made.  The arguments @var{$arg1} and @var{$arg2} are
177 the ones passed to the @code{mallopt} function.
178 @end deftp
180 @deftp Probe memory_mallopt_mxfast (int @var{$arg1}, int @var{$arg2})
181 This probe is triggered shortly after the @code{memory_mallopt} probe,
182 when the parameter to be changed is @code{M_MXFAST}, and the requested
183 value is in an acceptable range.  Argument @var{$arg1} is the requested
184 value, and @var{$arg2} is the previous value of this @code{malloc}
185 parameter.
186 @end deftp
188 @deftp Probe memory_mallopt_trim_threshold (int @var{$arg1}, int @var{$arg2}, int @var{$arg3})
189 This probe is triggere shortly after the @code{memory_mallopt} probe,
190 when the parameter to be changed is @code{M_TRIM_THRESHOLD}.  Argument
191 @var{$arg1} is the requested value, @var{$arg2} is the previous value of
192 this @code{malloc} parameter, and @var{$arg3} is nonzero if dynamic
193 threshold adjustment was already disabled.
194 @end deftp
196 @deftp Probe memory_mallopt_top_pad (int @var{$arg1}, int @var{$arg2}, int @var{$arg3})
197 This probe is triggered shortly after the @code{memory_mallopt} probe,
198 when the parameter to be changed is @code{M_TOP_PAD}.  Argument
199 @var{$arg1} is the requested value, @var{$arg2} is the previous value of
200 this @code{malloc} parameter, and @var{$arg3} is nonzero if dynamic
201 threshold adjustment was already disabled.
202 @end deftp
204 @deftp Probe memory_mallopt_mmap_threshold (int @var{$arg1}, int @var{$arg2}, int @var{$arg3})
205 This probe is triggered shortly after the @code{memory_mallopt} probe,
206 when the parameter to be changed is @code{M_MMAP_THRESHOLD}, and the
207 requested value is in an acceptable range.  Argument @var{$arg1} is the
208 requested value, @var{$arg2} is the previous value of this @code{malloc}
209 parameter, and @var{$arg3} is nonzero if dynamic threshold adjustment
210 was already disabled.
211 @end deftp
213 @deftp Probe memory_mallopt_mmap_max (int @var{$arg1}, int @var{$arg2}, int @var{$arg3})
214 This probe is triggered shortly after the @code{memory_mallopt} probe,
215 when the parameter to be changed is @code{M_MMAP_MAX}.  Argument
216 @var{$arg1} is the requested value, @var{$arg2} is the previous value of
217 this @code{malloc} parameter, and @var{$arg3} is nonzero if dynamic
218 threshold adjustment was already disabled.
219 @end deftp
221 @deftp Probe memory_mallopt_check_action (int @var{$arg1}, int @var{$arg2})
222 This probe is triggered shortly after the @code{memory_mallopt} probe,
223 when the parameter to be changed is @code{M_CHECK_ACTION}.  Argument
224 @var{$arg1} is the requested value, and @var{$arg2} is the previous
225 value of this @code{malloc} parameter.
226 @end deftp
228 @deftp Probe memory_mallopt_perturb (int @var{$arg1}, int @var{$arg2})
229 This probe is triggered shortly after the @code{memory_mallopt} probe,
230 when the parameter to be changed is @code{M_PERTURB}.  Argument
231 @var{$arg1} is the requested value, and @var{$arg2} is the previous
232 value of this @code{malloc} parameter.
233 @end deftp
235 @deftp Probe memory_mallopt_arena_test (int @var{$arg1}, int @var{$arg2})
236 This probe is triggered shortly after the @code{memory_mallopt} probe,
237 when the parameter to be changed is @code{M_ARENA_TEST}, and the
238 requested value is in an acceptable range.  Argument @var{$arg1} is the
239 requested value, and @var{$arg2} is the previous value of this
240 @code{malloc} parameter.  This probe is only available when per-thread
241 arenas are enabled.
242 @end deftp
244 @deftp Probe memory_mallopt_arena_max (int @var{$arg1}, int @var{$arg2})
245 This probe is triggered shortly after the @code{memory_mallopt} probe,
246 when the parameter to be changed is @code{M_ARENA_MAX}, and the
247 requested value is in an acceptable range.  Argument @var{$arg1} is the
248 requested value, and @var{$arg2} is the previous value of this
249 @code{malloc} parameter.  This probe is only available when per-thread
250 arenas are enabled.
251 @end deftp
253 @deftp Probe memory_mallopt_free_dyn_thresholds (int @var{$arg1}, int @var{$arg2})
254 This probe is triggered when function @code{free} decides to adjust the
255 dynamic brk/mmap thresholds.  Argument @var{$arg1} and @var{$arg2} are
256 the adjusted mmap and trim thresholds, respectively.
257 @end deftp