This is the mail archive of the
mailing list for the glibc project.
Re: Fwd: local equivalent for pthread_once() in glibc?
- From: Florian Weimer <fweimer at redhat dot com>
- To: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, libc-alpha at sourceware dot org
- Date: Mon, 26 Jun 2017 14:51:45 +0200
- Subject: Re: Fwd: local equivalent for pthread_once() in glibc?
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=fweimer at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1659380B29
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1659380B29
- References: <9EBFE06E-AF1D-48E9-85AB-B74C048438B1@oracle.com> <F050C948-50BF-4305-84AC-9003F97D9F59@oracle.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com>
On 06/26/2017 02:13 PM, Adhemerval Zanella wrote:
> On 25/06/2017 12:46, Florian Weimer wrote:
>> On 05/17/2017 04:51 PM, Adhemerval Zanella wrote:
>>> 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).
>> I don't understand. The concurrent access solely consists of reads. We
>> do not use atomics in that case.
> My understanding and my point is even for these cases we should aim for
> C11 atomic accesses, even for relaxed loads which on most architectures
> will map to normal loads.
I don't think this is true. If the last write happen before all the
concurrent read accesses, we don't need atomics. To me, this is quite
clear because this is what happens with locks, where we usually don't
use atomics within the critical section, either.