qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jun Koi <junkoi2004@gmail.com>
To: Stefan Weil <weil@mail.berlios.de>
Cc: Jan Kiszka <jan.kiszka@siemens.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] flush TB on singlestep command
Date: Tue, 20 Apr 2010 10:17:55 +0900	[thread overview]
Message-ID: <o2mfdaac4d51004191817h7158e19dy448b40502839a431@mail.gmail.com> (raw)
In-Reply-To: <4BC8D2E8.3030309@mail.berlios.de>

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 <junkoi2004@gmail.com>


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 = first_cpu; env != NULL; env = env->next_cpu) {
+        tb_flush(env);
+    }
+}
+
 static void do_singlestep(Monitor *mon, const QDict *qdict)
 {
     const char *option = qdict_get_try_str(qdict, "option");
+
     if (!option || !strcmp(option, "on")) {
         singlestep = 1;
+        flush_all_tb();
     } else if (!strcmp(option, "off")) {
         singlestep = 0;
+        flush_all_tb();
     } else {
         monitor_printf(mon, "unexpected option %s\n", option);
     }





On Sat, Apr 17, 2010 at 6:13 AM, Stefan Weil <weil@mail.berlios.de> wrote:
> Jun Koi schrieb:
>> (Thanks to Jan for comments on the last patch)
>>
>> Qemu has a command named singlestep, which reduces the translated code
>> block to be only one instruction.
>> However, there is one flaw when this command is triggered via monitor
>> interface: we do not flush all the current TBs, so we will miss
>> single-step on already translated code.
>> This patch fixes the problem by flushing all the TB to force new code
>> generation.
>>
>> Signed-off-by: Jun Koi <junkoi2004@gmail.com>
>>
>>
>>
>> diff --git a/monitor.c b/monitor.c
>> index 5659991..948b861 100644
>> --- a/monitor.c
>> +++ b/monitor.c
>> @@ -1190,8 +1190,14 @@ static void do_log(Monitor *mon, const QDict
>> *qdict)
>> static void do_singlestep(Monitor *mon, const QDict *qdict)
>> {
>> const char *option = qdict_get_try_str(qdict, "option");
>> + CPUState *env;
>> +
>> if (!option || !strcmp(option, "on")) {
>> singlestep = 1;
>> + /* flush all the TBs to force new code generation */
>> + for (env = first_cpu; env != NULL; env = env->next_cpu) {
>> + tb_flush(env);
>> + }
>> } else if (!strcmp(option, "off")) {
>> singlestep = 0;
>> } else {
>
> Hi,
>
> sorry that my feedback comes rather late. I read the discussion,
> but had no time to answer.
>
> I wrote the code for the singlestep command line and monitor option
> (which already existed before as a compile time option) and still use
> it frequently. Up to now, I did not miss the tb flushing, but I see that
> it might be useful in certain cases.
>
> My typical use cases for "singlestep" are
>
> * Compare execution of same code (usually a user mode program or a kernel)
>  running in different environments (32 bit or 64 bit host, big or little
>  endian host, different host architectures).
>  In combination with -D in_asm,cpu it is possible to find wrong tcg code
>  by comparing the resulting qemu.log files.
>
> * Use singlestep to slow down the execution (yes, this is sometimes useful).
>
> In most cases, I use the command line option, but sometimes I use the
> monitor command, too.
>
> There is no logical relation between switching singlestep on or off and
> tb flushing. If there is the need for tb flush, I'd suggest to add a new
> monitor command.
>
> If the translated tbs should match the singlestep setting,
> you would also have to flush them when singlestep is disabled:
> in that case, the translated tbs only contain a single target instruction,
> so they are not very efficient - and they remain so even after
> singlestep was disabled.
>
> So either flush for singlestep on and off, or better add a new monitor
> command
> which flushes tbs.
>
> Regards,
> Stefan
>
>

  reply	other threads:[~2010-04-20  1:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-16  1:03 [Qemu-devel] [PATCH] flush TB on singlestep command Jun Koi
2010-04-16 21:13 ` Stefan Weil
2010-04-20  1:17   ` Jun Koi [this message]
2010-04-20  7:18     ` [Qemu-devel] " Jan Kiszka
2010-04-20 10:51       ` Alexander Graf
2010-04-20 11:38         ` Jan Kiszka
2010-04-20 11:44           ` Alexander Graf
2010-04-21 10:04             ` Jun Koi
2010-04-21 10:11               ` Alexander Graf
2010-04-21 10:43                 ` Jan Kiszka
2010-04-21 19:20                   ` Stefan Weil
2010-04-22  7:02                     ` Jan Kiszka
2010-04-27 19:55                       ` Stefan Weil
2010-04-27 23:50                         ` Jun Koi
2010-04-28 18:06                           ` Stefan Weil
2010-04-22  7:14                     ` Jun Koi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=o2mfdaac4d51004191817h7158e19dy448b40502839a431@mail.gmail.com \
    --to=junkoi2004@gmail.com \
    --cc=jan.kiszka@siemens.com \
    --cc=qemu-devel@nongnu.org \
    --cc=weil@mail.berlios.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).