arrfab / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh742038.patch

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