1. 15 4月, 2011 2 次提交
    • P
      enable vm_clock to "warp" in the iothread+icount case · ab33fcda
      Paolo Bonzini 提交于
      The previous patch however is not enough, because if the virtual CPU
      goes to sleep waiting for a future timer interrupt to wake it up, qemu
      deadlocks.  The timer interrupt never comes because time is driven by
      icount, but the vCPU doesn't run any insns.
      
      You could say that VCPUs should never go to sleep in icount
      mode if there is a pending vm_clock timer; rather time should
      just warp to the next vm_clock event with no sleep ever taking place.
      Even better, you can sleep for some time related to the
      time left until the next event, to avoid that the warps are too visible
      externally; for example, you could be sending network packets continously
      instead of every 100ms.
      
      This is what this patch implements.  qemu_clock_warp is called: 1)
      whenever a vm_clock timer is adjusted, to ensure the warp_timer is
      synchronized; 2) at strategic points in the CPU thread, to make sure
      the insn counter is synchronized before the CPU starts running.
      In any case, the warp_timer is disabled while the CPU is running,
      because the insn counter will then be making progress on its own.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Tested-by: NEdgar E. Iglesias <edgar.iglesias@gmail.com>
      Signed-off-by: NEdgar E. Iglesias <edgar.iglesias@gmail.com>
      ab33fcda
    • P
      really fix -icount in the iothread case · 3b2319a3
      Paolo Bonzini 提交于
      The correct fix for -icount is to consider the biggest difference
      between iothread and non-iothread modes.  In the traditional model,
      CPUs run _before_ the iothread calls select (or WaitForMultipleObjects
      for Win32).  In the iothread model, CPUs run while the iothread
      isn't holding the mutex, i.e. _during_ those same calls.
      
      So, the iothread should always block as long as possible to let
      the CPUs run smoothly---the timeout might as well be infinite---and
      either the OS or the CPU thread itself will let the iothread know
      when something happens.  At this point, the iothread wakes up and
      interrupts the CPU.
      
      This is exactly the approach that this patch takes: when cpu_exec_all
      returns in -icount mode, and it is because a vm_clock deadline has
      been met, it wakes up the iothread to process the timers.  This is
      really the "bulk" of fixing icount.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Tested-by: NEdgar E. Iglesias <edgar.iglesias@gmail.com>
      Signed-off-by: NEdgar E. Iglesias <edgar.iglesias@gmail.com>
      3b2319a3
  2. 14 4月, 2011 2 次提交
  3. 13 4月, 2011 36 次提交