1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

Remove THREAD_STATS.

A THREAD_STATS macro duplicates gathering information that could be
obtained by systemtap probes instead.
This commit is contained in:
Ondřej Bílka
2014-02-10 12:25:04 +01:00
parent d674667cba
commit bdfe308a16
3 changed files with 7 additions and 60 deletions

View File

@ -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> 2014-02-08 Mike Frysinger <vapier@gentoo.org>
* sysdeps/unix/sysv/linux/shm_open.c (where_is_shmfs): Compare * sysdeps/unix/sysv/linux/shm_open.c (where_is_shmfs): Compare

View File

@ -37,14 +37,6 @@
mmap threshold, so that requests with a size just below that mmap threshold, so that requests with a size just below that
threshold can be fulfilled without creating too many heaps. */ 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) #define top(ar_ptr) ((ar_ptr)->top)
@ -79,13 +71,6 @@ static mutex_t list_lock = MUTEX_INITIALIZER;
static size_t narenas = 1; static size_t narenas = 1;
static mstate free_list; 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). */ /* Mapped memory in non-main arenas (reliable only for NO_THREADS). */
static unsigned long arena_mem; static unsigned long arena_mem;
@ -593,7 +578,6 @@ new_heap (size_t size, size_t top_pad)
h = (heap_info *) p2; h = (heap_info *) p2;
h->size = size; h->size = size;
h->mprotect_size = size; h->mprotect_size = size;
THREAD_STAT (stat_n_heaps++);
LIBC_PROBE (memory_heap_new, 2, h, h->size); LIBC_PROBE (memory_heap_new, 2, h, h->size);
return h; return h;
} }
@ -777,8 +761,6 @@ _int_new_arena (size_t size)
(void) mutex_unlock (&list_lock); (void) mutex_unlock (&list_lock);
THREAD_STAT (++(a->stat_lock_loop));
return a; return a;
} }
@ -800,7 +782,6 @@ get_free_list (void)
LIBC_PROBE (memory_arena_reuse_free_list, 1, result); LIBC_PROBE (memory_arena_reuse_free_list, 1, result);
(void) mutex_lock (&result->mutex); (void) mutex_lock (&result->mutex);
tsd_setspecific (arena_key, (void *) result); tsd_setspecific (arena_key, (void *) result);
THREAD_STAT (++(result->stat_lock_loop));
} }
} }
@ -840,7 +821,6 @@ reused_arena (mstate avoid_arena)
out: out:
LIBC_PROBE (memory_arena_reuse, 2, result, avoid_arena); LIBC_PROBE (memory_arena_reuse, 2, result, avoid_arena);
tsd_setspecific (arena_key, (void *) result); tsd_setspecific (arena_key, (void *) result);
THREAD_STAT (++(result->stat_lock_loop));
next_to_use = result->next; next_to_use = result->next;
return result; return result;

View File

@ -1672,11 +1672,6 @@ struct malloc_state
/* Flags (formerly in max_fast). */ /* Flags (formerly in max_fast). */
int flags; 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 */ /* Fastbins */
mfastbinptr fastbinsY[NFASTBINS]; mfastbinptr fastbinsY[NFASTBINS];
@ -3010,17 +3005,7 @@ __libc_realloc (void *oldmem, size_t bytes)
} }
ar_ptr = arena_for_chunk (oldp); 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); (void) mutex_lock (&ar_ptr->mutex);
#endif
newp = _int_realloc (ar_ptr, oldp, oldsize, nb); 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)) { else if (!chunk_is_mmapped(p)) {
if (! have_lock) { 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); (void)mutex_lock(&av->mutex);
#endif
locked = 1; locked = 1;
} }
@ -4681,9 +4657,6 @@ __malloc_stats (void)
int i; int i;
mstate ar_ptr; mstate ar_ptr;
unsigned int in_use_b = mp_.mmapped_mem, system_b = in_use_b; 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) if (__malloc_initialized < 0)
ptmalloc_init (); ptmalloc_init ();
@ -4706,11 +4679,6 @@ __malloc_stats (void)
#endif #endif
system_b += mi.arena; system_b += mi.arena;
in_use_b += mi.uordblks; 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); (void) mutex_unlock (&ar_ptr->mutex);
ar_ptr = ar_ptr->next; ar_ptr = ar_ptr->next;
if (ar_ptr == &main_arena) 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 regions = %10u\n", (unsigned int) mp_.max_n_mmaps);
fprintf (stderr, "max mmap bytes = %10lu\n", fprintf (stderr, "max mmap bytes = %10lu\n",
(unsigned long) mp_.max_mmapped_mem); (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_FILE *) stderr)->_flags2 |= old_flags2;
_IO_funlockfile (stderr); _IO_funlockfile (stderr);
} }