From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDfrP-0006mH-H7 for qemu-devel@nongnu.org; Fri, 30 Mar 2012 13:43:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SDfrK-0005NN-JF for qemu-devel@nongnu.org; Fri, 30 Mar 2012 13:43:39 -0400 Received: from thoth.sbs.de ([192.35.17.2]:27309) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDfrK-0005Mw-98 for qemu-devel@nongnu.org; Fri, 30 Mar 2012 13:43:34 -0400 Message-ID: <4F75F0C1.2070403@siemens.com> Date: Fri, 30 Mar 2012 19:43:29 +0200 From: Jan Kiszka MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] slirp: Signal free input buffer space to io-thread List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Cc: Paolo Bonzini 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 --- 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 +#include 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 -- 1.7.3.4