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: Fwd: local equivalent for pthread_once() in glibc?



On 17/05/2017 06:57, Florian Weimer wrote:
> On 04/26/2017 02:40 PM, Adhemerval Zanella wrote:
>> Now that we are on the subject, shouldn't we use __libc_once on
>> __malloc_initialized?
> 
> I think that would be misleading.  The arena selection code assumes that
> the main arena has been fully initialized, not just that ptmalloc_init
> has run.  ptmalloc_init only performs a partial initialization, the rest
> is done through malloc_consolidate (which is again triggered by the
> allocation which is part of pthread_create).  If we fix ptmalloc_init to
> allow concurrent invocation (although that never would happen), the lack
> of full initialization would still be in issue (in the impossible case
> that ptmalloc_init ran concurrenctly).
> 
> Thanks,
> Florian
> 

Right, but this is not seem the case for tunable where malloc_consolidate is
called from ptmalloc_init (at least for main_arena).  In any case, I still
think that for adequate __malloc_initialized access using C11 atomic since
its access is still done concurrently (that why I asked if using __libc_once
would be simpler).


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