This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/2] Initialize tunable list with the GLIBC_TUNABLES environment variable
- From: Siddhesh Poyarekar <sid at reserved-bit dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: libc-alpha at sourceware dot org, roland at hack dot frob dot com, carlos at redhat dot com, "Paul E. Murphy" <murphyp at linux dot vnet dot ibm dot com>, Andi Kleen <andi at firstfloor dot org>
- Date: Mon, 11 Jan 2016 20:15:37 +0530
- Subject: Re: [PATCH 2/2] Initialize tunable list with the GLIBC_TUNABLES environment variable
- Authentication-results: sourceware.org; auth=none
- References: <20160111111719 dot GA4183 at devel dot intra dot reserved-bit dot com> <mvmd1t81axj dot fsf at hawking dot suse dot de>
On Mon, Jan 11, 2016 at 02:51:36PM +0100, Andreas Schwab wrote:
> Siddhesh Poyarekar <sid@reserved-bit.com> writes:
>
> > void
> > __tunables_init (char **envp)
> > {
> > - /* Empty for now. */
> > + static bool initialized = false;
> > +
> > + if (__glibc_likely (initialized))
> > + return;
>
> Is this supposed to be thread-safe?
This is called only from the libc.so and libpthread.so constructors.
So the first run will always happen exclusively in the main thread
through either library constructor.
Even in case the constructors do get called in parallel in different
threads, they should get synchronized by the dynamic linker load lock,
so you'd never have concurrent calls to __tunables_init that race on
the value of initialized.
Siddhesh