From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSl4X-00066W-LK for qemu-devel@nongnu.org; Mon, 29 Oct 2012 04:51:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TSl4S-0004zM-Bi for qemu-devel@nongnu.org; Mon, 29 Oct 2012 04:51:49 -0400 Received: from plane.gmane.org ([80.91.229.3]:47061) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSl4S-0004ys-4t for qemu-devel@nongnu.org; Mon, 29 Oct 2012 04:51:44 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TSl4V-0004hd-V6 for qemu-devel@nongnu.org; Mon, 29 Oct 2012 09:51:48 +0100 Received: from 93-34-169-1.ip50.fastwebnet.it ([93.34.169.1]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 29 Oct 2012 09:51:47 +0100 Received: from pbonzini by 93-34-169-1.ip50.fastwebnet.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 29 Oct 2012 09:51:47 +0100 From: Paolo Bonzini Date: Mon, 29 Oct 2012 09:51:30 +0100 Message-ID: References: <1351468127-15025-1-git-send-email-pingfank@linux.vnet.ibm.com> <1351468127-15025-8-git-send-email-pingfank@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit In-Reply-To: <1351468127-15025-8-git-send-email-pingfank@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [patch v5 7/8] memory: introduce tls context to record nested dma List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Il 29/10/2012 00:48, Liu Ping Fan ha scritto: > Signed-off-by: Liu Ping Fan > --- > cpus.c | 3 ++ > exec.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > qemu-thread.h | 8 +++++++ > vl.c | 1 + > 4 files changed, 70 insertions(+), 0 deletions(-) > > diff --git a/cpus.c b/cpus.c > index 191cbf5..e67d80f 100644 > --- a/cpus.c > +++ b/cpus.c > @@ -733,6 +733,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg) > > qemu_mutex_lock(&qemu_global_mutex); > qemu_thread_get_self(cpu->thread); > + qemu_thread_init_context(); > env->thread_id = qemu_get_thread_id(); > cpu_single_env = env; > > @@ -774,6 +775,7 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) > > qemu_mutex_lock_iothread(); > qemu_thread_get_self(cpu->thread); > + qemu_thread_init_context(); > env->thread_id = qemu_get_thread_id(); > > sigemptyset(&waitset); > @@ -813,6 +815,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) > > qemu_tcg_init_cpu_signals(); > qemu_thread_get_self(cpu->thread); > + qemu_thread_init_context(); > > /* signal CPU creation */ > qemu_mutex_lock(&qemu_global_mutex); > diff --git a/exec.c b/exec.c > index 46da08c..ea672c6 100644 > --- a/exec.c > +++ b/exec.c > @@ -3449,6 +3449,49 @@ static bool address_space_section_lookup_ref(AddressSpace *as, > return safe_ref; > } > > +typedef struct ThreadContext { > + DispatchType dispatch_type; > + unsigned int mmio_req_pending; > +} ThreadContext; > + > +static __thread ThreadContext *thread_context; > + > +void qemu_thread_init_context(void) > +{ > + thread_context = g_new(ThreadContext, 1); > + thread_context->dispatch_type = DISPATCH_INIT; > + thread_context->mmio_req_pending = 0; > +} No need for this: static __thread ThreadContext thread_context = { .dispatch_type = DISPATCH_INIT, .mmio_req_pending = 0 }; Paolo