This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH 1/2] Consolidate heap in memalign when alignment is large.
- From: Will Newton <will dot newton at linaro dot org>
- To: Ondřej Bílka <neleai at seznam dot cz>
- Cc: libc-alpha <libc-alpha at sourceware dot org>
- Date: Fri, 8 Nov 2013 10:01:00 +0000
- Subject: Re: [PATCH 1/2] Consolidate heap in memalign when alignment is large.
- Authentication-results: sourceware.org; auth=none
- References: <20131107204959 dot GA21537 at domone>
On 7 November 2013 20:50, OndÅej BÃlka <email@example.com> wrote:
> I looked how deduplicate malloc code. Funcions valloc/pvalloc should be
> implemented by calling memalign, only difference is that they call heap
> If consolidation is useful then memalign would benefit when user passes
> page size alignments. Otherwise we should delete consolidation from
> Which alternative is better?
I would vote for removing the consolidation call. I don't have any
benchmarks for judging what is better and I suspect with this type of
thing you would need a real app with does a significant amount of page
aligned allocations which may not even exist. But pvalloc and valloc
are much less frequently called than memalign/posix_memalign so I
would assume the latter is the better tested code.
And overall I think it is better to err on the side of simplicity,
especially as this code has no clear rationale documented.
> * malloc/malloc.c (__libc_memalign): Call heap consolidation
> when alignment is multiple of page size.
> diff --git a/malloc/malloc.c b/malloc/malloc.c
> index 897c43a..29a5488 100644
> --- a/malloc/malloc.c
> +++ b/malloc/malloc.c
> @@ -3005,6 +3005,9 @@ __libc_memalign(size_t alignment, size_t bytes)
> mstate ar_ptr;
> void *p;
> + if(__malloc_initialized < 0)
> + ptmalloc_init();
This bit is fine.
Toolchain Working Group, Linaro