From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O4BnJ-0005N1-Cp for qemu-devel@nongnu.org; Tue, 20 Apr 2010 07:39:09 -0400 Received: from [140.186.70.92] (port=33383 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4BnI-0005KD-16 for qemu-devel@nongnu.org; Tue, 20 Apr 2010 07:39:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O4BnE-0002oQ-3n for qemu-devel@nongnu.org; Tue, 20 Apr 2010 07:39:07 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]:55490) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O4BnD-0002nE-OJ for qemu-devel@nongnu.org; Tue, 20 Apr 2010 07:39:04 -0400 Message-ID: <4BCD924D.1080909@web.de> Date: Tue, 20 Apr 2010 13:38:53 +0200 From: Jan Kiszka MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [PATCH] flush TB on singlestep command References: <4BC8D2E8.3030309@mail.berlios.de> <4BCD5560.6070004@web.de> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig691833910B1D3E7A2888CAE5" Sender: jan.kiszka@web.de List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: qemu-devel@nongnu.org, Jun Koi This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig691833910B1D3E7A2888CAE5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Alexander Graf wrote: > On 20.04.2010, at 09:18, Jan Kiszka wrote: >=20 >> Jun Koi wrote: >>> Thank you for the explanation of this code. >>> >>> Qemu has a command named singlestep, which reduces the translated cod= e >>> block to be only one instruction. >>> This new patch flushes TBs both when singlestep is on and off. >>> >>> Signed-off-by: Jun Koi >>> >>> >>> diff --git a/monitor.c b/monitor.c >>> index 5659991..2b2005b 100644 >>> --- a/monitor.c >>> +++ b/monitor.c >>> @@ -1187,13 +1187,26 @@ static void do_log(Monitor *mon, const QDict = *qdict) >>> cpu_set_log(mask); >>> } >>> >>> +/* flush all the TBs to force new code generation */ >>> +static void flush_all_tb(void) >>> +{ >>> + CPUState *env; >>> + >>> + for (env =3D first_cpu; env !=3D NULL; env =3D env->next_cpu) { >>> + tb_flush(env); >>> + } >>> +} >>> + >> The smaller your patch are, the more people pick on it. :) >> >> I was about to suggest moving this close to tb_flush, but then I >> realized that the env argument of that service is misleading. In fact,= >> it already flushes the one and only translation buffer pool. >> >>> static void do_singlestep(Monitor *mon, const QDict *qdict) >>> { >>> const char *option =3D qdict_get_try_str(qdict, "option"); >>> + >>> if (!option || !strcmp(option, "on")) { >>> singlestep =3D 1; >>> + flush_all_tb(); >>> } else if (!strcmp(option, "off")) { >>> singlestep =3D 0; >>> + flush_all_tb(); >>> } else { >>> monitor_printf(mon, "unexpected option %s\n", option); >>> } >>> >> Let's just pass mon->mon_cpu to tb_flush and skip the redundant loop. >=20 > That doesn't help, no? singlestep is a global variable. Flushing only t= he current vcpu would still not affect the others, while the singlestep s= witch would. tb_flush uses env only to dump some state when a problem occurred. >=20 > According to your above comment the cache is global, but I don't think = we should rely on that. It might make sense to define some tb_flush_all() as tb_flush(first_cpu) for now to establish the infrastructure. Then we are prepared for the day the tb_flush implementation may change. Jan --------------enig691833910B1D3E7A2888CAE5 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 iEYEARECAAYFAkvNklQACgkQitSsb3rl5xRGYgCgyoUiFLuC8CTA25jbMuWln/7A FA0AoIyong+N20dPaXTifw9Kf1k39noj =dSn5 -----END PGP SIGNATURE----- --------------enig691833910B1D3E7A2888CAE5--