arrfab / rpms / glibc

Forked from rpms/glibc 4 years ago
Clone

Blame SOURCES/glibc-rh1505492-undef-5.patch

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