Skip to contentSkip to conversation

cpus: tcg: fix never exiting loop on unplug

PATCH Applied Cédric Le Goater 2 participants 2 messages Apr 25, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpus: tcg: fix never exiting loop on unplug

Commit 9b0605f9837b ("cpus: tcg: unregister thread with RCU, fix exiting of loop on unplug") changed the exit condition of the loop in the vCPU thread function but forgot to remove the beginning 'while (1)' statement. The resulting code :

	while (1) {
	...
	} while (!cpu->unplug || cpu_can_run(cpu));

is a sequence of two distinct two while() loops, the first not exiting in case of an unplug event.

Remove the first while (1) to fix CPU unplug.

---
 cpus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cpus.c +1 -1
index 38eba8bff334..e1d94038fd0d 100644
@@ -1648,7 +1648,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
     /* process any pending work */
     cpu->exit_request = 1;
 
-    while (1) {
+    do {
         if (cpu_can_run(cpu)) {
             int r;
             qemu_mutex_unlock_iothread();
Signature · 1 line
2.13.6
#1 lore raw
Quoted 25 lines · Cédric Le Goater

Commit 9b0605f9837b ("cpus: tcg: unregister thread with RCU, fix exiting of loop on unplug") changed the exit condition of the loop in the vCPU thread function but forgot to remove the beginning 'while (1)' statement. The resulting code :

	while (1) {
	...
	} while (!cpu->unplug || cpu_can_run(cpu));

is a sequence of two distinct two while() loops, the first not exiting in case of an unplug event.

Remove the first while (1) to fix CPU unplug.

---
 cpus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cpus.c +0 -0
index 38eba8bff334..e1d94038fd0d 100644

cpus.c static void *qemu_tcg_cpu_thread_fn(void *arg) · line 1654

Quoted 8 lines
cpus.c +1 -1
@@ -1648,7 +1648,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
     /* process any pending work */
     cpu->exit_request = 1;
 
-    while (1) {
+    do {
         if (cpu_can_run(cpu)) {
             int r;
             qemu_mutex_unlock_iothread();

Queued, thanks.

Paolo