From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=43513 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PpzEd-0007y8-3l for qemu-devel@nongnu.org; Thu, 17 Feb 2011 03:29:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PpzEc-0002S0-33 for qemu-devel@nongnu.org; Thu, 17 Feb 2011 03:29:11 -0500 Received: from fmmailgate02.web.de ([217.72.192.227]:33680) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PpzEb-0002Rl-OD for qemu-devel@nongnu.org; Thu, 17 Feb 2011 03:29:10 -0500 Message-ID: <4D5CDC51.8020702@web.de> Date: Thu, 17 Feb 2011 09:29:05 +0100 From: Jan Kiszka MIME-Version: 1.0 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> <4D5B99A9.1010404@redhat.com> <20110217031538.GA22552@amt.cnet> In-Reply-To: <20110217031538.GA22552@amt.cnet> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigBF852FE2F8CA6A66487DB013" Sender: jan.kiszka@web.de Subject: [Qemu-devel] Re: [PATCH] fix halt emulation with icount and CONFIG_IOTHREAD (v2) List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcelo Tosatti Cc: Paolo Bonzini , "qemu-devel@nongnu.org" , "Edgar E. Iglesias" This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigBF852FE2F8CA6A66487DB013 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2011-02-17 04:15, Marcelo Tosatti wrote: > On Wed, Feb 16, 2011 at 10:32:25AM +0100, Paolo Bonzini wrote: >> 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 inco= rrect. >> >> 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: >> >> 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 =3D cpu_exec_all(); >> if (vm_request_pending()) { >> nonblocking =3D true; >> >> 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(). >=20 > Yes, using qemu_icount_delta directly in tcg_wait_io_event timedwait=20 > is explicit (partially the reason for confusion with my patch). >=20 > So the reasoning for the patch is: >=20 > 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. >=20 > So instead vm_timer expiration is converted to realtime, and used as > halt timeout. The changing the calculation is trying to cure a symptom. A halt with timeout is already broken, but we fortunately have a patch against that. Let's shake potential remaining bugs out of *that*. Jan --------------enigBF852FE2F8CA6A66487DB013 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iEYEARECAAYFAk1c3FEACgkQitSsb3rl5xS4MgCgsOk8DcJv9bnTYeY8hNlG1kUA m+UAoJAbuzeW7BJIT3EkF3bs8oj61AgF =cMXP -----END PGP SIGNATURE----- --------------enigBF852FE2F8CA6A66487DB013--