about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOndřej Bílka <neleai@seznam.cz>2014-02-10 12:25:04 +0100
committerOndřej Bílka <neleai@seznam.cz>2014-02-10 12:25:04 +0100
commitbdfe308a166b433a841d5c9ae256560c18bce640 (patch)
treeaf44bb0ab52aee61a9f067f193817f1807d369c7
parentd674667cbaa84ff4cf82cfedacad0665ae6cb440 (diff)
downloadglibc-bdfe308a166b433a841d5c9ae256560c18bce640.tar.gz
glibc-bdfe308a166b433a841d5c9ae256560c18bce640.tar.xz
glibc-bdfe308a166b433a841d5c9ae256560c18bce640.zip
Remove THREAD_STATS.
A THREAD_STATS macro duplicates gathering information that could be
obtained by systemtap probes instead.
-rw-r--r--ChangeLog7
-rw-r--r--malloc/arena.c20
-rw-r--r--malloc/malloc.c40
3 files changed, 7 insertions, 60 deletions
diff --git a/ChangeLog b/ChangeLog
index 34b2edfb64..bded2c3a39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2014-02-10  Ondřej Bílka  <neleai@seznam.cz>
+
+	* malloc/arena.c (grow_heap, get_free_list, reused_arena,
+	arena_get2): Remove THREAD_STATS conditionals.
+	* malloc/malloc.c (__malloc_assert, __libc_realloc, _int_free,
+	__malloc_stats, int): Likewise.
+
 2014-02-08  Mike Frysinger  <vapier@gentoo.org>
 
 	* sysdeps/unix/sysv/linux/shm_open.c (where_is_shmfs): Compare
diff --git a/malloc/arena.c b/malloc/arena.c
index 5088a253ec..71678a9dc4 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -37,14 +37,6 @@
    mmap threshold, so that requests with a size just below that
    threshold can be fulfilled without creating too many heaps.  */
 
-
-#ifndef THREAD_STATS
-# define THREAD_STATS 0
-#endif
-
-/* If THREAD_STATS is non-zero, some statistics on mutex locking are
-   computed.  */
-
 /***************************************************************************/
 
 #define top(ar_ptr) ((ar_ptr)->top)
@@ -79,13 +71,6 @@ static mutex_t list_lock = MUTEX_INITIALIZER;
 static size_t narenas = 1;
 static mstate free_list;
 
-#if THREAD_STATS
-static int stat_n_heaps;
-# define THREAD_STAT(x) x
-#else
-# define THREAD_STAT(x) do ; while (0)
-#endif
-
 /* Mapped memory in non-main arenas (reliable only for NO_THREADS). */
 static unsigned long arena_mem;
 
@@ -593,7 +578,6 @@ new_heap (size_t size, size_t top_pad)
   h = (heap_info *) p2;
   h->size = size;
   h->mprotect_size = size;
-  THREAD_STAT (stat_n_heaps++);
   LIBC_PROBE (memory_heap_new, 2, h, h->size);
   return h;
 }
@@ -777,8 +761,6 @@ _int_new_arena (size_t size)
 
   (void) mutex_unlock (&list_lock);
 
-  THREAD_STAT (++(a->stat_lock_loop));
-
   return a;
 }
 
@@ -800,7 +782,6 @@ get_free_list (void)
           LIBC_PROBE (memory_arena_reuse_free_list, 1, result);
           (void) mutex_lock (&result->mutex);
           tsd_setspecific (arena_key, (void *) result);
-          THREAD_STAT (++(result->stat_lock_loop));
         }
     }
 
@@ -840,7 +821,6 @@ reused_arena (mstate avoid_arena)
 out:
   LIBC_PROBE (memory_arena_reuse, 2, result, avoid_arena);
   tsd_setspecific (arena_key, (void *) result);
-  THREAD_STAT (++(result->stat_lock_loop));
   next_to_use = result->next;
 
   return result;
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 813e94eea3..4f209995ad 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1672,11 +1672,6 @@ struct malloc_state
   /* Flags (formerly in max_fast).  */
   int flags;
 
-#if THREAD_STATS
-  /* Statistics for locking.  Only used if THREAD_STATS is defined.  */
-  long stat_lock_direct, stat_lock_loop, stat_lock_wait;
-#endif
-
   /* Fastbins */
   mfastbinptr fastbinsY[NFASTBINS];
 
@@ -3010,17 +3005,7 @@ __libc_realloc (void *oldmem, size_t bytes)
     }
 
   ar_ptr = arena_for_chunk (oldp);
-#if THREAD_STATS
-  if (!mutex_trylock (&ar_ptr->mutex))
-    ++(ar_ptr->stat_lock_direct);
-  else
-    {
-      (void) mutex_lock (&ar_ptr->mutex);
-      ++(ar_ptr->stat_lock_wait);
-    }
-#else
   (void) mutex_lock (&ar_ptr->mutex);
-#endif
 
 
   newp = _int_realloc (ar_ptr, oldp, oldsize, nb);
@@ -3929,16 +3914,7 @@ _int_free (mstate av, mchunkptr p, int have_lock)
 
   else if (!chunk_is_mmapped(p)) {
     if (! have_lock) {
-#if THREAD_STATS
-      if(!mutex_trylock(&av->mutex))
-	++(av->stat_lock_direct);
-      else {
-	(void)mutex_lock(&av->mutex);
-	++(av->stat_lock_wait);
-      }
-#else
       (void)mutex_lock(&av->mutex);
-#endif
       locked = 1;
     }
 
@@ -4681,9 +4657,6 @@ __malloc_stats (void)
   int i;
   mstate ar_ptr;
   unsigned int in_use_b = mp_.mmapped_mem, system_b = in_use_b;
-#if THREAD_STATS
-  long stat_lock_direct = 0, stat_lock_loop = 0, stat_lock_wait = 0;
-#endif
 
   if (__malloc_initialized < 0)
     ptmalloc_init ();
@@ -4706,11 +4679,6 @@ __malloc_stats (void)
 #endif
       system_b += mi.arena;
       in_use_b += mi.uordblks;
-#if THREAD_STATS
-      stat_lock_direct += ar_ptr->stat_lock_direct;
-      stat_lock_loop += ar_ptr->stat_lock_loop;
-      stat_lock_wait += ar_ptr->stat_lock_wait;
-#endif
       (void) mutex_unlock (&ar_ptr->mutex);
       ar_ptr = ar_ptr->next;
       if (ar_ptr == &main_arena)
@@ -4722,14 +4690,6 @@ __malloc_stats (void)
   fprintf (stderr, "max mmap regions = %10u\n", (unsigned int) mp_.max_n_mmaps);
   fprintf (stderr, "max mmap bytes   = %10lu\n",
            (unsigned long) mp_.max_mmapped_mem);
-#if THREAD_STATS
-  fprintf (stderr, "heaps created    = %10d\n", stat_n_heaps);
-  fprintf (stderr, "locked directly  = %10ld\n", stat_lock_direct);
-  fprintf (stderr, "locked in loop   = %10ld\n", stat_lock_loop);
-  fprintf (stderr, "locked waiting   = %10ld\n", stat_lock_wait);
-  fprintf (stderr, "locked total     = %10ld\n",
-           stat_lock_direct + stat_lock_loop + stat_lock_wait);
-#endif
   ((_IO_FILE *) stderr)->_flags2 |= old_flags2;
   _IO_funlockfile (stderr);
 }