Skip to content

Commit

Permalink
malloc: Remove arena_mem variable
Browse files Browse the repository at this point in the history
The computed value is never used.  The accesses were data races.
  • Loading branch information
Florian Weimer committed Feb 19, 2016
1 parent aff8c7a commit 00d4e2e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2016-02-19 Florian Weimer <fweimer@redhat.com>

* malloc/malloc.c (sysmalloc): Do not update arena_max.
* malloc/arena.c (arena_max): Remove.
(heap_trim, _int_new_arena): Do not update arena_max.

2016-02-19 Florian Weimer <fweimer@redhat.com>

* resolv/res_init.c (res_ninit): Update comment.
Expand Down
6 changes: 0 additions & 6 deletions malloc/arena.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ static mstate free_list;
acquired. */
static mutex_t list_lock = _LIBC_LOCK_INITIALIZER;

/* Mapped memory in non-main arenas (reliable only for NO_THREADS). */
static unsigned long arena_mem;

/* Already initialized? */
int __malloc_initialized = -1;

Expand Down Expand Up @@ -705,7 +702,6 @@ heap_trim (heap_info *heap, size_t pad)
if (new_size + (HEAP_MAX_SIZE - prev_heap->size) < pad + MINSIZE + pagesz)
break;
ar_ptr->system_mem -= heap->size;
arena_mem -= heap->size;
LIBC_PROBE (memory_heap_free, 2, heap, heap->size);
delete_heap (heap);
heap = prev_heap;
Expand Down Expand Up @@ -743,7 +739,6 @@ heap_trim (heap_info *heap, size_t pad)
return 0;

ar_ptr->system_mem -= extra;
arena_mem -= extra;

/* Success. Adjust top accordingly. */
set_head (top_chunk, (top_size - extra) | PREV_INUSE);
Expand Down Expand Up @@ -793,7 +788,6 @@ _int_new_arena (size_t size)
a->attached_threads = 1;
/*a->next = NULL;*/
a->system_mem = a->max_system_mem = h->size;
arena_mem += h->size;

/* Set up the top chunk, with proper alignment. */
ptr = (char *) (a + 1);
Expand Down
2 changes: 0 additions & 2 deletions malloc/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2410,7 +2410,6 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av)
&& grow_heap (old_heap, MINSIZE + nb - old_size) == 0)
{
av->system_mem += old_heap->size - old_heap_size;
arena_mem += old_heap->size - old_heap_size;
set_head (old_top, (((char *) old_heap + old_heap->size) - (char *) old_top)
| PREV_INUSE);
}
Expand All @@ -2420,7 +2419,6 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av)
heap->ar_ptr = av;
heap->prev = old_heap;
av->system_mem += heap->size;
arena_mem += heap->size;
/* Set up the new top. */
top (av) = chunk_at_offset (heap, sizeof (*heap));
set_head (top (av), (heap->size - sizeof (*heap)) | PREV_INUSE);
Expand Down

0 comments on commit 00d4e2e

Please sign in to comment.