cpus: Fix CPU unplug for MTTCG
authorBharata B Rao <bharata@linux.vnet.ibm.com>
Thu, 27 Apr 2017 05:18:22 +0000 (10:48 +0530)
committerDavid Gibson <david@gibson.dropbear.id.au>
Wed, 10 May 2017 23:45:15 +0000 (09:45 +1000)
Ensure that the unplugged CPU thread is destroyed and the waiting
thread is notified about it. This is needed for CPU unplug to work
correctly in MTTCG mode.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
cpus.c

diff --git a/cpus.c b/cpus.c
index 740b8dc3f808b320cce92c434af93f8bc315eb79..79f780b654a61f1ba769e2943f501a58dbb737de 100644 (file)
--- a/cpus.c
+++ b/cpus.c
@@ -1483,6 +1483,12 @@ 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);