From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:49455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q9v3j-0004js-Bi for qemu-devel@nongnu.org; Wed, 13 Apr 2011 04:04:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q9v3d-0005N6-J8 for qemu-devel@nongnu.org; Wed, 13 Apr 2011 04:04:19 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:43652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q9v3d-0005N1-FU for qemu-devel@nongnu.org; Wed, 13 Apr 2011 04:04:13 -0400 Received: by ywl41 with SMTP id 41so201258ywl.4 for ; Wed, 13 Apr 2011 01:04:12 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 13 Apr 2011 10:03:43 +0200 Message-Id: <1302681826-10236-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1302681826-10236-1-git-send-email-pbonzini@redhat.com> References: <1302681826-10236-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v4 1/4] really fix -icount in the iothread case List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: edgar.iglesias@gmail.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 Tested-by: Edgar E. Iglesias --- 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