coroutine-ucontext: use __thread
commitd1d1b206b07977fe0e75b0254e5b50c215c97803
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 2 Dec 2014 11:05:44 +0000 (2 12:05 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Tue, 13 Jan 2015 13:43:28 +0000 (13 13:43 +0000)
tree2926e9c04304e3ef1d016a84152a3e27cd486fc1
parentbc521696607c5348fcd8a9e57b408d0ac0dbe2f8
coroutine-ucontext: use __thread

ELF thread local storage is about 10% faster on tests/test-coroutine's
perf/cost test.  The timing on my machine is 190ns per iteration with
pthread TLS, 170 with ELF TLS.

Based on a patch by Kevin Wolf and Peter Lieven, but redone to follow
the model of coroutine-win32.c (including the important "noinline"
attribute!).

Platforms without thread-local storage (OpenBSD probably?) will need
a new-enough GCC for this to compile, in order to use the same emutls
support that Windows already relies on.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Message-id: 1417518350-6167-2-git-send-email-pbonzini@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
coroutine-ucontext.c