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