qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] cpus: tcg: fix never exiting loop on unplug
@ 2018-04-25 13:18 Cédric Le Goater
  2018-04-25 13:30 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Cédric Le Goater @ 2018-04-25 13:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Peter Maydell, David Gibson, 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.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 cpus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpus.c b/cpus.c
index 38eba8bff334..e1d94038fd0d 100644
--- a/cpus.c
+++ b/cpus.c
@@ -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();
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] cpus: tcg: fix never exiting loop on unplug
  2018-04-25 13:18 [Qemu-devel] [PATCH] cpus: tcg: fix never exiting loop on unplug Cédric Le Goater
@ 2018-04-25 13:30 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2018-04-25 13:30 UTC (permalink / raw)
  To: Cédric Le Goater, qemu-devel
  Cc: Peter Maydell, David Gibson, qemu-stable

On 25/04/2018 15:18, Cédric Le Goater wrote:
> 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.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  cpus.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/cpus.c b/cpus.c
> index 38eba8bff334..e1d94038fd0d 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -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();
> 

Cc: qemu-stable@nongnu.org

Queued, thanks.

Paolo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-04-25 13:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-25 13:18 [Qemu-devel] [PATCH] cpus: tcg: fix never exiting loop on unplug Cédric Le Goater
2018-04-25 13:30 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).