Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 24 Mar 2014 20:58:15 -0400
From: Rich Felker <>
Subject: Re: Transition path for removing lazy init of thread pointer

On Mon, Mar 24, 2014 at 11:44:57PM +0000, Justin Cormack wrote:
> On Mon, Mar 24, 2014 at 11:04 PM, Rich Felker <> wrote:
> >
> > At this point we now have two mandatory syscalls at startup on most
> > archs (just one where setting the thread pointer is entirely a
> > userspace operation). The second syscall is set_tid_address, and it
> > seems like it should only be needed it pthread_create is being used
> > (to that pthread_join will work), but it serves a second purpose of
> > standing in for gettid() too. We could, however, eliminate it in some
> > cases:x
> Which archs is it userspace only?

Setting the thread pointer is a fully-userspace operation on
microblaze, sh, and powerpc. On the rest it requires a syscall.

Note that one negative side-effect of it being fully userspace is that
we get no indication of whether the kernel is new enough to support
threads properly (whereas normally, successful syscall to set the
thread pointer means the kernel supports threads). So on these archs,
pthread_create really needs to be doing some extra work to make sure
threads are supported and the clone flags it's using will actually
have an effect; otherwise it could end up creating threads that don't
behave at all like threads... This is an issue we've ignored until
now, but it's fairly minor, especially since microblaze didn't even
exist during 2.4 and sh has been broken in the kernel up til now and
until at least the next kernel release.

> Any idea what the performance benefit of the optimisations might be?
> Static linked non threaded programs sounds like a good target.

Basically just cutting off one syscall that takes ~1000-3000 cycles
that's always accompanied by a syscall that takes over 100000 cycles
(execve). So not much, I think.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.