[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 10/11] Use __thread where available.
From: |
Glauber Costa |
Subject: |
[Qemu-devel] [PATCH v2 10/11] Use __thread where available. |
Date: |
Tue, 1 Dec 2009 10:51:36 -0200 |
It is much faster than pthread_{g,s}et_specific.
Signed-off-by: Glauber Costa <address@hidden>
---
configure | 17 +++++++++++++++++
vl.c | 16 ++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/configure b/configure
index dca5a43..ce7bcc4 100755
--- a/configure
+++ b/configure
@@ -233,6 +233,7 @@ blobs="yes"
pkgversion=""
check_utests="no"
user_pie="no"
+tls_thread="yes"
# OS specific
if check_define __linux__ ; then
@@ -1017,6 +1018,19 @@ EOF
fi
##########################################
+# Check for availability of the __thread keyword
+cat > $TMPC <<EOF
+__thread void *ptr;
+int main(void) { return 0;}
+EOF
+
+if compile_prog; then
+ tls_thread="yes"
+else
+ tls_thread="no"
+fi
+
+##########################################
# VNC TLS detection
if test "$vnc_tls" != "no" ; then
cat > $TMPC <<EOF
@@ -1969,6 +1983,9 @@ echo "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >>
$config_host_mak
if test "$mixemu" = "yes" ; then
echo "CONFIG_MIXEMU=y" >> $config_host_mak
fi
+if test "$tls_thread" = "yes" ; then
+ echo "CONFIG_TLS_HAS_THREAD=y" >> $config_host_mak
+fi
if test "$vnc_tls" = "yes" ; then
echo "CONFIG_VNC_TLS=y" >> $config_host_mak
echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
diff --git a/vl.c b/vl.c
index ad2e7d6..16a41e3 100644
--- a/vl.c
+++ b/vl.c
@@ -3445,21 +3445,37 @@ static void block_io_signals(void);
static void unblock_io_signals(void);
static int tcg_has_work(void);
+#ifdef CONFIG_TLS_HAS_THREAD
+static __thread CPUState *current_env;
+#else
static pthread_key_t current_env;
+#endif
static CPUState *qemu_get_current_env(void)
{
+#ifdef CONFIG_TLS_HAS_THREAD
+ return current_env;
+#else
return pthread_getspecific(current_env);
+#endif
}
static void qemu_set_current_env(CPUState *env)
{
+#ifdef CONFIG_TLS_HAS_THREAD
+ current_env = env;
+#else
pthread_setspecific(current_env, env);
+#endif
}
static void qemu_init_current_env(void)
{
+#ifdef CONFIG_TLS_HAS_THREAD
+ current_env = NULL;
+#else
pthread_key_create(¤t_env, NULL);
+#endif
}
static int qemu_init_main_loop(void)
--
1.6.5.2
- [Qemu-devel] [PATCH v2 0/11], Glauber Costa, 2009/12/01
- [Qemu-devel] [PATCH v2 01/11] Don't mess with halted state., Glauber Costa, 2009/12/01
- [Qemu-devel] [PATCH v2 02/11] store thread-specific env information, Glauber Costa, 2009/12/01
- [Qemu-devel] [PATCH v2 03/11] update halted state on mp_state sync, Glauber Costa, 2009/12/01
- [Qemu-devel] [PATCH v2 04/11] qemu_flush_work for remote vcpu execution, Glauber Costa, 2009/12/01
- [Qemu-devel] [PATCH v2 05/11] tell kernel about all registers instead of just mp_state, Glauber Costa, 2009/12/01
- [Qemu-devel] [PATCH v2 06/11] flush state in migration post_load, Glauber Costa, 2009/12/01
- [Qemu-devel] [PATCH v2 07/11] Don't call kvm cpu reset on initialization, Glauber Costa, 2009/12/01
- [Qemu-devel] [PATCH v2 08/11] use cpu_kick instead of direct signalling., Glauber Costa, 2009/12/01
- [Qemu-devel] [PATCH v2 09/11] Use per-cpu reset handlers., Glauber Costa, 2009/12/01
- [Qemu-devel] [PATCH v2 10/11] Use __thread where available.,
Glauber Costa <=
- [Qemu-devel] [PATCH v2 11/11] remove smp restriction from kvm, Glauber Costa, 2009/12/01
- Re: [Qemu-devel] [PATCH v2 05/11] tell kernel about all registers instead of just mp_state, Gleb Natapov, 2009/12/02
- Re: [Qemu-devel] [PATCH v2 05/11] tell kernel about all registers instead of just mp_state, Glauber Costa, 2009/12/02
- [Qemu-devel] Re: [PATCH v2 05/11] tell kernel about all registers instead of just mp_state, Jan Kiszka, 2009/12/02
- [Qemu-devel] Re: [PATCH v2 05/11] tell kernel about all registers instead of just mp_state, Gleb Natapov, 2009/12/02
- [Qemu-devel] Re: [PATCH v2 05/11] tell kernel about all registers instead of just mp_state, Jan Kiszka, 2009/12/02
- Re: [Qemu-devel] [PATCH v2 04/11] qemu_flush_work for remote vcpu execution, Marcelo Tosatti, 2009/12/02
- Re: [Qemu-devel] [PATCH v2 04/11] qemu_flush_work for remote vcpu execution, Glauber Costa, 2009/12/02
- Re: [Qemu-devel] [PATCH v2 04/11] qemu_flush_work for remote vcpu execution, Marcelo Tosatti, 2009/12/02
- Re: [Qemu-devel] [PATCH v2 04/11] qemu_flush_work for remote vcpu execution, Glauber Costa, 2009/12/02