Patchwork [v2,08/11] use cpu_kick instead of direct signalling.

login
register
mail settings
Submitter Glauber Costa
Date Dec. 1, 2009, 12:51 p.m.
Message ID <1259671897-22232-9-git-send-email-glommer@redhat.com>
Download mbox | patch
Permalink /patch/39904/
State New
Headers show

Comments

Glauber Costa - Dec. 1, 2009, 12:51 p.m.
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 <glommer@redhat.com>
---
 vl.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

Patch

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;
     }