Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 Dec 2003 17:31:03 -0500 (EST)
From:      Daniel Eischen <eischen@vigrid.com>
To:        Alfred Perlstein <bright@mu.org>
Cc:        hackers@freebsd.org
Subject:   Re: support for __thread
Message-ID:  <Pine.GSO.4.10.10312211712220.24264-100000@pcnet5.pcnet.com>
In-Reply-To: <20031221203311.GW60229@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 21 Dec 2003, Alfred Perlstein wrote:

> * Daniel Eischen <eischen@vigrid.com> [031221 12:08] wrote:
> > On Sun, 21 Dec 2003, Alfred Perlstein wrote:
> > 
> > > * Alfred Perlstein <bright@mu.org> [031221 02:47] wrote:
> > > > How do I get __thread to work for me?
> > > > 
> > > > http://gcc.gnu.org/onlinedocs/gcc/Thread-Local.html
> > > > 
> > > > it seems the assembler chokes on it?
> > 
> > We don't have support for it yet.  Why do you want it?
> 
> .) it'd be nice to have it for future work
> .) linux seems to have it, so does MS

libkse is ready to add support for it but I believe there's
some additional work to be done in rtld-elf first.

> but mostly:
> 
> I'm porting webstone to use threads, and it uses that construct
> for the win32 threaded portion, it'd be really nice if we supported
> it so that I could make use of it instead of changing hundreds of
> lines of code.

I would discourage using __thread and instead make the API
better so it's not needed.  My fear is that once we have it,
it'll be abused in all sorts of ways.  I can understand
needing it for something like nvidia's OpenGL where you
have an existing API layered over their drivers and they
need to get thread-local-storage very often (tight loops).

> Any idea of how much effort it would take?  I have no clue as to
> how to fix our toolchain, gooing the work in ld.so doesn't see
> that awful, but it's not trivial either:
> 
> http://people.freebsd.org/~alfred/tls.pdf

Yes, we've been over that in either -current or -threads; I forget
which.  I think libkse already obeys the tls spec WRT %gs; we just need
some hooks/coordination into/with rtld.

> I want a threaded webstone so that I can generate a lot more load
> with wimpier client boxes on FreeBSD.
>
> Right now doing hundreds of connections nearly kills my desktop,
> but when threaded it barely hiccups.

There is always pthread_[gs]pecific which is what normally should
be used.
 
> Also, in re: thread things:
>  http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/60477
> :(

There were some thoughts on restructuring our name lookups so
that they would be thread-safe.  I would rather see that than
littering __thread around libc.

-- 
Dan Eischen



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.10.10312211712220.24264-100000>