ce426f
Author: Alexandre Oliva <aoliva@redhat.com>
ce426f
ce426f
    Add malloc probes for sbrk and heap resizing.
ce426f
    
ce426f
    	* malloc/arena.c (new_heap): New memory_heap_new probe.
ce426f
    	(grow_heap): New memory_heap_more probe.
ce426f
    	(shrink_heap): New memory_heap_less probe.
ce426f
    	(heap_trim): New memory_heap_free probe.
ce426f
    	* malloc/malloc.c (sysmalloc): New memory_sbrk_more probe.
ce426f
    	(systrim): New memory_sbrk_less probe.
ce426f
    	* manual/probes.texi: Document them.
ce426f
ce426f
    Add catch-all alloc retry probe.
ce426f
    
ce426f
    	* malloc/arena.c (arena_get_retry): Add memory_arena_retry probe.
ce426f
    	* manual/probes.texi: Document it.
ce426f
ce426f
    Add probes for malloc retries.
ce426f
    
ce426f
    	* malloc/malloc.c (__libc_malloc): Add memory_malloc_retry probe.
ce426f
    	(__libc_realloc): Add memory_realloc_retry probe.
ce426f
    	(__libc_memalign): Add memory_memalign_retry probe.
ce426f
    	(__libc_valloc): Add memory_valloc_retry probe.
ce426f
    	(__libc_pvalloc): Add memory_pvalloc_retry probe.
ce426f
    	(__libc_calloc): Add memory_calloc_retry probe.
ce426f
    	* manual/probes.texi: Document them.
ce426f
ce426f
    Add probes for malloc arena changes.
ce426f
    
ce426f
    	* malloc/arena.c (get_free_list): Add probe
ce426f
    	memory_arena_reuse_free_list.
ce426f
    	(reused_arena) [PER_THREAD]: Add probes memory_arena_reuse_wait
ce426f
    	and memory_arena_reuse.
ce426f
    	(arena_get2) [!PER_THREAD]: Likewise.
ce426f
    	* malloc/malloc.c (__libc_realloc) [!PER_THREAD]: Add probe
ce426f
    	memory_arena_reuse_realloc.
ce426f
    	* manual/probes.texi: Document them.
ce426f
ce426f
    Add probes for all changes to malloc options.
ce426f
    
ce426f
    	* malloc/malloc.c (__libc_free): Add
ce426f
    	memory_mallopt_free_dyn_thresholds probe.
ce426f
    	(__libc_mallopt): Add multiple memory_mallopt probes.
ce426f
    	* manual/probes.texi: Document them.
ce426f
ce426f
    Add first set of memory probes.
ce426f
    
ce426f
    	* malloc/malloc.c: Include stap-probe.h.
ce426f
    	(__libc_mallopt): Add memory_mallopt probe.
ce426f
    	* malloc/arena.c (_int_new_arena): Add memory_arena_new probe.
ce426f
    	* manual/probes.texi: New.
ce426f
    	* manual/Makefile (chapters): Add probes.
ce426f
    	* manual/debug.texi: Set next node.
ce426f
ce426f
Index: glibc-2.17-c758a686/malloc/arena.c
ce426f
===================================================================
ce426f
--- glibc-2.17-c758a686/malloc/arena.c.orig
ce426f
+++ glibc-2.17-c758a686/malloc/arena.c
ce426f
@@ -586,6 +586,7 @@ new_heap(size_t size, size_t top_pad)
ce426f
   h->size = size;
ce426f
   h->mprotect_size = size;
ce426f
   THREAD_STAT(stat_n_heaps++);
ce426f
+  LIBC_PROBE (memory_heap_new, 2, h, h->size);
ce426f
   return h;
ce426f
 }
ce426f
 
ce426f
@@ -611,6 +612,7 @@ grow_heap(heap_info *h, long diff)
ce426f
   }
ce426f
 
ce426f
   h->size = new_size;
ce426f
+  LIBC_PROBE (memory_heap_more, 2, h, h->size);
ce426f
   return 0;
ce426f
 }
ce426f
 
ce426f
@@ -638,6 +640,7 @@ shrink_heap(heap_info *h, long diff)
ce426f
   /*fprintf(stderr, "shrink %p %08lx\n", h, new_size);*/
ce426f
 
ce426f
   h->size = new_size;
ce426f
+  LIBC_PROBE (memory_heap_less, 2, h, h->size);
ce426f
   return 0;
ce426f
 }
ce426f
 
ce426f
@@ -679,6 +682,7 @@ heap_trim(heap_info *heap, size_t pad)
ce426f
       break;
ce426f
     ar_ptr->system_mem -= heap->size;
ce426f
     arena_mem -= heap->size;
ce426f
+    LIBC_PROBE (memory_heap_free, 2, heap, heap->size);
ce426f
     delete_heap(heap);
ce426f
     heap = prev_heap;
ce426f
     if(!prev_inuse(p)) { /* consolidate backward */
ce426f
@@ -741,6 +745,7 @@ _int_new_arena(size_t size)
ce426f
   top(a) = (mchunkptr)ptr;
ce426f
   set_head(top(a), (((char*)h + h->size) - ptr) | PREV_INUSE);
ce426f
 
ce426f
+  LIBC_PROBE (memory_arena_new, 2, a, size);
ce426f
   tsd_setspecific(arena_key, (void *)a);
ce426f
   mutex_init(&a->mutex);
ce426f
   (void)mutex_lock(&a->mutex);
ce426f
@@ -779,6 +784,7 @@ get_free_list (void)
ce426f
 
ce426f
       if (result != NULL)
ce426f
 	{
ce426f
+	  LIBC_PROBE (memory_arena_reuse_free_list, 1, result);
ce426f
 	  (void)mutex_lock(&result->mutex);
ce426f
 	  tsd_setspecific(arena_key, (void *)result);
ce426f
 	  THREAD_STAT(++(result->stat_lock_loop));
ce426f
@@ -815,9 +821,11 @@ reused_arena (mstate avoid_arena)
ce426f
     result = result->next;
ce426f
 
ce426f
   /* No arena available.  Wait for the next in line.  */
ce426f
+  LIBC_PROBE (memory_arena_reuse_wait, 3, &result->mutex, result, avoid_arena);
ce426f
   (void)mutex_lock(&result->mutex);
ce426f
 
ce426f
  out:
ce426f
+  LIBC_PROBE (memory_arena_reuse, 2, result, avoid_arena);
ce426f
   tsd_setspecific(arena_key, (void *)result);
ce426f
   THREAD_STAT(++(result->stat_lock_loop));
ce426f
   next_to_use = result->next;
ce426f
@@ -896,6 +904,7 @@ arena_get2(mstate a_tsd, size_t size, ms
ce426f
       if (retried)
ce426f
 	(void)mutex_unlock(&list_lock);
ce426f
       THREAD_STAT(++(a->stat_lock_loop));
ce426f
+      LIBC_PROBE (memory_arena_reuse, 2, a, a_tsd);
ce426f
       tsd_setspecific(arena_key, (void *)a);
ce426f
       return a;
ce426f
     }
ce426f
@@ -908,6 +917,7 @@ arena_get2(mstate a_tsd, size_t size, ms
ce426f
      locks. */
ce426f
   if(!retried && mutex_trylock(&list_lock)) {
ce426f
     /* We will block to not run in a busy loop.  */
ce426f
+    LIBC_PROBE (memory_arena_reuse_wait, 3, &list_lock, NULL, a_tsd);
ce426f
     (void)mutex_lock(&list_lock);
ce426f
 
ce426f
     /* Since we blocked there might be an arena available now.  */
ce426f
@@ -931,6 +941,7 @@ arena_get2(mstate a_tsd, size_t size, ms
ce426f
 static mstate
ce426f
 arena_get_retry (mstate ar_ptr, size_t bytes)
ce426f
 {
ce426f
+  LIBC_PROBE (memory_arena_retry, 2, bytes, ar_ptr);
ce426f
   if(ar_ptr != &main_arena) {
ce426f
     (void)mutex_unlock(&ar_ptr->mutex);
ce426f
     ar_ptr = &main_arena;
ce426f
Index: glibc-2.17-c758a686/malloc/malloc.c
ce426f
===================================================================
ce426f
--- glibc-2.17-c758a686/malloc/malloc.c.orig
ce426f
+++ glibc-2.17-c758a686/malloc/malloc.c
ce426f
@@ -1884,6 +1884,8 @@ static int perturb_byte;
ce426f
 #define free_perturb(p, n) memset (p, perturb_byte & 0xff, n)
ce426f
 
ce426f
 
ce426f
+#include <stap-probe.h>
ce426f
+
ce426f
 /* ------------------- Support for multiple arenas -------------------- */
ce426f
 #include "arena.c"
ce426f
 
ce426f
@@ -2452,8 +2454,10 @@ static void* sysmalloc(INTERNAL_SIZE_T n
ce426f
     below even if we cannot call MORECORE.
ce426f
   */
ce426f
 
ce426f
-  if (size > 0)
ce426f
+  if (size > 0) {
ce426f
     brk = (char*)(MORECORE(size));
ce426f
+    LIBC_PROBE (memory_sbrk_more, 2, brk, size);
ce426f
+  }
ce426f
 
ce426f
   if (brk != (char*)(MORECORE_FAILURE)) {
ce426f
     /* Call the `morecore' hook if necessary.  */
ce426f
@@ -2753,6 +2757,8 @@ static int systrim(size_t pad, mstate av
ce426f
 	(*hook) ();
ce426f
       new_brk = (char*)(MORECORE(0));
ce426f
 
ce426f
+      LIBC_PROBE (memory_sbrk_less, 2, new_brk, extra);
ce426f
+
ce426f
       if (new_brk != (char*)MORECORE_FAILURE) {
ce426f
 	released = (long)(current_brk - new_brk);
ce426f
 
ce426f
@@ -2862,6 +2868,7 @@ __libc_malloc(size_t bytes)
ce426f
     return 0;
ce426f
   victim = _int_malloc(ar_ptr, bytes);
ce426f
   if(!victim) {
ce426f
+    LIBC_PROBE (memory_malloc_retry, 1, bytes);
ce426f
     ar_ptr = arena_get_retry(ar_ptr, bytes);
ce426f
     if (__builtin_expect(ar_ptr != NULL, 1)) {
ce426f
       victim = _int_malloc(ar_ptr, bytes);
ce426f
@@ -2902,6 +2909,8 @@ __libc_free(void* mem)
ce426f
       {
ce426f
 	mp_.mmap_threshold = chunksize (p);
ce426f
 	mp_.trim_threshold = 2 * mp_.mmap_threshold;
ce426f
+	LIBC_PROBE (memory_mallopt_free_dyn_thresholds, 2,
ce426f
+		    mp_.mmap_threshold, mp_.trim_threshold);
ce426f
       }
ce426f
     munmap_chunk(p);
ce426f
     return;
ce426f
@@ -2981,6 +2990,7 @@ __libc_realloc(void* oldmem, size_t byte
ce426f
 #endif
ce426f
 
ce426f
 #if !defined PER_THREAD
ce426f
+  LIBC_PROBE (memory_arena_reuse_realloc, 1, ar_ptr);
ce426f
   /* As in malloc(), remember this arena for the next allocation. */
ce426f
   tsd_setspecific(arena_key, (void *)ar_ptr);
ce426f
 #endif
ce426f
@@ -2994,6 +3004,7 @@ __libc_realloc(void* oldmem, size_t byte
ce426f
   if (newp == NULL)
ce426f
     {
ce426f
       /* Try harder to allocate memory in other arenas.  */
ce426f
+      LIBC_PROBE (memory_realloc_retry, 2, bytes, oldmem);
ce426f
       newp = __libc_malloc(bytes);
ce426f
       if (newp != NULL)
ce426f
 	{
ce426f
@@ -3029,6 +3040,7 @@ __libc_memalign(size_t alignment, size_t
ce426f
     return 0;
ce426f
   p = _int_memalign(ar_ptr, alignment, bytes);
ce426f
   if(!p) {
ce426f
+    LIBC_PROBE (memory_memalign_retry, 2, bytes, alignment);
ce426f
     ar_ptr = arena_get_retry (ar_ptr, bytes);
ce426f
     if (__builtin_expect(ar_ptr != NULL, 1)) {
ce426f
       p = _int_memalign(ar_ptr, alignment, bytes);
ce426f
@@ -3066,6 +3078,7 @@ __libc_valloc(size_t bytes)
ce426f
     return 0;
ce426f
   p = _int_valloc(ar_ptr, bytes);
ce426f
   if(!p) {
ce426f
+    LIBC_PROBE (memory_valloc_retry, 1, bytes);
ce426f
     ar_ptr = arena_get_retry (ar_ptr, bytes);
ce426f
     if (__builtin_expect(ar_ptr != NULL, 1)) {
ce426f
       p = _int_memalign(ar_ptr, pagesz, bytes);
ce426f
@@ -3101,6 +3114,7 @@ __libc_pvalloc(size_t bytes)
ce426f
   arena_get(ar_ptr, bytes + 2*pagesz + MINSIZE);
ce426f
   p = _int_pvalloc(ar_ptr, bytes);
ce426f
   if(!p) {
ce426f
+    LIBC_PROBE (memory_pvalloc_retry, 1, bytes);
ce426f
     ar_ptr = arena_get_retry (ar_ptr, bytes + 2*pagesz + MINSIZE);
ce426f
     if (__builtin_expect(ar_ptr != NULL, 1)) {
ce426f
       p = _int_memalign(ar_ptr, pagesz, rounded_bytes);
ce426f
@@ -3177,6 +3191,7 @@ __libc_calloc(size_t n, size_t elem_size
ce426f
 	 av == arena_for_chunk(mem2chunk(mem)));
ce426f
 
ce426f
   if (mem == 0) {
ce426f
+    LIBC_PROBE (memory_calloc_retry, 1, sz);
ce426f
     av = arena_get_retry (av, sz);
ce426f
     if (__builtin_expect(av != NULL, 1)) {
ce426f
       mem = _int_malloc(av, sz);
ce426f
@@ -4695,21 +4710,29 @@ int __libc_mallopt(int param_number, int
ce426f
   /* Ensure initialization/consolidation */
ce426f
   malloc_consolidate(av);
ce426f
 
ce426f
+  LIBC_PROBE (memory_mallopt, 2, param_number, value);
ce426f
+
ce426f
   switch(param_number) {
ce426f
   case M_MXFAST:
ce426f
-    if (value >= 0 && value <= MAX_FAST_SIZE) {
ce426f
-      set_max_fast(value);
ce426f
-    }
ce426f
+    if (value >= 0 && value <= MAX_FAST_SIZE)
ce426f
+      {
ce426f
+	LIBC_PROBE (memory_mallopt_mxfast, 2, value, get_max_fast ());
ce426f
+	set_max_fast(value);
ce426f
+      }
ce426f
     else
ce426f
       res = 0;
ce426f
     break;
ce426f
 
ce426f
   case M_TRIM_THRESHOLD:
ce426f
+    LIBC_PROBE (memory_mallopt_trim_threshold, 3, value,
ce426f
+		mp_.trim_threshold, mp_.no_dyn_threshold);
ce426f
     mp_.trim_threshold = value;
ce426f
     mp_.no_dyn_threshold = 1;
ce426f
     break;
ce426f
 
ce426f
   case M_TOP_PAD:
ce426f
+    LIBC_PROBE (memory_mallopt_top_pad, 3, value,
ce426f
+		mp_.top_pad, mp_.no_dyn_threshold);
ce426f
     mp_.top_pad = value;
ce426f
     mp_.no_dyn_threshold = 1;
ce426f
     break;
ce426f
@@ -4720,33 +4743,45 @@ int __libc_mallopt(int param_number, int
ce426f
       res = 0;
ce426f
     else
ce426f
       {
ce426f
+	LIBC_PROBE (memory_mallopt_mmap_threshold, 3, value,
ce426f
+		    mp_.mmap_threshold, mp_.no_dyn_threshold);
ce426f
 	mp_.mmap_threshold = value;
ce426f
 	mp_.no_dyn_threshold = 1;
ce426f
       }
ce426f
     break;
ce426f
 
ce426f
   case M_MMAP_MAX:
ce426f
+    LIBC_PROBE (memory_mallopt_mmap_max, 3, value,
ce426f
+		mp_.n_mmaps_max, mp_.no_dyn_threshold);
ce426f
     mp_.n_mmaps_max = value;
ce426f
     mp_.no_dyn_threshold = 1;
ce426f
     break;
ce426f
 
ce426f
   case M_CHECK_ACTION:
ce426f
+    LIBC_PROBE (memory_mallopt_check_action, 2, value, check_action);
ce426f
     check_action = value;
ce426f
     break;
ce426f
 
ce426f
   case M_PERTURB:
ce426f
+    LIBC_PROBE (memory_mallopt_perturb, 2, value, perturb_byte);
ce426f
     perturb_byte = value;
ce426f
     break;
ce426f
 
ce426f
 #ifdef PER_THREAD
ce426f
   case M_ARENA_TEST:
ce426f
     if (value > 0)
ce426f
-      mp_.arena_test = value;
ce426f
+      {
ce426f
+	LIBC_PROBE (memory_mallopt_arena_test, 2, value, mp_.arena_test);
ce426f
+	mp_.arena_test = value;
ce426f
+      }
ce426f
     break;
ce426f
 
ce426f
   case M_ARENA_MAX:
ce426f
     if (value > 0)
ce426f
-      mp_.arena_max = value;
ce426f
+      {
ce426f
+	LIBC_PROBE (memory_mallopt_arena_max, 2, value, mp_.arena_max);
ce426f
+	mp_.arena_max = value;
ce426f
+      }
ce426f
     break;
ce426f
 #endif
ce426f
   }
ce426f
Index: glibc-2.17-c758a686/manual/Makefile
ce426f
===================================================================
ce426f
--- glibc-2.17-c758a686/manual/Makefile.orig
ce426f
+++ glibc-2.17-c758a686/manual/Makefile
ce426f
@@ -43,7 +43,7 @@ chapters = $(addsuffix .texi, \
ce426f
 		       message search pattern io stdio llio filesys	\
ce426f
 		       pipe socket terminal syslog math arith time	\
ce426f
 		       resource setjmp signal startup process job nss	\
ce426f
-		       users sysinfo conf crypt debug)
ce426f
+		       users sysinfo conf crypt debug probes)
ce426f
 add-chapters = $(wildcard $(foreach d, $(add-ons), ../$d/$d.texi))
ce426f
 appendices = lang.texi header.texi install.texi maint.texi platform.texi \
ce426f
 	     contrib.texi
ce426f
Index: glibc-2.17-c758a686/manual/probes.texi
ce426f
===================================================================
ce426f
--- /dev/null
ce426f
+++ glibc-2.17-c758a686/manual/probes.texi
ce426f
@@ -0,0 +1,257 @@
ce426f
+@node Internal Probes
ce426f
+@c @node Internal Probes, , Debugging Support, Top
ce426f
+@c %MENU% Probes to monitor libc internal behavior
ce426f
+@chapter Internal probes
ce426f
+
ce426f
+In order to aid in debugging and monitoring internal behavior,
ce426f
+@theglibc{} exposes nearly-zero-overhead SystemTap probes marked with
ce426f
+the @code{libc} provider.
ce426f
+
ce426f
+These probes are not part of the @glibcadj{} stable ABI, and they are
ce426f
+subject to change or removal across releases.  Our only promise with
ce426f
+regard to them is that, if we find a need to remove or modify the
ce426f
+arguments of a probe, the modified probe will have a different name, so
ce426f
+that program monitors relying on the old probe will not get unexpected
ce426f
+arguments.
ce426f
+
ce426f
+@menu
ce426f
+* Memory Allocation Probes::  Probes in the memory allocation subsystem
ce426f
+@end menu
ce426f
+
ce426f
+@node Memory Allocation Probes
ce426f
+@section Memory Allocation Probes
ce426f
+
ce426f
+These probes are designed to signal relatively unusual situations within
ce426f
+the virtual memory subsystem of @theglibc{}.  The location and the
ce426f
+availability of some probes depend on whether per-thread arenas are
ce426f
+enabled (the default) or disabled at the time @theglibc{} is compiled.
ce426f
+
ce426f
+@deftp Probe memory_sbrk_more (void *@var{$arg1}, size_t @var{$arg2})
ce426f
+This probe is triggered after the main arena is extended by calling
ce426f
+@code{sbrk}.  Argument @var{$arg1} is the additional size requested to
ce426f
+@code{sbrk}, and @var{$arg2} is the pointer that marks the end of the
ce426f
+@code{sbrk} area, returned in response to the request.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_sbrk_less (void *@var{$arg1}, size_t @var{$arg2})
ce426f
+This probe is triggered after the size of the main arena is decreased by
ce426f
+calling @code{sbrk}.  Argument @var{$arg1} is the size released by
ce426f
+@code{sbrk} (the positive value, rather than the negative value passed
ce426f
+to @code{sbrk}), and @var{$arg2} is the pointer that marks the end of
ce426f
+the @code{sbrk} area, returned in response to the request.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_heap_new (void *@var{$arg1}, size_t @var{$arg2})
ce426f
+This probe is triggered after a new heap is @code{mmap}ed.  Argument
ce426f
+@var{$arg1} is a pointer to the base of the memory area, where the
ce426f
+@code{heap_info} data structure is held, and @var{$arg2} is the size of
ce426f
+the heap.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_heap_free (void *@var{$arg1}, size_t @var{$arg2})
ce426f
+This probe is triggered @emph{before} (unlike the other sbrk and heap
ce426f
+probes) a heap is completely removed via @code{munmap}.  Argument
ce426f
+@var{$arg1} is a pointer to the heap, and @var{$arg2} is the size of the
ce426f
+heap.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_heap_more (void *@var{$arg1}, size_t @var{$arg2})
ce426f
+This probe is triggered after a trailing portion of an @code{mmap}ed
ce426f
+heap is extended.  Argument @var{$arg1} is a pointer to the heap, and
ce426f
+@var{$arg2} is the new size of the heap.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_heap_less (void *@var{$arg1}, size_t @var{$arg2})
ce426f
+This probe is triggered after a trailing portion of an @code{mmap}ed
ce426f
+heap is released.  Argument @var{$arg1} is a pointer to the heap, and
ce426f
+@var{$arg2} is the new size of the heap.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_malloc_retry (size_t @var{$arg1})
ce426f
+@deftpx Probe memory_realloc_retry (size_t @var{$arg1}, void *@var{$arg2})
ce426f
+@deftpx Probe memory_memalign_retry (size_t @var{$arg1}, size_t @var{$arg2})
ce426f
+@deftpx Probe memory_valloc_retry (size_t @var{$arg1})
ce426f
+@deftpx Probe memory_pvalloc_retry (size_t @var{$arg1})
ce426f
+@deftpx Probe memory_calloc_retry (size_t @var{$arg1})
ce426f
+These probes are triggered when the corresponding functions fail to
ce426f
+obtain the requested amount of memory from the arena in use, before they
ce426f
+call @code{arena_get_retry} to select an alternate arena in which to
ce426f
+retry the allocation.  Argument @var{$arg1} is the amount of memory
ce426f
+requested by the user; in the @code{calloc} case, that is the total size
ce426f
+computed from both function arguments.  In the @code{realloc} case,
ce426f
+@var{$arg2} is the pointer to the memory area being resized.  In the
ce426f
+@code{memalign} case, @var{$arg2} is the alignment to be used for the
ce426f
+request, which may be stricter than the value passed to the
ce426f
+@code{memalign} function.
ce426f
+
ce426f
+Note that the argument order does @emph{not} match that of the
ce426f
+corresponding two-argument functions, so that in all of these probes the
ce426f
+user-requested allocation size is in @var{$arg1}.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_arena_retry (size_t @var{$arg1}, void *@var{$arg2})
ce426f
+This probe is triggered within @code{arena_get_retry} (the function
ce426f
+called to select the alternate arena in which to retry an allocation
ce426f
+that failed on the first attempt), before the selection of an alternate
ce426f
+arena.  This probe is redundant, but much easier to use when it's not
ce426f
+important to determine which of the various memory allocation functions
ce426f
+is failing to allocate on the first try.  Argument @var{$arg1} is the
ce426f
+same as in the function-specific probes, except for extra room for
ce426f
+padding introduced by functions that have to ensure stricter alignment.
ce426f
+Argument @var{$arg2} is the arena in which allocation failed.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_arena_new (void *@var{$arg1}, size_t @var{$arg2})
ce426f
+This probe is triggered when @code{malloc} allocates and initializes an
ce426f
+additional arena (not the main arena), but before the arena is assigned
ce426f
+to the running thread or inserted into the internal linked list of
ce426f
+arenas.  The arena's @code{malloc_state} internal data structure is
ce426f
+located at @var{$arg1}, within a newly-allocated heap big enough to hold
ce426f
+at least @var{$arg2} bytes.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_arena_reuse (void *@var{$arg1}, void *@var{$arg2})
ce426f
+This probe is triggered when @code{malloc} has just selected an existing
ce426f
+arena to reuse, and (temporarily) reserved it for exclusive use.
ce426f
+Argument @var{$arg1} is a pointer to the newly-selected arena, and
ce426f
+@var{$arg2} is a pointer to the arena previously used by that thread.
ce426f
+
ce426f
+When per-thread arenas are enabled, this occurs within
ce426f
+@code{reused_arena}, right after the mutex mentioned in probe
ce426f
+@code{memory_arena_reuse_wait} is acquired; argument @var{$arg1} will
ce426f
+point to the same arena.  In this configuration, this will usually only
ce426f
+occur once per thread.  The exception is when a thread first selected
ce426f
+the main arena, but a subsequent allocation from it fails: then, and
ce426f
+only then, may we switch to another arena to retry that allocations, and
ce426f
+for further allocations within that thread.
ce426f
+
ce426f
+When per-thread arenas are disabled, this occurs within
ce426f
+@code{arena_get2}, whenever the mutex for the previously-selected arena
ce426f
+cannot be immediately acquired.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_arena_reuse_wait (void *@var{$arg1}, void *@var{$arg2}, void *@var{$arg3})
ce426f
+This probe is triggered when @code{malloc} is about to wait for an arena
ce426f
+to become available for reuse.  Argument @var{$arg1} holds a pointer to
ce426f
+the mutex the thread is going to wait on, @var{$arg2} is a pointer to a
ce426f
+newly-chosen arena to be reused, and @var{$arg3} is a pointer to the
ce426f
+arena previously used by that thread.
ce426f
+
ce426f
+When per-thread arenas are enabled, this occurs within
ce426f
+@code{reused_arena}, when a thread first tries to allocate memory or
ce426f
+needs a retry after a failure to allocate from the main arena, there
ce426f
+isn't any free arena, the maximum number of arenas has been reached, and
ce426f
+an existing arena was chosen for reuse, but its mutex could not be
ce426f
+immediately acquired.  The mutex in @var{$arg1} is the mutex of the
ce426f
+selected arena.
ce426f
+
ce426f
+When per-thread arenas are disabled, this occurs within
ce426f
+@code{arena_get2}, when a thread first tries to allocate memory or the
ce426f
+mutex of the arena it previously used could not be immediately acquired,
ce426f
+and none of the existing arenas could be immediately reserved for
ce426f
+exclusive use.  The mutex in @var{$arg1} is that of the list of arenas,
ce426f
+and since the arena won't have been selected yet, @var{$arg2} will be
ce426f
+@code{NULL}.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_arena_reuse_free_list (void *@var{$arg1})
ce426f
+This probe is triggered when @code{malloc} has chosen an arena that is
ce426f
+in the free list for use by a thread, within the @code{get_free_list}
ce426f
+function.  This probe is only available when @code{malloc} is configured
ce426f
+to use per-thread arenas.  The argument @var{$arg1} holds a pointer to
ce426f
+the selected arena.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_arena_reuse_realloc (void *@var{$arg1})
ce426f
+This probe is triggered within @code{realloc}, as the arena of the
ce426f
+current thread is changed to match that in which the given address was
ce426f
+allocated.  This probe is @emph{not} available when @code{malloc} is
ce426f
+configured to use per-thread arenas.  The argument @var{$arg1} holds a
ce426f
+pointer to the newly-selected arena.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_mallopt (int @var{$arg1}, int @var{$arg2})
ce426f
+This probe is triggered when function @code{mallopt} is called to change
ce426f
+@code{malloc} internal configuration parameters, before any change to
ce426f
+the parameters is made.  The arguments @var{$arg1} and @var{$arg2} are
ce426f
+the ones passed to the @code{mallopt} function.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_mallopt_mxfast (int @var{$arg1}, int @var{$arg2})
ce426f
+This probe is triggered shortly after the @code{memory_mallopt} probe,
ce426f
+when the parameter to be changed is @code{M_MXFAST}, and the requested
ce426f
+value is in an acceptable range.  Argument @var{$arg1} is the requested
ce426f
+value, and @var{$arg2} is the previous value of this @code{malloc}
ce426f
+parameter.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_mallopt_trim_threshold (int @var{$arg1}, int @var{$arg2}, int @var{$arg3})
ce426f
+This probe is triggere shortly after the @code{memory_mallopt} probe,
ce426f
+when the parameter to be changed is @code{M_TRIM_THRESHOLD}.  Argument
ce426f
+@var{$arg1} is the requested value, @var{$arg2} is the previous value of
ce426f
+this @code{malloc} parameter, and @var{$arg3} is nonzero if dynamic
ce426f
+threshold adjustment was already disabled.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_mallopt_top_pad (int @var{$arg1}, int @var{$arg2}, int @var{$arg3})
ce426f
+This probe is triggered shortly after the @code{memory_mallopt} probe,
ce426f
+when the parameter to be changed is @code{M_TOP_PAD}.  Argument
ce426f
+@var{$arg1} is the requested value, @var{$arg2} is the previous value of
ce426f
+this @code{malloc} parameter, and @var{$arg3} is nonzero if dynamic
ce426f
+threshold adjustment was already disabled.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_mallopt_mmap_threshold (int @var{$arg1}, int @var{$arg2}, int @var{$arg3})
ce426f
+This probe is triggered shortly after the @code{memory_mallopt} probe,
ce426f
+when the parameter to be changed is @code{M_MMAP_THRESHOLD}, and the
ce426f
+requested value is in an acceptable range.  Argument @var{$arg1} is the
ce426f
+requested value, @var{$arg2} is the previous value of this @code{malloc}
ce426f
+parameter, and @var{$arg3} is nonzero if dynamic threshold adjustment
ce426f
+was already disabled.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_mallopt_mmap_max (int @var{$arg1}, int @var{$arg2}, int @var{$arg3})
ce426f
+This probe is triggered shortly after the @code{memory_mallopt} probe,
ce426f
+when the parameter to be changed is @code{M_MMAP_MAX}.  Argument
ce426f
+@var{$arg1} is the requested value, @var{$arg2} is the previous value of
ce426f
+this @code{malloc} parameter, and @var{$arg3} is nonzero if dynamic
ce426f
+threshold adjustment was already disabled.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_mallopt_check_action (int @var{$arg1}, int @var{$arg2})
ce426f
+This probe is triggered shortly after the @code{memory_mallopt} probe,
ce426f
+when the parameter to be changed is @code{M_CHECK_ACTION}.  Argument
ce426f
+@var{$arg1} is the requested value, and @var{$arg2} is the previous
ce426f
+value of this @code{malloc} parameter.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_mallopt_perturb (int @var{$arg1}, int @var{$arg2})
ce426f
+This probe is triggered shortly after the @code{memory_mallopt} probe,
ce426f
+when the parameter to be changed is @code{M_PERTURB}.  Argument
ce426f
+@var{$arg1} is the requested value, and @var{$arg2} is the previous
ce426f
+value of this @code{malloc} parameter.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_mallopt_arena_test (int @var{$arg1}, int @var{$arg2})
ce426f
+This probe is triggered shortly after the @code{memory_mallopt} probe,
ce426f
+when the parameter to be changed is @code{M_ARENA_TEST}, and the
ce426f
+requested value is in an acceptable range.  Argument @var{$arg1} is the
ce426f
+requested value, and @var{$arg2} is the previous value of this
ce426f
+@code{malloc} parameter.  This probe is only available when per-thread
ce426f
+arenas are enabled.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_mallopt_arena_max (int @var{$arg1}, int @var{$arg2})
ce426f
+This probe is triggered shortly after the @code{memory_mallopt} probe,
ce426f
+when the parameter to be changed is @code{M_ARENA_MAX}, and the
ce426f
+requested value is in an acceptable range.  Argument @var{$arg1} is the
ce426f
+requested value, and @var{$arg2} is the previous value of this
ce426f
+@code{malloc} parameter.  This probe is only available when per-thread
ce426f
+arenas are enabled.
ce426f
+@end deftp
ce426f
+
ce426f
+@deftp Probe memory_mallopt_free_dyn_thresholds (int @var{$arg1}, int @var{$arg2})
ce426f
+This probe is triggered when function @code{free} decides to adjust the
ce426f
+dynamic brk/mmap thresholds.  Argument @var{$arg1} and @var{$arg2} are
ce426f
+the adjusted mmap and trim thresholds, respectively.
ce426f
+@end deftp
ce426f
Index: glibc-2.17-c758a686/manual/debug.texi
ce426f
===================================================================
ce426f
--- glibc-2.17-c758a686/manual/debug.texi.orig
ce426f
+++ glibc-2.17-c758a686/manual/debug.texi
ce426f
@@ -1,5 +1,5 @@
ce426f
 @node Debugging Support
ce426f
-@c @node Debugging Support, , Cryptographic Functions, Top
ce426f
+@c @node Debugging Support, Internal Probes, Cryptographic Functions, Top
ce426f
 @c %MENU% Functions to help debugging applications
ce426f
 @chapter Debugging support
ce426f