qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] Tap: fix vcpu long time io blocking on tap
@ 2014-07-18  9:33 Wangkai (Kevin,C)
  2014-07-28 15:52 ` Stefan Hajnoczi
  0 siblings, 1 reply; 4+ messages in thread
From: Wangkai (Kevin,C) @ 2014-07-18  9:33 UTC (permalink / raw)
  To: qemu-devel@nongnu.org; +Cc: Lee yang, aliguori@amazon.com, Stefan Hajnoczi

fix vcpu long time io blocking on tap, when too many packets was delivered 
to the guest os via tap interface.

--
Signed-off-by: Wangkai <wangkai86@huawei.com>

diff --git a/net/tap.c b/net/tap.c
index a40f7f0..1da6d89 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -189,6 +189,7 @@ static void tap_send(void *opaque)
 {
     TAPState *s = opaque;
     int size;
+    int packets = 0;
 
     while (qemu_can_send_packet(&s->nc)) {
         uint8_t *buf = s->buf;
@@ -210,6 +211,19 @@ static void tap_send(void *opaque)
         } else if (size < 0) {
             break;
         }
+
+        /*
+         * When receive packets on tap, QEMU io was locked, if too many
+         * packets was delivered to the guest os via tap interface,
+         * tap_send() would keep looping, if then the VM required a io
+         * operation, would be blocked for a long time.
+         * Here we set the number to limit one tap interface receive time,
+         * keep io events fair and lock time little.
+         */
+        packets++;
+        if (packets >= 50) {
+            break;
+        }
     }
 }

--
2.0.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-29 12:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-18  9:33 [Qemu-devel] [PATCH v2] Tap: fix vcpu long time io blocking on tap Wangkai (Kevin,C)
2014-07-28 15:52 ` Stefan Hajnoczi
2014-07-29 12:02   ` Wangkai (Kevin,C)
2014-07-29 12:43     ` Stefan Hajnoczi

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).