Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O4qdB-0001J2-T8 for qemu-devel@nongnu.org; Thu, 22 Apr 2010 03:15:25 -0400 Received: from [140.186.70.92] (port=40266 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4qd5-0001EM-Fo for qemu-devel@nongnu.org; Thu, 22 Apr 2010 03:15:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O4qcu-0006gd-NZ for qemu-devel@nongnu.org; Thu, 22 Apr 2010 03:15:12 -0400 Received: from mail-iw0-f192.google.com ([209.85.223.192]:47201) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O4qct-0006ed-Gl for qemu-devel@nongnu.org; Thu, 22 Apr 2010 03:15:07 -0400 Received: by iwn30 with SMTP id 30so5518338iwn.28 for ; Thu, 22 Apr 2010 00:15:01 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4BCF4FE2.50401@mail.berlios.de> References: <4BCD5560.6070004@web.de> <4BCD924D.1080909@web.de> <40763F40-E48C-4380-94E0-E637F00A5C81@suse.de> <297C546E-0AE2-4EAD-AEAA-3FABAB7786FA@suse.de> <4BCED6C6.4070509@web.de> <4BCF4FE2.50401@mail.berlios.de> From: Jun Koi Date: Thu, 22 Apr 2010 16:14:40 +0900 Message-ID: Subject: Re: [Qemu-devel] Re: [PATCH] flush TB on singlestep command Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: Jan Kiszka , Alexander Graf , qemu-devel@nongnu.org On Thu, Apr 22, 2010 at 4:20 AM, Stefan Weil wrote: > Jan Kiszka schrieb: >> Alexander Graf wrote: >> >>> On 21.04.2010, at 12:04, Jun Koi wrote: >>> >>> >>>> On Tue, Apr 20, 2010 at 8:44 PM, Alexander Graf wrote: >>>> >>>>> On 20.04.2010, at 13:38, Jan Kiszka wrote: >>>>> >>>>> >>>>>> Alexander Graf wrote: >>>>>> >>>>>>> On 20.04.2010, at 09:18, Jan Kiszka wrote: >>>>>>> >>>>>>> >>>>>>>> Jun Koi wrote: >>>>>>>> >>>>>>>>> Thank you for the explanation of this code. >>>>>>>>> >>>>>>>>> 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. >>>>>>>>> >>>>>>>>> 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 QD= ict *qdict) >>>>>>>>> =A0 =A0cpu_set_log(mask); >>>>>>>>> } >>>>>>>>> >>>>>>>>> +/* flush all the TBs to force new code generation */ >>>>>>>>> +static void flush_all_tb(void) >>>>>>>>> +{ >>>>>>>>> + =A0 =A0CPUState *env; >>>>>>>>> + >>>>>>>>> + =A0 =A0for (env =3D first_cpu; env !=3D NULL; env =3D env->next= _cpu) { >>>>>>>>> + =A0 =A0 =A0 =A0tb_flush(env); >>>>>>>>> + =A0 =A0} >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> >>>>>>>> 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 f= act, >>>>>>>> it already flushes the one and only translation buffer pool. >>>>>>>> >>>>>>>> >>>>>>>>> static void do_singlestep(Monitor *mon, const QDict *qdict) >>>>>>>>> { >>>>>>>>> =A0 =A0const char *option =3D qdict_get_try_str(qdict, "option"); >>>>>>>>> + >>>>>>>>> =A0 =A0if (!option || !strcmp(option, "on")) { >>>>>>>>> =A0 =A0 =A0 =A0singlestep =3D 1; >>>>>>>>> + =A0 =A0 =A0 =A0flush_all_tb(); >>>>>>>>> =A0 =A0} else if (!strcmp(option, "off")) { >>>>>>>>> =A0 =A0 =A0 =A0singlestep =3D 0; >>>>>>>>> + =A0 =A0 =A0 =A0flush_all_tb(); >>>>>>>>> =A0 =A0} else { >>>>>>>>> =A0 =A0 =A0 =A0monitor_printf(mon, "unexpected option %s\n", opti= on); >>>>>>>>> =A0 =A0} >>>>>>>>> >>>>>>>>> >>>>>>>> Let's just pass mon->mon_cpu to tb_flush and skip the redundant lo= op. >>>>>>>> >>>>>>> That doesn't help, no? singlestep is a global variable. Flushing on= ly the current vcpu would still not affect the others, while the singlestep= switch would. >>>>>>> >>>>>> tb_flush uses env only to dump some state when a problem occurred. >>>>>> >>>>>> >>>>>>> According to your above comment the cache is global, but I don't th= ink 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 th= e >>>>>> day the tb_flush implementation may change. >>>>>> >>>>> Right. But then the call to tb_flush_all here is still correct. >>>>> >>>> So what is the final solution do you want? >>>> >>>> I still think that having flush_all_tb() like in the last patch is goo= d enough. >>>> >>> I agree. And I like the patch as is. >>> >>> Acked-by: Alexander Graf >>> >>> >> >> Sorry, nack for keeping this service in /monitor.c/. But a bonus ack if >> you avoid the needless loop when moving it to exec.c, adding a comment >> that current tb_flush has global, env-invariant scope. >> >> Thanks, >> Jan > > flush_all_tb() is now called for singlestep on and off, that's fine. > But it's called always - no way to disable this call. That's not good. > Sometimes I don't want to flush all TBs when I switch singlestep mode When dont you want to flush TBs?? Thanks, J