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