[lxc-devel] [PATCH] remove static_lock()/static_unlock() and start to use thread local storage (v2)

Serge Hallyn serge.hallyn at ubuntu.com
Thu Jan 2 15:44:33 UTC 2014


Quoting S.Çağlar Onur (caglar at 10ur.org):
> Hi,
> 
> What about reverting the revert and then do something like following?

The question is whether we want to consider use of threads on
android unsupported for now or not.  If so, then we can do what
you suggest, as well as ignore the missing pthread_atfork().
If not then we have to either keep static_lock() or find the
right fix for in bionic.

I'm happy to consider threads unsupported in android, but then
I don't use lxc on android :)  Stéphane?

> diff --git a/src/lxc/utils.c b/src/lxc/utils.c
> index e00c47c..c94ee24 100644
> --- a/src/lxc/utils.c
> +++ b/src/lxc/utils.c
> @@ -270,7 +270,11 @@ const char *lxc_global_config_value(const char
> *option_name)
>         }
> 
>         /* placed in the thread local storage pool */
> +#ifdef IS_BIONIC
> +       static const char *values[sizeof(options) / sizeof(options[0])] = { 0 };
> +#else
>         static __thread const char *values[sizeof(options) /
> sizeof(options[0])] = { 0 };
> +#endif
>         const char *(*ptr)[2];
>         const char *value;
>         size_t i;
> 
> This solves both problem until we come up with a proper solution.
> 
> 
> On Mon, Dec 23, 2013 at 1:29 PM, Serge Hallyn <serge.hallyn at ubuntu.com> wrote:
> > Quoting Stéphane Graber (stgraber at ubuntu.com):
> >> On Mon, Dec 23, 2013 at 10:14:41AM -0600, Serge Hallyn wrote:
> >> > Quoting Stéphane Graber (stgraber at ubuntu.com):
> >> > > On Mon, Dec 23, 2013 at 09:25:55AM -0600, Serge Hallyn wrote:
> >> > > > Quoting Andrey Mazo (mazo at telum.ru):
> >> > > > > Hi all,
> >> > > > >
> >> > > > > Sorry for coming too late to the discussion.
> >> > > > > In fact, I've already acked [1] the changeset.
> >> > > > > But after sleeping more on it, I'm concerned about __thread and bionic.
> >> > > > > Quoting android-ndk-r9c/docs/text/system/libc/OVERVIEW.text:
> >> > > > >   At the moment, thread-local storage defined through the __thread compiler
> >> > > > >   keyword is not supported by the Bionic C library and dynamic linker.
> >> > > > >
> >> > > > > The same OVERVIEW.TXT was present until recently in bionic sources [2].
> >> > > > > Moreover, grepping (today's git HEAD) bionic sources for __thread, PT_TLS (thread-local storage segment), .tbss and .tdata section names shows nothing.
> >> > > > > So, while utils.c compiles fine (due to GNU gcc/binutils support for __thread), lxc-* will likely segfault on the first access to the "values" array (because of missing memory segment due to bionic dynamic loader's lack of __thread support).
> >> > > > > I suppose, we could allocate a TLS slot for "values" pointer via pthread_key_create() and set it to a per-thread malloc()'ed memory chunk via pthread_setspecific(). (this seems to be quite verbose though)
> >> > > >
> >> > > > Stéphane, have you run lxc with this patch on android without
> >> > > > passing -P (which should get the lxcpath from default values)?
> >> > >
> >> > > I'm unfortunately 7000km away from my LXC on Android hardware and will
> >> > > only be able to test it on the 3rd of January.
> >> >
> >> > Should we revert the patch with a note to test on android on jan 4th?
> >>
> >> Since I just published a blog post telling people they can use LXC on
> >> Android using current git head, that may be the safer course of action
> >> indeed.
> >
> > Ok I've reverted that, let's test with it on android in two weeks.
> >
> > thanks,
> > -serge
> > _______________________________________________
> > lxc-devel mailing list
> > lxc-devel at lists.linuxcontainers.org
> > http://lists.linuxcontainers.org/listinfo/lxc-devel
> 
> 
> 
> -- 
> S.Çağlar Onur <caglar at 10ur.org>
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel


More information about the lxc-devel mailing list