From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LyvtQ-0003Tw-AA for qemu-devel@nongnu.org; Tue, 28 Apr 2009 18:35:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LyvtK-0003SO-QX for qemu-devel@nongnu.org; Tue, 28 Apr 2009 18:35:10 -0400 Received: from [199.232.76.173] (port=47081 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LyvtK-0003SI-IC for qemu-devel@nongnu.org; Tue, 28 Apr 2009 18:35:06 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]:41533) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LyvtJ-00082h-Sj for qemu-devel@nongnu.org; Tue, 28 Apr 2009 18:35:06 -0400 Message-ID: <49F7848F.7020708@web.de> Date: Wed, 29 Apr 2009 00:34:55 +0200 From: Jan Kiszka MIME-Version: 1.0 References: In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig22D2D3177B8D4CB9713F0F8D" Sender: jan.kiszka@web.de Subject: [Qemu-devel] Re: [7241] qemu: refactor main_loop (Marcelo Tosatti) List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori , Marcelo Tosatti Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig22D2D3177B8D4CB9713F0F8D Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Anthony Liguori wrote: > Revision: 7241 > http://svn.sv.gnu.org/viewvc/?view=3Drev&root=3Dqemu&revision= =3D7241 > Author: aliguori > Date: 2009-04-24 18:03:33 +0000 (Fri, 24 Apr 2009) > Log Message: > ----------- > qemu: refactor main_loop (Marcelo Tosatti) >=20 > Break main loop into 3 main functions. I suspect this patch comes with a race between SIGALRM and qemu_calculate_timeout() so that I see occasional freezes of exactly 5 seconds if the IO thread is disabled. I do not yet understand what happens precisely or if this patch only widens an already existing race window in the old code, but I'm on it. Besides that... >=20 > Signed-off-by: Marcelo Tosatti > Signed-off-by: Anthony Liguori >=20 > Modified Paths: > -------------- > trunk/vl.c >=20 > Modified: trunk/vl.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- trunk/vl.c 2009-04-24 18:03:29 UTC (rev 7240) > +++ trunk/vl.c 2009-04-24 18:03:33 UTC (rev 7241) > @@ -273,7 +273,7 @@ > =20 > static CPUState *cur_cpu; > static CPUState *next_cpu; > -static int event_pending =3D 1; > +static int timer_alarm_pending =3D 1; > /* Conversion factor from emulated instructions to virtual clock ticks= =2E */ > static int icount_time_shift; > /* Arbitrarily pick 1MIPS as the minimum allowable speed. */ > @@ -1360,7 +1360,7 @@ > } > #endif > } > - event_pending =3D 1; > + timer_alarm_pending =3D 1; > qemu_notify_event(); > } > } > @@ -3879,153 +3879,175 @@ > =20 > } > =20 > -static int main_loop(void) > +static int qemu_cpu_exec(CPUState *env) > { > - int ret, timeout; > + int ret; > #ifdef CONFIG_PROFILER > int64_t ti; > #endif > + > +#ifdef CONFIG_PROFILER > + ti =3D profile_getclock(); > +#endif > + if (use_icount) { > + int64_t count; > + int decr; > + qemu_icount -=3D (env->icount_decr.u16.low + env->icount_extra= ); > + env->icount_decr.u16.low =3D 0; > + env->icount_extra =3D 0; > + count =3D qemu_next_deadline(); > + count =3D (count + (1 << icount_time_shift) - 1) > + >> icount_time_shift; > + qemu_icount +=3D count; > + decr =3D (count > 0xffff) ? 0xffff : count; > + count -=3D decr; > + env->icount_decr.u16.low =3D decr; > + env->icount_extra =3D count; > + } > + ret =3D cpu_exec(env); > +#ifdef CONFIG_PROFILER > + qemu_time +=3D profile_getclock() - ti; > +#endif > + if (use_icount) { > + /* Fold pending instructions back into the > + instruction counter, and clear the interrupt flag. */ > + qemu_icount -=3D (env->icount_decr.u16.low > + + env->icount_extra); > + env->icount_decr.u32 =3D 0; > + env->icount_extra =3D 0; > + } > + return ret; > +} > + > +static int cpu_has_work(CPUState *env) =2E..this naming is suboptimal. There is already cpu_has_work() in target-*/exec.h which is at least confusing. Please rename. Jan --------------enig22D2D3177B8D4CB9713F0F8D 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.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkn3hJcACgkQniDOoMHTA+maZACfQjdjnYRi+RTAr9otl3+9Dpbi LgEAn3/iWP4IDmT2fIA11jbi0crj85FS =J5/w -----END PGP SIGNATURE----- --------------enig22D2D3177B8D4CB9713F0F8D--