qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Chris Friesen <chris.friesen@windriver.com>
Cc: Amit Shah <amit.shah@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [bug] busy-loop in send_all()
Date: Fri, 23 May 2014 13:55:40 +0200	[thread overview]
Message-ID: <20140523115540.GC1260@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <5374F82A.7050205@windriver.com>

On Thu, May 15, 2014 at 11:23:54AM -0600, Chris Friesen wrote:
> I've run into a situation that seems like a bug.  I'm using qemu 1.4.2 (with
> additional patches) from within openstack.
> 
> I'm using virtio-serial-pci to provide a channel between the guest and host.
> 
> On occasion when doing suspend/resume I run into a case where the main qemu
> thread ends up chewing 100% of a cpu.
> 
> I attached strace to the thread and it showed qemu just spitting messages:
> 
> write(35, "HRBT\0\1\0\3d<\230k\0\0\0\0\0\0\1\330\0\0\0\0enqueue\0"..., 472)
> = -1 EAGAIN (Resource temporarily unavailable)
> write(35, "HRBT\0\1\0\3d<\230k\0\0\0\0\0\0\1\330\0\0\0\0enqueue\0"..., 472)
> = -1 EAGAIN (Resource temporarily unavailable)
> write(35, "HRBT\0\1\0\3d<\230k\0\0\0\0\0\0\1\330\0\0\0\0enqueue\0"..., 472)
> = -1 EAGAIN (Resource temporarily unavailable)
> write(35, "HRBT\0\1\0\3d<\230k\0\0\0\0\0\0\1\330\0\0\0\0enqueue\0"..., 472)
> = -1 EAGAIN (Resource temporarily unavailable)
> 
> File descriptor 35 is the unix socket corresponding to the virtio-serial
> port.
> 
> I broke in with gdb and got a backtrace showing it was in send_all().
> Looking at the implementation of send_all(), the core loop looks like:
> 
>      while (len > 0) {
>          ret = write(fd, buf, len);
>          if (ret < 0) {
>              if (errno != EINTR && errno != EAGAIN)
>                  return -1;
>          } else if (ret == 0) {
>              break;
>          } else {
>              buf += ret;
>              len -= ret;
>          }
>      }
> 
> 
> So if we get EAGAIN, we'll just immediately retry.
> 
> I'm not sure where the unix socket would get opened, but I'm assuming it's
> set as non-blocking?  And by default /proc/sys/net/unix/max_dgram_qlen is
> set to 10.
> 
> So if the other end of that unix socket is connected but isn't actually
> paying attention to the messages then the first 10 messages will get
> buffered but after that we'll end up with qemu spinning forever in a
> busy-loop trying to send a message into a full buffer.
> 
> This seems less than ideal.  Either we should block, or else we should
> discard the data.  And I don't think discarding the data makes sense.

CCed Amit Shah for virtio-serial.

Stefan

      reply	other threads:[~2014-05-23 11:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-15 17:23 [Qemu-devel] [bug] busy-loop in send_all() Chris Friesen
2014-05-23 11:55 ` Stefan Hajnoczi [this message]

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=20140523115540.GC1260@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=amit.shah@redhat.com \
    --cc=chris.friesen@windriver.com \
    --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).