]> git.proxmox.com Git - qemu.git/commitdiff
Fix cpu_exit for tcp_cpu_exec
authorJan Kiszka <jan.kiszka@siemens.com>
Fri, 25 Jun 2010 14:56:52 +0000 (16:56 +0200)
committerAurelien Jarno <aurelien@aurel32.net>
Thu, 22 Jul 2010 03:52:09 +0000 (05:52 +0200)
If a cpu_exit request is pending, ensure that we leave the CPU loop
quickly. For this purpose, keep the global exit_request pending until
we are about to leave tcg_cpu_exec. Also, immediately break out of the
SMP loop if the request is set, do not run till the end of the chain.
This preserves the VCPU scheduling order in SMP mode.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
cpu-exec.c
cpus.c

index 5f88f3fa893716e8ccfe9068b937e6a478eae42b..d170566cfddbc676682272e9dcd651460d4bb74e 100644 (file)
@@ -237,9 +237,8 @@ int cpu_exec(CPUState *env1)
     barrier();
     env = env1;
 
-    if (exit_request) {
+    if (unlikely(exit_request)) {
         env->exit_request = 1;
-        exit_request = 0;
     }
 
 #if defined(TARGET_I386)
diff --git a/cpus.c b/cpus.c
index b95cc195d0027ba1008e733345b2292b3d7dbffd..7533668d2b9e2d999d68a9bad085be32c819f4e6 100644 (file)
--- a/cpus.c
+++ b/cpus.c
@@ -770,7 +770,7 @@ bool tcg_cpu_exec(void)
 
     if (next_cpu == NULL)
         next_cpu = first_cpu;
-    for (; next_cpu != NULL; next_cpu = next_cpu->next_cpu) {
+    for (; next_cpu != NULL && !exit_request; next_cpu = next_cpu->next_cpu) {
         CPUState *env = cur_cpu = next_cpu;
 
         qemu_clock_enable(vm_clock,
@@ -789,6 +789,7 @@ bool tcg_cpu_exec(void)
             break;
         }
     }
+    exit_request = 0;
     return tcg_has_work();
 }