From patchwork Wed Feb 16 09:32:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 83350 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6B13BB711A for ; Wed, 16 Feb 2011 20:33:50 +1100 (EST) Received: from localhost ([127.0.0.1]:38664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ppdlb-00064P-LP for incoming@patchwork.ozlabs.org; Wed, 16 Feb 2011 04:33:47 -0500 Received: from [140.186.70.92] (port=49343 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PpdkO-00062h-3O for qemu-devel@nongnu.org; Wed, 16 Feb 2011 04:32:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PpdkN-0002OG-5A for qemu-devel@nongnu.org; Wed, 16 Feb 2011 04:32:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PpdkM-0002Ny-Ur for qemu-devel@nongnu.org; Wed, 16 Feb 2011 04:32:31 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p1G9WReD022934 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 16 Feb 2011 04:32:27 -0500 Received: from yakj.usersys.redhat.com (dhcp-176-234.mxp.redhat.com [10.32.176.234]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p1G9WQrR031860; Wed, 16 Feb 2011 04:32:26 -0500 Message-ID: <4D5B99A9.1010404@redhat.com> Date: Wed, 16 Feb 2011 10:32:25 +0100 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7 MIME-Version: 1.0 To: Marcelo Tosatti References: <20110215175410.GA13487@amt.cnet> <4D5ACCED.1080906@siemens.com> <20110215200446.GA15802@amt.cnet> <4D5AE2FC.4020309@web.de> <20110215205504.GA16527@amt.cnet> <20110215205631.GA16579@amt.cnet> In-Reply-To: <20110215205631.GA16579@amt.cnet> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: "Edgar E. Iglesias" , Jan Kiszka , "qemu-devel@nongnu.org" Subject: [Qemu-devel] Re: [PATCH] fix halt emulation with icount and CONFIG_IOTHREAD (v2) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On 02/15/2011 09:56 PM, Marcelo Tosatti wrote: > Note: to be applied to uq/master. > > In icount mode, halt emulation should take into account the nearest > event when sleeping. I agree with Jan that this patch is not the best solution, if not incorrect. However, in the iothread, the main loop can kick the VCPU thread instead of running cpu_exec_all like it does in non-iothread mode. Something like this: I don't like this 100% because it relies on the fact that there is only one TCG execution thread. In a multithreaded world you would: 1) have each CPU register its own instruction counter; 2) have each CPU register its own QEMU_CLOCK_REALTIME timer based on qemu_icount_delta() and arm it just before going to sleep; the timer kicks the CPU. 3) remove all icount business from qemu_calculate_timeout. Item (3) is what makes me prefer my patch above (if it works) to Marcelo's. Marcelo's patch is tying even more qemu_calculate_timeout to the icount. So if anything, a patch tweaking the timedwait like Marcelo's should use something based on qemu_icount_delta(). Paolo diff --git a/vl.c b/vl.c index b436952..7835317 100644 --- a/vl.c +++ b/vl.c @@ -1425,7 +1425,9 @@ static void main_loop(void) qemu_main_loop_start(); for (;;) { -#ifndef CONFIG_IOTHREAD +#ifdef CONFIG_IOTHREAD + qemu_cpu_kick(first_cpu); +#else nonblocking = cpu_exec_all(); if (vm_request_pending()) { nonblocking = true;