qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] slirp: Signal free input buffer space to io-thread
Date: Fri, 30 Mar 2012 20:37:29 +0200	[thread overview]
Message-ID: <4F75FD69.8060803@redhat.com> (raw)
In-Reply-To: <4F75F0C1.2070403@siemens.com>

Il 30/03/2012 19:43, Jan Kiszka ha scritto:
> This massively accelerates slirp reception speed: If data arrives
> faster than the guest can read it from the input buffer, the file
> descriptor for the corresponding socket was taken out of the fdset for
> select. However, the event of the guest reading enough data from the
> buffer was not signaled. Thus, the io-thread only noticed this change
> on the next time-driven poll. Fix this by kicking the io-thread as
> required.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> 
> Hell, this was really annoying when working with slirp, specifically
> with KVM irqchip enabled (as it reduces userspace exits). But I never
> really found the time to dig deep enough. And now it turned out to be
> so simple! http://thread.gmane.org/gmane.comp.emulators.qemu/141975 was
> the key for me.
> 
>  slirp/sbuf.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/slirp/sbuf.c b/slirp/sbuf.c
> index 5a1ccbf..637f8fe 100644
> --- a/slirp/sbuf.c
> +++ b/slirp/sbuf.c
> @@ -6,6 +6,7 @@
>   */
>  
>  #include <slirp.h>
> +#include <main-loop.h>
>  
>  static void sbappendsb(struct sbuf *sb, struct mbuf *m);
>  
> @@ -18,6 +19,8 @@ sbfree(struct sbuf *sb)
>  void
>  sbdrop(struct sbuf *sb, int num)
>  {
> +    int limit = sb->sb_datalen / 2;
> +
>  	/*
>  	 * We can only drop how much we have
>  	 * This should never succeed
> @@ -29,6 +32,9 @@ sbdrop(struct sbuf *sb, int num)
>  	if(sb->sb_rptr >= sb->sb_data + sb->sb_datalen)
>  		sb->sb_rptr -= sb->sb_datalen;
>  
> +    if (sb->sb_cc < limit && sb->sb_cc + num >= limit) {
> +        qemu_notify_event();
> +    }
>  }
>  
>  void

Looks good!

Paolo

      reply	other threads:[~2012-03-30 18:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-30 17:43 [Qemu-devel] [PATCH] slirp: Signal free input buffer space to io-thread Jan Kiszka
2012-03-30 18:37 ` Paolo Bonzini [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=4F75FD69.8060803@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=jan.kiszka@siemens.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).