[PATCH v2] malloc: Prevent arena free_list from turning cyclic [BZ #19048]
Florian Weimer
fweimer@redhat.com
Tue Oct 13 11:31:00 GMT 2015
On 10/09/2015 08:28 PM, Siddhesh Poyarekar wrote:
> The only time a thread ever switches arenas is when it fails to allocate
> on the earlier arena. Also, what's hidden in the implementation is that
> the switch always happens from the main arena to a non-main arena and
> never in any other condition. So you could consolidate the replacement
> logic to just arena_get2 where you do tsd_setspecific (arena_key, NULL)
> if avoid_arena is set and decrement the refcount on avoid_arena.
> There's no other place where you want to detach from an arena.
>
> It makes no sense to stick to the avoided arena anyway because we failed
> to allocate on that arena and if we don't find another arena either
> through a free list or reused_arena, we will try mmap and if even that
> fails, we fail allocation.
Thanks for your comments. The code is difficult to follow (and it does
not seem to do what some people expect it to do, it seems). But I do
not want to refactor it in a major way right now.
I believe I have addressed your comments in the attached patch. I would
really like to have a review of the pthread_atfork changes because these
bits are really tricky.
Florian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-malloc-Prevent-arena-free_list-from-turning-cyclic-B.patch
Type: text/x-patch
Size: 7067 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20151013/6960e236/attachment.bin>
More information about the Libc-alpha
mailing list