qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: kvm@vger.kernel.org, qemu-devel@nongnu.org
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Subject: [Qemu-devel] [patch uq/master 2/9] make SIG_IPI to tcg vcpu thread reliable
Date: Tue, 04 May 2010 09:45:20 -0300	[thread overview]
Message-ID: <20100504124634.221277834@redhat.com> (raw)
In-Reply-To: 20100504124518.979470863@redhat.com

[-- Attachment #1: qemu-remove-signal-lock --]
[-- Type: text/plain, Size: 2515 bytes --]

Store tcg loop exit request on a global variable, and transfer it to
per-CPUState exit_request after assignment of cpu_single_env.

This makes exit request signal from robust. Drop the timedlock hack.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: qemu/cpu-exec.c
===================================================================
--- qemu.orig/cpu-exec.c
+++ qemu/cpu-exec.c  
@@ -213,6 +213,8 @@ static void cpu_handle_debug_exception(C
 
 /* 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 */
Index: qemu/cpus.c
===================================================================
--- qemu.orig/cpus.c
+++ qemu/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)
Index: qemu/exec-all.h
===================================================================
--- qemu.orig/exec-all.h
+++ qemu/exec-all.h
@@ -339,4 +339,7 @@ CPUDebugExcpHandler *cpu_set_debug_excp_
 /* vl.c */
 extern int singlestep;
 
+/* cpu-exec.c */
+extern volatile sig_atomic_t exit_request;
+
 #endif

  parent reply	other threads:[~2010-05-04 13:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-04 12:45 [Qemu-devel] [patch uq/master 0/9] enable smp > 1 and related fixes Marcelo Tosatti
2010-05-04 12:45 ` [Qemu-devel] [patch uq/master 1/9] kvm: set cpu_single_env around KVM_RUN ioctl Marcelo Tosatti
2010-05-04 12:45 ` Marcelo Tosatti [this message]
2010-05-04 12:45 ` [Qemu-devel] [patch uq/master 3/9] standardize on qemu_cpu_kick for signalling cpu thread(s) Marcelo Tosatti
2010-05-04 12:45 ` [Qemu-devel] [patch uq/master 4/9] port qemu-kvm's on_vcpu code Marcelo Tosatti
2010-05-04 12:45 ` [Qemu-devel] [patch uq/master 5/9] kvm: synchronize state from cpu context Marcelo Tosatti
2010-05-06 11:31   ` [Qemu-devel] " Avi Kivity
2010-05-04 12:45 ` [Qemu-devel] [patch uq/master 6/9] add cpu_is_stopped helper Marcelo Tosatti
2010-05-04 12:45 ` [Qemu-devel] [patch uq/master 7/9] move stop/stopped CPU_COMMON fields after area zeroed by reset Marcelo Tosatti
2010-05-04 12:45 ` [Qemu-devel] [patch uq/master 8/9] kvm: validate context for kvm cpu get/put operations Marcelo Tosatti
2010-05-04 12:45 ` [Qemu-devel] [patch uq/master 9/9] kvm: enable smp > 1 Marcelo Tosatti
2010-05-05 18:24 ` [Qemu-devel] Re: [patch uq/master 0/9] enable smp > 1 and related fixes Anthony Liguori
2010-05-06 11:33   ` Avi Kivity
2010-05-06 11:34 ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100504124634.221277834@redhat.com \
    --to=mtosatti@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).