Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O4B3H-0004X5-NO for qemu-devel@nongnu.org; Tue, 20 Apr 2010 06:51:35 -0400 Received: from [140.186.70.92] (port=50158 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4B3F-0004Wv-B2 for qemu-devel@nongnu.org; Tue, 20 Apr 2010 06:51:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O4B3C-0002ac-Ty for qemu-devel@nongnu.org; Tue, 20 Apr 2010 06:51:33 -0400 Received: from cantor2.suse.de ([195.135.220.15]:58426 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O4B3C-0002aD-OU for qemu-devel@nongnu.org; Tue, 20 Apr 2010 06:51:30 -0400 Subject: Re: [Qemu-devel] Re: [PATCH] flush TB on singlestep command Mime-Version: 1.0 (Apple Message framework v1078) Content-Type: text/plain; charset=us-ascii From: Alexander Graf In-Reply-To: <4BCD5560.6070004@web.de> Date: Tue, 20 Apr 2010 12:51:26 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <4BC8D2E8.3030309@mail.berlios.de> <4BCD5560.6070004@web.de> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: qemu-devel@nongnu.org, Jun Koi On 20.04.2010, at 09:18, Jan Kiszka wrote: > Jun Koi wrote: >> Thank you for the explanation of this code. >>=20 >> Qemu has a command named singlestep, which reduces the translated = code >> block to be only one instruction. >> This new patch flushes TBs both when singlestep is on and off. >>=20 >> Signed-off-by: Jun Koi >>=20 >>=20 >> 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); >> } >>=20 >> +/* 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); >> + } >> +} >> + >=20 > The smaller your patch are, the more people pick on it. :) >=20 > 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. >=20 >> 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); >> } >>=20 >=20 > Let's just pass mon->mon_cpu to tb_flush and skip the redundant loop. That doesn't help, no? singlestep is a global variable. Flushing only = the current vcpu would still not affect the others, while the singlestep = switch would. According to your above comment the cache is global, but I don't think = we should rely on that. Alex