about summary refs log tree commit diff
path: root/malloc/malloc.c
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2013-09-20 11:10:55 -0300
committerAlexandre Oliva <aoliva@redhat.com>2013-09-20 11:50:08 -0300
commit35fed6f15d3d29c02203a3fe2e446e205d45b0ff (patch)
tree22861471442264b51f40c4619169ad13ad269426 /malloc/malloc.c
parent6999d38c953e568f0488572c0a68cba32286a2c3 (diff)
downloadglibc-35fed6f15d3d29c02203a3fe2e446e205d45b0ff.tar.gz
glibc-35fed6f15d3d29c02203a3fe2e446e205d45b0ff.tar.xz
glibc-35fed6f15d3d29c02203a3fe2e446e205d45b0ff.zip
Add probes for malloc retries.
for ChangeLog

	* malloc/malloc.c (__libc_malloc): Add memory_malloc_retry probe.
	(__libc_realloc): Add memory_realloc_retry probe.
	(__libc_memalign): Add memory_memalign_retry probe.
	(__libc_valloc): Add memory_valloc_retry probe.
	(__libc_pvalloc): Add memory_pvalloc_retry probe.
	(__libc_calloc): Add memory_calloc_retry probe.
	* manual/probes.texi: Document them.
Diffstat (limited to 'malloc/malloc.c')
-rw-r--r--malloc/malloc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index c5b3c7cae8..5b4fcff70e 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -2856,6 +2856,7 @@ __libc_malloc(size_t bytes)
     return 0;
   victim = _int_malloc(ar_ptr, bytes);
   if(!victim) {
+    LIBC_PROBE (memory_malloc_retry, 1, bytes);
     ar_ptr = arena_get_retry(ar_ptr, bytes);
     if (__builtin_expect(ar_ptr != NULL, 1)) {
       victim = _int_malloc(ar_ptr, bytes);
@@ -2991,6 +2992,7 @@ __libc_realloc(void* oldmem, size_t bytes)
   if (newp == NULL)
     {
       /* Try harder to allocate memory in other arenas.  */
+      LIBC_PROBE (memory_realloc_retry, 2, bytes, oldmem);
       newp = __libc_malloc(bytes);
       if (newp != NULL)
 	{
@@ -3032,6 +3034,7 @@ __libc_memalign(size_t alignment, size_t bytes)
     return 0;
   p = _int_memalign(ar_ptr, alignment, bytes);
   if(!p) {
+    LIBC_PROBE (memory_memalign_retry, 2, bytes, alignment);
     ar_ptr = arena_get_retry (ar_ptr, bytes);
     if (__builtin_expect(ar_ptr != NULL, 1)) {
       p = _int_memalign(ar_ptr, alignment, bytes);
@@ -3075,6 +3078,7 @@ __libc_valloc(size_t bytes)
     return 0;
   p = _int_valloc(ar_ptr, bytes);
   if(!p) {
+    LIBC_PROBE (memory_valloc_retry, 1, bytes);
     ar_ptr = arena_get_retry (ar_ptr, bytes);
     if (__builtin_expect(ar_ptr != NULL, 1)) {
       p = _int_memalign(ar_ptr, pagesz, bytes);
@@ -3116,6 +3120,7 @@ __libc_pvalloc(size_t bytes)
   arena_get(ar_ptr, bytes + 2*pagesz + MINSIZE);
   p = _int_pvalloc(ar_ptr, bytes);
   if(!p) {
+    LIBC_PROBE (memory_pvalloc_retry, 1, bytes);
     ar_ptr = arena_get_retry (ar_ptr, bytes + 2*pagesz + MINSIZE);
     if (__builtin_expect(ar_ptr != NULL, 1)) {
       p = _int_memalign(ar_ptr, pagesz, rounded_bytes);
@@ -3192,6 +3197,7 @@ __libc_calloc(size_t n, size_t elem_size)
 	 av == arena_for_chunk(mem2chunk(mem)));
 
   if (mem == 0) {
+    LIBC_PROBE (memory_calloc_retry, 1, sz);
     av = arena_get_retry (av, sz);
     if (__builtin_expect(av != NULL, 1)) {
       mem = _int_malloc(av, sz);