On 02/17/2011 04:15 AM, Marcelo Tosatti wrote:
Yes, using qemu_icount_delta directly in tcg_wait_io_event timedwait
is explicit (partially the reason for confusion with my patch).

So the reasoning for the patch is:

With icount vm_timer timers expire on virtual CPU time. If a CPU halts,
you cannot expect passage of realtime to trigger vm_timers expiration.

But if a CPU is halted, all_cpu_threads_idle() will still be true even if you signal the condition variable, and you'll be looping in the while condition. That's why I say that

   while (x) {
       cond_timedwait (cond, mutex);
   }

(i.e. without checking the return value of cond_timedwait, and without polling something else upon return) is a broken idiom that can only work around missing signals/broadcasts.

So instead vm_timer expiration is converted to realtime, and used as
halt timeout.

But vm_timer timers are only used by "-icount auto", which works in my tests [*]. It is "-icount N" which is broken and unfortunately your patch does not fix it. The CRIS image on qemu.org triggers the watchdog (and if I eliminate the watchdog I see that the CPU is hung).

    [*] Actually, it works but doesn't calibrate very well.  It shows
        25 bogomips, sometimes 50, compared to 250 without iothread.

Paolo

Reply via email to