From patchwork Mon Oct 3 16:33:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gilbert X-Patchwork-Id: 117482 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 85E2FB6F75 for ; Tue, 4 Oct 2011 03:34:27 +1100 (EST) Received: from localhost ([::1]:53666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAlT5-0004qE-UE for incoming@patchwork.ozlabs.org; Mon, 03 Oct 2011 12:34:15 -0400 Received: from eggs.gnu.org ([140.186.70.92]:35620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAlSy-0004px-Rj for qemu-devel@nongnu.org; Mon, 03 Oct 2011 12:34:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RAlSx-0002Zr-Ns for qemu-devel@nongnu.org; Mon, 03 Oct 2011 12:34:08 -0400 Received: from mail-wy0-f173.google.com ([74.125.82.173]:57257) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAlSx-0002Zh-Ey for qemu-devel@nongnu.org; Mon, 03 Oct 2011 12:34:07 -0400 Received: by wyh22 with SMTP id 22so3858923wyh.4 for ; Mon, 03 Oct 2011 09:34:04 -0700 (PDT) Received: by 10.216.15.76 with SMTP id e54mr165452wee.54.1317659644515; Mon, 03 Oct 2011 09:34:04 -0700 (PDT) Received: from davesworkthinkpad (gbibp9ph1--blueice2n1.emea.ibm.com. [195.212.29.75]) by mx.google.com with ESMTPS id h14sm20265101wbo.7.2011.10.03.09.34.03 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 03 Oct 2011 09:34:03 -0700 (PDT) Date: Mon, 3 Oct 2011 17:33:56 +0100 From: "Dr. David Alan Gilbert" To: qemu-devel@nongnu.org Message-ID: <20111003163352.GA22822@davesworkthinkpad> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.173 Cc: peter.maydell@linaro.org, agraf@suse.de, patches@linaro.org Subject: [Qemu-devel] [PATCH] Make cpu_single_env thread local (Linux only for now) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Make cpu_single_env thread local (Linux only for now) * Fixes some user space threading issues (esp those triggered by bug 823902) Against rev d11cf8cc..., tested on ARM user mode, and ARM Vexpress system mode (with Blue Swirl's fix from yesterday) - only tested on Linux host. Lets me run ARM userspace firefox. Signed-off-by: Dr. David Alan Gilbert diff --git a/cpu-all.h b/cpu-all.h index 42a5fa0..d895ee6 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -334,7 +334,13 @@ void cpu_dump_statistics(CPUState *env, FILE *f, fprintf_function cpu_fprintf, void QEMU_NORETURN cpu_abort(CPUState *env, const char *fmt, ...) GCC_FMT_ATTR(2, 3); extern CPUState *first_cpu; + +#ifdef __linux__ +/* DAG: Only tested thread local on Linux, feel free to add others */ +extern __thread CPUState *cpu_single_env; +#else extern CPUState *cpu_single_env; +#endif /* Flags for use in ENV->INTERRUPT_PENDING. diff --git a/exec.c b/exec.c index d0cbf15..b82d8e4 100644 --- a/exec.c +++ b/exec.c @@ -120,7 +120,12 @@ static MemoryRegion *system_io; CPUState *first_cpu; /* current CPU in the current thread. It is only valid inside cpu_exec() */ +#ifdef __linux__ +/* DAG: Only tested thread local on Linux, feel free to add others */ +__thread CPUState *cpu_single_env; +#else CPUState *cpu_single_env; +#endif /* 0 = Do not count executed instructions. 1 = Precise instruction counting. 2 = Adaptive rate instruction counting. */