From patchwork Tue Dec 1 12:51:34 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 39904 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A0060B7BA5 for ; Wed, 2 Dec 2009 00:12:24 +1100 (EST) Received: from localhost ([127.0.0.1]:39251 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFSWi-0003db-Js for incoming@patchwork.ozlabs.org; Tue, 01 Dec 2009 08:12:20 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFSD8-0005aT-On for qemu-devel@nongnu.org; Tue, 01 Dec 2009 07:52:06 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFSD3-0005YD-GX for qemu-devel@nongnu.org; Tue, 01 Dec 2009 07:52:05 -0500 Received: from [199.232.76.173] (port=35011 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFSD2-0005Xh-H2 for qemu-devel@nongnu.org; Tue, 01 Dec 2009 07:52:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:31741) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NFSD2-0004s9-5Q for qemu-devel@nongnu.org; Tue, 01 Dec 2009 07:52:00 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nB1CpwmB001320 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 1 Dec 2009 07:51:59 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nB1CphO4002534; Tue, 1 Dec 2009 07:51:57 -0500 From: Glauber Costa To: qemu-devel@nongnu.org Date: Tue, 1 Dec 2009 10:51:34 -0200 Message-Id: <1259671897-22232-9-git-send-email-glommer@redhat.com> In-Reply-To: <1259671897-22232-8-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> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com, avi@redhat.com, agraf@suse.de Subject: [Qemu-devel] [PATCH v2 08/11] use cpu_kick instead of direct signalling. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Before signalling a cpu, we have to set exit_request = 1, otherwise it may go back to executing itself. So every cpu wakeup becomes at least two statements. The qemu_cpu_kick already provides semantics to that. So use it all over. Signed-off-by: Glauber Costa --- vl.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/vl.c b/vl.c index c7b46a9..97446fc 100644 --- a/vl.c +++ b/vl.c @@ -3568,6 +3568,7 @@ void qemu_cpu_kick(void *_env) { CPUState *env = _env; qemu_cond_broadcast(env->halt_cond); + env->exit_request = 1; if (kvm_enabled()) qemu_thread_signal(env->thread, SIGUSR1); } @@ -3589,7 +3590,7 @@ void qemu_queue_work(CPUState *env, void (*func)(void *data), void *data) wii->data = data; wii->done = 0; - qemu_thread_signal(env->thread, SIGUSR1); + qemu_cpu_kick(env); while (!wii->done) { qemu_cond_wait(&env->work_cond, &qemu_global_mutex); @@ -3716,7 +3717,7 @@ static void pause_all_vcpus(void) qemu_cond_timedwait(&qemu_pause_cond, &qemu_global_mutex, 100); penv = first_cpu; while (penv) { - qemu_thread_signal(penv->thread, SIGUSR1); + qemu_cpu_kick(penv); penv = (CPUState *)penv->next_cpu; } } @@ -3729,7 +3730,6 @@ static void resume_all_vcpus(void) while (penv) { penv->stop = 0; penv->stopped = 0; - qemu_thread_signal(penv->thread, SIGUSR1); qemu_cpu_kick(penv); penv = (CPUState *)penv->next_cpu; }