This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Enhancing malloc
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: Will Newton <will dot newton at linaro dot org>, Carlos O'Donell <carlos at redhat dot com>, Siddhesh Poyarekar <siddhesh at redhat dot com>, libc-alpha <libc-alpha at sourceware dot org>
- Date: Wed, 29 May 2013 15:25:04 +0200
- Subject: Re: Enhancing malloc
- References: <CANu=Dmj34hZoWr8A5dPThv14XUmP8vTgsxFLAbJ9jTTabRPqqA at mail dot gmail dot com> <20130528123317 dot GA17360 at domone dot kolej dot mff dot cuni dot cz> <20130528125444 dot GC2145 at spoyarek dot pnq dot redhat dot com> <51A50991 dot 7010100 at redhat dot com> <CANu=DmgciQkeWfS8TBq2FVokBQXQCG2V6tmYU+9jhmfCF_9GcQ at mail dot gmail dot com> <51A5EA16 dot 3070707 at redhat dot com> <CANu=Dmg-f9O_UOCw0Zk3ZDu_PK4hGcVq0W6VFET4_O26_jxjaA at mail dot gmail dot com> <51A5FC61 dot 2050106 at redhat dot com>
On Wed, May 29, 2013 at 03:02:25PM +0200, Florian Weimer wrote:
> On 05/29/2013 02:53 PM, Will Newton wrote:
>
> >>Other things to consider are fork friendliness and the impact of buffer
> >>overruns and double-free bugs in application programs in terms of actual
> >>security vulnerabilities.
> >
> >What do you mean by "fork friendliness" in this context?
>
> The metadata updates performed by malloc/free can trigger copying of
> pages shared between the parent and child processes. An obvious
> candidate for such behavior is a hash table keyed by the pointer
> returned by malloc. Under this criterion, schemes which do not
> colocate metadata with object data tend to fare less well than
> schemes which do.
>
I am more concerned of copying of shared pages triggered by malloc.
A memory is most of time fragmented. Assume that significant part of
allocations were less than page large. When malloc allocates memory into
that gap then subsequent code that initializes that memory triggers copy
on write. When parent/child keep allocating memory it is matter of time
until everything is copied.
Here less fragmentation mean less copying.