2013-09-20 Alexandre Oliva <aoliva@redhat.com>
+ * malloc/malloc.c (__libc_malloc): Add memory_malloc_retry probe.
+ (__libc_realloc): Add memory_realloc_retry probe.
+ (__libc_memalign): Add memory_memalign_retry probe.
+ (__libc_valloc): Add memory_valloc_retry probe.
+ (__libc_pvalloc): Add memory_pvalloc_retry probe.
+ (__libc_calloc): Add memory_calloc_retry probe.
+ * manual/probes.texi: Document them.
+
* malloc/arena.c (get_free_list): Add probe
memory_arena_reuse_free_list.
(reused_arena) [PER_THREAD]: Add probes memory_arena_reuse_wait
return 0;
victim = _int_malloc(ar_ptr, bytes);
if(!victim) {
+ LIBC_PROBE (memory_malloc_retry, 1, bytes);
ar_ptr = arena_get_retry(ar_ptr, bytes);
if (__builtin_expect(ar_ptr != NULL, 1)) {
victim = _int_malloc(ar_ptr, bytes);
if (newp == NULL)
{
/* Try harder to allocate memory in other arenas. */
+ LIBC_PROBE (memory_realloc_retry, 2, bytes, oldmem);
newp = __libc_malloc(bytes);
if (newp != NULL)
{
return 0;
p = _int_memalign(ar_ptr, alignment, bytes);
if(!p) {
+ LIBC_PROBE (memory_memalign_retry, 2, bytes, alignment);
ar_ptr = arena_get_retry (ar_ptr, bytes);
if (__builtin_expect(ar_ptr != NULL, 1)) {
p = _int_memalign(ar_ptr, alignment, bytes);
return 0;
p = _int_valloc(ar_ptr, bytes);
if(!p) {
+ LIBC_PROBE (memory_valloc_retry, 1, bytes);
ar_ptr = arena_get_retry (ar_ptr, bytes);
if (__builtin_expect(ar_ptr != NULL, 1)) {
p = _int_memalign(ar_ptr, pagesz, bytes);
arena_get(ar_ptr, bytes + 2*pagesz + MINSIZE);
p = _int_pvalloc(ar_ptr, bytes);
if(!p) {
+ LIBC_PROBE (memory_pvalloc_retry, 1, bytes);
ar_ptr = arena_get_retry (ar_ptr, bytes + 2*pagesz + MINSIZE);
if (__builtin_expect(ar_ptr != NULL, 1)) {
p = _int_memalign(ar_ptr, pagesz, rounded_bytes);
av == arena_for_chunk(mem2chunk(mem)));
if (mem == 0) {
+ LIBC_PROBE (memory_calloc_retry, 1, sz);
av = arena_get_retry (av, sz);
if (__builtin_expect(av != NULL, 1)) {
mem = _int_malloc(av, sz);
availability of some probes depend on whether per-thread arenas are
enabled (the default) or disabled at the time @theglibc{} is compiled.
+@deftp Probe memory_malloc_retry (size_t @var{$arg1})
+@deftpx Probe memory_realloc_retry (size_t @var{$arg1}, void *@var{$arg2})
+@deftpx Probe memory_memalign_retry (size_t @var{$arg1}, size_t @var{$arg2})
+@deftpx Probe memory_valloc_retry (size_t @var{$arg1})
+@deftpx Probe memory_pvalloc_retry (size_t @var{$arg1})
+@deftpx Probe memory_calloc_retry (size_t @var{$arg1})
+These probes are triggered when the corresponding functions fail to
+obtain the requested amount of memory from the arena in use, before they
+call @code{arena_get_retry} to select an alternate arena in which to
+retry the allocation. Argument @var{$arg1} is the amount of memory
+requested by the user; in the @code{calloc} case, that is the total size
+computed from both function arguments. In the @code{realloc} case,
+@var{$arg2} is the pointer to the memory area being resized. In the
+@code{memalign} case, @var{$arg2} is the alignment to be used for the
+request, which may be stricter than the value passed to the
+@code{memalign} function.
+
+Note that the argument order does @emph{not} match that of the
+corresponding two-argument functions, so that in all of these probes the
+user-requested allocation size is in @var{$arg1}.
+@end deftp
+
@deftp Probe memory_arena_new (void *@var{$arg1}, size_t @var{$arg2})
This probe is triggered when @code{malloc} allocates and initializes an
additional arena (not the main arena), but before the arena is assigned