This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] malloc: Prevent arena free_list from turning cyclic [BZ #19048]


2015-10-09 15:30 GMT-03:00 Siddhesh Poyarekar <sid@reserved-bit.com>:
> On Friday 09 October 2015 11:58 PM, Siddhesh Poyarekar wrote:
>
>>> +static void
>>> +deattach_arena (mstate replaced_arena)
>>
>> Call it detach_arena if you want to keep it a separate function.
>
> To be clear, it seems to me that consolidating to arena_get2 would mean
> that detach_arena is called in only one place and hence may not deserve
> to be a separate function.

  My first idea was to create a reference counter, and only put
arenas in the free_list if the reference counter goes down to zero.
  If I understand correctly, adding a reference counter, but having
more threads then arenas, will cause it to cycle in the next pointer,
until there are less threads than arenas, in which case,  the
next_free pointer would become close to useless, as well as the
reference counter, because they would seldomly be used.
  I confess I do not correctly understand what was the original
idea of the free_list pointer, but after thinking about a reference
counter, I preferred the two proposed patches, that are localized.
Either add the arena in the tail of the free_list, or in the head as
the last proposed one, as it would have the same behavior of
current glibc, sans correcting the free_list corruption.

> Siddhesh

Thanks,
Paulo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]