From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MvbaL-0003H8-VG for qemu-devel@nongnu.org; Wed, 07 Oct 2009 14:50:02 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MvbaH-0003Ct-3o for qemu-devel@nongnu.org; Wed, 07 Oct 2009 14:50:01 -0400 Received: from [199.232.76.173] (port=42268 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MvbaG-0003CX-Rt for qemu-devel@nongnu.org; Wed, 07 Oct 2009 14:49:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2602) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MvbaG-0000v7-CI for qemu-devel@nongnu.org; Wed, 07 Oct 2009 14:49:56 -0400 From: Glauber Costa Date: Wed, 7 Oct 2009 15:49:48 -0300 Message-Id: <1254941388-12556-3-git-send-email-glommer@redhat.com> In-Reply-To: <1254941388-12556-2-git-send-email-glommer@redhat.com> References: <1254941388-12556-1-git-send-email-glommer@redhat.com> <1254941388-12556-2-git-send-email-glommer@redhat.com> Subject: [Qemu-devel] [PATCH 2/2] do proper cpu_self check List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Glauber Costa , aliguori@us.ibm.com From: Glauber Costa Currently, our check for qemu_cpu_self only checks if there is a cpu currently in execution (represented by cpu_single_env being set). While this might be okay for tcg, it is certainly not okay for kvm, since multiple cpus might be executing. Instead, I propose we use pthread primitives to test if the caller thread is the same as env->thread. For tcg, it will have the same semantics as before, since all CPUStates will point to the same thread, and we'll only have one in execution at a time. Signed-off-by: Glauber Costa --- vl.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/vl.c b/vl.c index 3012141..e141bd1 100644 --- a/vl.c +++ b/vl.c @@ -3582,9 +3582,14 @@ void qemu_cpu_kick(void *_env) qemu_thread_signal(env->thread, SIGUSR1); } -int qemu_cpu_self(void *env) +int qemu_cpu_self(void *_env) { - return (cpu_single_env != NULL); + CPUState *env = _env; + QemuThread this; + + qemu_thread_self(&this); + + return qemu_thread_equal(&this, env->thread); } static void cpu_signal(int sig) -- 1.6.2.5