From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFSDC-0005cW-Uo for qemu-devel@nongnu.org; Tue, 01 Dec 2009 07:52:11 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFSD6-0005Zg-1Q for qemu-devel@nongnu.org; Tue, 01 Dec 2009 07:52:09 -0500 Received: from [199.232.76.173] (port=35015 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFSD5-0005ZY-Bv for qemu-devel@nongnu.org; Tue, 01 Dec 2009 07:52:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:19181) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NFSD4-0004sV-Vy for qemu-devel@nongnu.org; Tue, 01 Dec 2009 07:52:03 -0500 From: Glauber Costa Date: Tue, 1 Dec 2009 10:51:36 -0200 Message-Id: <1259671897-22232-11-git-send-email-glommer@redhat.com> In-Reply-To: <1259671897-22232-10-git-send-email-glommer@redhat.com> References: <1259671897-22232-1-git-send-email-glommer@redhat.com> <1259671897-22232-2-git-send-email-glommer@redhat.com> <1259671897-22232-3-git-send-email-glommer@redhat.com> <1259671897-22232-4-git-send-email-glommer@redhat.com> <1259671897-22232-5-git-send-email-glommer@redhat.com> <1259671897-22232-6-git-send-email-glommer@redhat.com> <1259671897-22232-7-git-send-email-glommer@redhat.com> <1259671897-22232-8-git-send-email-glommer@redhat.com> <1259671897-22232-9-git-send-email-glommer@redhat.com> <1259671897-22232-10-git-send-email-glommer@redhat.com> Subject: [Qemu-devel] [PATCH v2 10/11] Use __thread where available. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, avi@redhat.com, agraf@suse.de It is much faster than pthread_{g,s}et_specific. Signed-off-by: Glauber Costa --- 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 < $TMPC <> $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