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