c6d234
commit bdfe308a166b433a841d5c9ae256560c18bce640
c6d234
Author: Ondřej Bílka <neleai@seznam.cz>
c6d234
Date:   Mon Feb 10 12:25:04 2014 +0100
c6d234
c6d234
    Remove THREAD_STATS.
c6d234
    
c6d234
    A THREAD_STATS macro duplicates gathering information that could be
c6d234
    obtained by systemtap probes instead.
c6d234
c6d234
Conflicts:
c6d234
	malloc/arena.c
c6d234
	malloc/malloc.c
c6d234
c6d234
Textual conflicts due to independent malloc backports.
c6d234
c6d234
diff --git a/malloc/arena.c b/malloc/arena.c
c6d234
index f5e97fadc17ad92d..fe4ec8de614454c9 100644
c6d234
--- a/malloc/arena.c
c6d234
+++ b/malloc/arena.c
c6d234
@@ -40,14 +40,6 @@
c6d234
    mmap threshold, so that requests with a size just below that
c6d234
    threshold can be fulfilled without creating too many heaps.  */
c6d234
 
c6d234
-
c6d234
-#ifndef THREAD_STATS
c6d234
-#define THREAD_STATS 0
c6d234
-#endif
c6d234
-
c6d234
-/* If THREAD_STATS is non-zero, some statistics on mutex locking are
c6d234
-   computed.  */
c6d234
-
c6d234
 /***************************************************************************/
c6d234
 
c6d234
 #define top(ar_ptr) ((ar_ptr)->top)
c6d234
@@ -101,13 +93,6 @@ static mstate free_list;
c6d234
    acquired.  */
c6d234
 static mutex_t list_lock = MUTEX_INITIALIZER;
c6d234
 
c6d234
-#if THREAD_STATS
c6d234
-static int stat_n_heaps;
c6d234
-#define THREAD_STAT(x) x
c6d234
-#else
c6d234
-#define THREAD_STAT(x) do ; while(0)
c6d234
-#endif
c6d234
-
c6d234
 /* Mapped memory in non-main arenas (reliable only for NO_THREADS). */
c6d234
 static unsigned long arena_mem;
c6d234
 
c6d234
@@ -583,7 +568,6 @@ new_heap(size_t size, size_t top_pad)
c6d234
   h = (heap_info *)p2;
c6d234
   h->size = size;
c6d234
   h->mprotect_size = size;
c6d234
-  THREAD_STAT(stat_n_heaps++);
c6d234
   LIBC_PROBE (memory_heap_new, 2, h, h->size);
c6d234
   return h;
c6d234
 }
c6d234
@@ -811,8 +795,6 @@ _int_new_arena(size_t size)
c6d234
 
c6d234
   (void) mutex_lock (&a->mutex);
c6d234
 
c6d234
-  THREAD_STAT(++(a->stat_lock_loop));
c6d234
-
c6d234
   return a;
c6d234
 }
c6d234
 
c6d234
@@ -844,7 +826,6 @@ get_free_list (void)
c6d234
 	  LIBC_PROBE (memory_arena_reuse_free_list, 1, result);
c6d234
 	  (void)mutex_lock(&result->mutex);
c6d234
 	  tsd_setspecific(arena_key, (void *)result);
c6d234
-	  THREAD_STAT(++(result->stat_lock_loop));
c6d234
 	}
c6d234
     }
c6d234
 
c6d234
@@ -941,7 +922,6 @@ reused_arena (mstate avoid_arena)
c6d234
   }
c6d234
   LIBC_PROBE (memory_arena_reuse, 2, result, avoid_arena);
c6d234
   tsd_setspecific(arena_key, (void *)result);
c6d234
-  THREAD_STAT(++(result->stat_lock_loop));
c6d234
   next_to_use = result->next;
c6d234
 
c6d234
   return result;
c6d234
diff --git a/malloc/malloc.c b/malloc/malloc.c
c6d234
index fc86b344ee3b3a7c..9d3b24ee0c137a1b 100644
c6d234
--- a/malloc/malloc.c
c6d234
+++ b/malloc/malloc.c
c6d234
@@ -1712,11 +1712,6 @@ struct malloc_state {
c6d234
   /* Flags (formerly in max_fast).  */
c6d234
   int flags;
c6d234
 
c6d234
-#if THREAD_STATS
c6d234
-  /* Statistics for locking.  Only used if THREAD_STATS is defined.  */
c6d234
-  long stat_lock_direct, stat_lock_loop, stat_lock_wait;
c6d234
-#endif
c6d234
-
c6d234
   /* Fastbins */
c6d234
   mfastbinptr      fastbinsY[NFASTBINS];
c6d234
 
c6d234
@@ -3015,17 +3010,7 @@ __libc_realloc(void* oldmem, size_t bytes)
c6d234
     return newmem;
c6d234
   }
c6d234
 
c6d234
-#if THREAD_STATS
c6d234
-  if(!mutex_trylock(&ar_ptr->mutex))
c6d234
-    ++(ar_ptr->stat_lock_direct);
c6d234
-  else {
c6d234
-    (void)mutex_lock(&ar_ptr->mutex);
c6d234
-    ++(ar_ptr->stat_lock_wait);
c6d234
-  }
c6d234
-#else
c6d234
   (void)mutex_lock(&ar_ptr->mutex);
c6d234
-#endif
c6d234
-
c6d234
 
c6d234
   newp = _int_realloc(ar_ptr, oldp, oldsize, nb);
c6d234
 
c6d234
@@ -3941,16 +3926,7 @@ _int_free(mstate av, mchunkptr p, int have_lock)
c6d234
 
c6d234
   else if (!chunk_is_mmapped(p)) {
c6d234
     if (! have_lock) {
c6d234
-#if THREAD_STATS
c6d234
-      if(!mutex_trylock(&av->mutex))
c6d234
-	++(av->stat_lock_direct);
c6d234
-      else {
c6d234
-	(void)mutex_lock(&av->mutex);
c6d234
-	++(av->stat_lock_wait);
c6d234
-      }
c6d234
-#else
c6d234
       (void)mutex_lock(&av->mutex);
c6d234
-#endif
c6d234
       locked = 1;
c6d234
     }
c6d234
 
c6d234
@@ -4713,9 +4689,6 @@ __malloc_stats (void)
c6d234
   int i;
c6d234
   mstate ar_ptr;
c6d234
   unsigned int in_use_b = mp_.mmapped_mem, system_b = in_use_b;
c6d234
-#if THREAD_STATS
c6d234
-  long stat_lock_direct = 0, stat_lock_loop = 0, stat_lock_wait = 0;
c6d234
-#endif
c6d234
 
c6d234
   if(__malloc_initialized < 0)
c6d234
     ptmalloc_init ();
c6d234
@@ -4737,11 +4710,6 @@ __malloc_stats (void)
c6d234
 #endif
c6d234
     system_b += mi.arena;
c6d234
     in_use_b += mi.uordblks;
c6d234
-#if THREAD_STATS
c6d234
-    stat_lock_direct += ar_ptr->stat_lock_direct;
c6d234
-    stat_lock_loop += ar_ptr->stat_lock_loop;
c6d234
-    stat_lock_wait += ar_ptr->stat_lock_wait;
c6d234
-#endif
c6d234
     (void)mutex_unlock(&ar_ptr->mutex);
c6d234
     ar_ptr = ar_ptr->next;
c6d234
     if(ar_ptr == &main_arena) break;
c6d234
@@ -4752,14 +4720,6 @@ __malloc_stats (void)
c6d234
   fprintf(stderr, "max mmap regions = %10u\n", (unsigned int)mp_.max_n_mmaps);
c6d234
   fprintf(stderr, "max mmap bytes   = %10lu\n",
c6d234
 	  (unsigned long)mp_.max_mmapped_mem);
c6d234
-#if THREAD_STATS
c6d234
-  fprintf(stderr, "heaps created    = %10d\n",  stat_n_heaps);
c6d234
-  fprintf(stderr, "locked directly  = %10ld\n", stat_lock_direct);
c6d234
-  fprintf(stderr, "locked in loop   = %10ld\n", stat_lock_loop);
c6d234
-  fprintf(stderr, "locked waiting   = %10ld\n", stat_lock_wait);
c6d234
-  fprintf(stderr, "locked total     = %10ld\n",
c6d234
-	  stat_lock_direct + stat_lock_loop + stat_lock_wait);
c6d234
-#endif
c6d234
   ((_IO_FILE *) stderr)->_flags2 |= old_flags2;
c6d234
   _IO_funlockfile (stderr);
c6d234
 }