From patchwork Wed May 12 21:24:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 99111 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4CLRLHG029210 for ; Wed, 12 May 2010 21:27:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757958Ab0ELV1R (ORCPT ); Wed, 12 May 2010 17:27:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34503 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757941Ab0ELV1M (ORCPT ); Wed, 12 May 2010 17:27:12 -0400 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 o4CLR2nj010933 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 12 May 2010 17:27:02 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4CLR1cD021479; Wed, 12 May 2010 17:27:01 -0400 Received: from amt.cnet (vpn2-10-158.ams2.redhat.com [10.36.10.158]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o4CLQxJI021850; Wed, 12 May 2010 17:27:00 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 26064656078; Wed, 12 May 2010 18:25:49 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o4CLPiCD028645; Wed, 12 May 2010 18:25:44 -0300 From: Marcelo Tosatti To: Anthony Liguori Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Marcelo Tosatti , Avi Kivity Subject: [PATCH 03/12] make SIG_IPI to tcg vcpu thread reliable Date: Wed, 12 May 2010 18:24:57 -0300 Message-Id: <1a28cac3161f8a85ee0256776068eaed2da025e5.1273699506.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 12 May 2010 21:27:22 +0000 (UTC) diff --git a/cpu-exec.c b/cpu-exec.c index dc81e79..c776605 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -213,6 +213,8 @@ static void cpu_handle_debug_exception(CPUState *env) /* main execution loop */ +volatile sig_atomic_t exit_request; + int cpu_exec(CPUState *env1) { volatile host_reg_t saved_env_reg; @@ -234,6 +236,11 @@ int cpu_exec(CPUState *env1) asm(""); env = env1; + if (exit_request) { + env->exit_request = 1; + exit_request = 0; + } + #if defined(TARGET_I386) if (!kvm_enabled()) { /* put eflags in CPU temporary format */ diff --git a/cpus.c b/cpus.c index 29462e5..53226b3 100644 --- a/cpus.c +++ b/cpus.c @@ -472,6 +472,7 @@ static void cpu_signal(int sig) { if (cpu_single_env) cpu_exit(cpu_single_env); + exit_request = 1; } static void tcg_block_io_signals(void) @@ -542,26 +543,20 @@ static void unblock_io_signals(void) pthread_sigmask(SIG_BLOCK, &set, NULL); } -static void qemu_signal_lock(unsigned int msecs) -{ - qemu_mutex_lock(&qemu_fair_mutex); - - while (qemu_mutex_trylock(&qemu_global_mutex)) { - qemu_thread_signal(tcg_cpu_thread, SIG_IPI); - if (!qemu_mutex_timedlock(&qemu_global_mutex, msecs)) - break; - } - qemu_mutex_unlock(&qemu_fair_mutex); -} - void qemu_mutex_lock_iothread(void) { if (kvm_enabled()) { qemu_mutex_lock(&qemu_fair_mutex); qemu_mutex_lock(&qemu_global_mutex); qemu_mutex_unlock(&qemu_fair_mutex); - } else - qemu_signal_lock(100); + } else { + qemu_mutex_lock(&qemu_fair_mutex); + if (qemu_mutex_trylock(&qemu_global_mutex)) { + qemu_thread_signal(tcg_cpu_thread, SIG_IPI); + qemu_mutex_lock(&qemu_global_mutex); + } + qemu_mutex_unlock(&qemu_fair_mutex); + } } void qemu_mutex_unlock_iothread(void) diff --git a/exec-all.h b/exec-all.h index 1016de2..4565dd0 100644 --- a/exec-all.h +++ b/exec-all.h @@ -351,4 +351,7 @@ CPUDebugExcpHandler *cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler); /* vl.c */ extern int singlestep; +/* cpu-exec.c */ +extern volatile sig_atomic_t exit_request; + #endif