qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: edgar.iglesias@gmail.com
Subject: [Qemu-devel] [PATCH v4 1/4] really fix -icount in the iothread case
Date: Wed, 13 Apr 2011 10:03:43 +0200	[thread overview]
Message-ID: <1302681826-10236-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1302681826-10236-1-git-send-email-pbonzini@redhat.com>

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: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
---
 cpus.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/cpus.c b/cpus.c
index 41bec7c..cbeac7a 100644
--- a/cpus.c
+++ b/cpus.c
@@ -830,6 +830,9 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
 
     while (1) {
         cpu_exec_all();
+        if (use_icount && qemu_next_deadline() <= 0) {
+            qemu_notify_event();
+        }
         qemu_tcg_wait_io_event();
     }
 
-- 
1.7.4

  reply	other threads:[~2011-04-13  8:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-13  8:03 [Qemu-devel] [PATCH v4 0/4] Fix -icount with iothread Paolo Bonzini
2011-04-13  8:03 ` Paolo Bonzini [this message]
2011-04-13  8:03 ` [Qemu-devel] [PATCH v4 2/4] enable vm_clock to "warp" in the iothread+icount case Paolo Bonzini
2011-04-13  8:03 ` [Qemu-devel] [PATCH v4 3/4] Revert wrong fixes for -icount in the iothread case Paolo Bonzini
2011-04-13  8:03 ` [Qemu-devel] [PATCH v4 4/4] qemu_next_deadline should not consider host-time timers Paolo Bonzini
2011-04-15  7:49 ` [Qemu-devel] [PATCH v4 0/4] Fix -icount with iothread Edgar E. Iglesias
2011-04-15 10:18   ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1302681826-10236-2-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).