summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2018-01-30 11:05:06 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2018-02-07 14:09:25 +0100
commit9b0605f9837b68fd56c7fc7c96a3a1a3b983687d (patch)
tree66aa6b3fdb09575c3e0ad11ee8d54fab52ca4535
parentd2831ab065765c8af13a5bb42627150323a96662 (diff)
downloadfocaccia-qemu-9b0605f9837b68fd56c7fc7c96a3a1a3b983687d.tar.gz
focaccia-qemu-9b0605f9837b68fd56c7fc7c96a3a1a3b983687d.zip
cpus: tcg: unregister thread with RCU, fix exiting of loop on unplug
Keep running until cpu_can_run(cpu) becomes false, for consistency
with other acceslerators.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to '')
-rw-r--r--cpus.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/cpus.c b/cpus.c
index 190ad5aabb..269d527938 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1467,6 +1467,7 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg)
         deal_with_unplugged_cpus();
     }
 
+    rcu_unregister_thread();
     return NULL;
 }
 
@@ -1603,18 +1604,17 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
                 /* Ignore everything else? */
                 break;
             }
-        } else if (cpu->unplug) {
-            qemu_tcg_destroy_vcpu(cpu);
-            cpu->created = false;
-            qemu_cond_signal(&qemu_cpu_cond);
-            qemu_mutex_unlock_iothread();
-            return NULL;
         }
 
         atomic_mb_set(&cpu->exit_request, 0);
         qemu_wait_io_event(cpu);
-    }
+    } while (!cpu->unplug || cpu_can_run(cpu));
 
+    qemu_tcg_destroy_vcpu(cpu);
+    cpu->created = false;
+    qemu_cond_signal(&qemu_cpu_cond);
+    qemu_mutex_unlock_iothread();
+    rcu_unregister_thread();
     return NULL;
 }