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: "Dr. David Alan Gilbert" X-Patchwork-Id: 4502 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 06A3323EF6 for ; Mon, 3 Oct 2011 16:34:07 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id C0766A189CE for ; Mon, 3 Oct 2011 16:34:06 +0000 (UTC) Received: by yxm34 with SMTP id 34so5723790yxm.11 for ; Mon, 03 Oct 2011 09:34:06 -0700 (PDT) Received: by 10.223.55.136 with SMTP id u8mr171629fag.46.1317659645991; Mon, 03 Oct 2011 09:34:05 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.23.170 with SMTP id n10cs19892laf; Mon, 3 Oct 2011 09:34:05 -0700 (PDT) Received: by 10.227.200.134 with SMTP id ew6mr157331wbb.45.1317659645274; Mon, 03 Oct 2011 09:34:05 -0700 (PDT) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id gf18si9201498wbb.10.2011.10.03.09.34.04 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 03 Oct 2011 09:34:05 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of david.gilbert@linaro.org) client-ip=74.125.82.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of david.gilbert@linaro.org) smtp.mail=david.gilbert@linaro.org Received: by wwe3 with SMTP id 3so5692860wwe.31 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 Cc: patches@linaro.org, agraf@suse.de, peter.maydell@linaro.org Subject: [PATCH] Make cpu_single_env thread local (Linux only for now) Message-ID: <20111003163352.GA22822@davesworkthinkpad> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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. */