Patchwork fix halt emulation with icount and CONFIG_IOTHREAD (v2)

login
register
mail settings
Submitter Marcelo Tosatti
Date Feb. 15, 2011, 8:56 p.m.
Message ID <20110215205631.GA16579@amt.cnet>
Download mbox | patch
Permalink /patch/83300/
State New
Headers show

Comments

Marcelo Tosatti - Feb. 15, 2011, 8:56 p.m.
Note: to be applied to uq/master.

In icount mode, halt emulation should take into account the nearest event when sleeping.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Reported-and-tested-by: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Jan Kiszka - Feb. 16, 2011, 8:27 a.m.
On 2011-02-15 21:56, Marcelo Tosatti wrote:
> Note: to be applied to uq/master.
> 
> In icount mode, halt emulation should take into account the nearest event when sleeping.
> 
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> Reported-and-tested-by: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> 
> diff --git a/cpus.c b/cpus.c
> index 468544c..21c3eba 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -770,7 +770,7 @@ static void qemu_tcg_wait_io_event(void)
>      CPUState *env;
>  
>      while (all_cpu_threads_idle()) {
> -        qemu_cond_timedwait(tcg_halt_cond, &qemu_global_mutex, 1000);
> +        qemu_cond_timedwait(tcg_halt_cond, &qemu_global_mutex, qemu_calculate_timeout());
>      }
>  
>      qemu_mutex_unlock(&qemu_global_mutex);

As we agree that timeouts are wrong here, let's check if Paolo's patches
make a difference.

If not, it would still be better to understand the actual issue. After
trying too many voodoo patches myself, I've finally found that mutex
ping pong between iothread and vcpus by starring at a trace in kernelshark.

Jan

Patch

diff --git a/cpus.c b/cpus.c
index 468544c..21c3eba 100644
--- a/cpus.c
+++ b/cpus.c
@@ -770,7 +770,7 @@  static void qemu_tcg_wait_io_event(void)
     CPUState *env;
 
     while (all_cpu_threads_idle()) {
-        qemu_cond_timedwait(tcg_halt_cond, &qemu_global_mutex, 1000);
+        qemu_cond_timedwait(tcg_halt_cond, &qemu_global_mutex, qemu_calculate_timeout());
     }
 
     qemu_mutex_unlock(&qemu_global_mutex);