qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: malc <av1474@comtv.ru>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] fix 100% cpu utilization when cpu is stopped (was Re: d6f4ade214a9f74dca9495b83a24ff9c113e4f9a)
Date: Tue, 06 Apr 2010 22:16:05 +0200	[thread overview]
Message-ID: <4BBB9685.9090801@redhat.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1004051747280.12421@linmac>

On 04/05/2010 03:51 PM, malc wrote:
> Hello,
>
> d6f4ade214a9f74dca9495b83a24ff9c113e4f9a: disentangle tcg and deadline calculation
> introduces following regression(s):
>
> 100% cpu utilization when QEMU is invoked like:
> qemu -S -s ...
>
> ditto when gdb takes control over the session via gdb-stub
> (i.e. the breakpoint is hit or C-c is pressed inside gdb to
>   interrupt the attached qemu instance)

The bug is that env->stopped is not really as comprehensive as it seems 
to be (and cpu_has_work thinks); it is only valid with iothread 
basically, and even then it is cleared by reset and it is not set when 
starting qemu with -S.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

diff --git a/cpus.c b/cpus.c
index a2e0642..0debe77 100644
--- a/cpus.c
+++ b/cpus.c
@@ -100,9 +100,7 @@ static int cpu_can_run(CPUState *env)
  {
      if (env->stop)
          return 0;
-    if (env->stopped)
-        return 0;
-    if (!vm_running)
+    if (env->stopped || !vm_running)
          return 0;
      return 1;
  }
@@ -111,7 +109,7 @@ static int cpu_has_work(CPUState *env)
  {
      if (env->stop)
          return 1;
-    if (env->stopped)
+    if (env->stopped || !vm_running)
          return 0;
      if (!env->halted)
          return 1;

  reply	other threads:[~2010-04-06 20:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-05 13:51 [Qemu-devel] d6f4ade214a9f74dca9495b83a24ff9c113e4f9a malc
2010-04-06 20:16 ` Paolo Bonzini [this message]
2010-04-06 21:17   ` [Qemu-devel] Re: [PATCH] fix 100% cpu utilization when cpu is stopped (was Re: d6f4ade214a9f74dca9495b83a24ff9c113e4f9a) malc
2010-04-06 22:11     ` [Qemu-devel] [PATCH resend] fix 100% cpu utilization when cpu is stopped Paolo Bonzini

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=4BBB9685.9090801@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=av1474@comtv.ru \
    --cc=qemu-devel@nongnu.org \
    /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).