qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Tap: fix vcpu long time io blocking on tap
@ 2014-07-11  1:05 Wangkai (Kevin,C)
  2014-07-11 13:04 ` Stefan Hajnoczi
  2014-07-17 12:54 ` Stefan Hajnoczi
  0 siblings, 2 replies; 11+ messages in thread
From: Wangkai (Kevin,C) @ 2014-07-11  1:05 UTC (permalink / raw)
  To: qemu-devel@nongnu.org; +Cc: Lee yang, stefanha@redhat.com, aliguori@amazon.com

When used a tap as net driver for vm, if too many packets was delivered to the 
guest os via tap interface, the guest os will be blocked on io events for a long
time, while tap driver was busying process packets.

kvm vcpu thread block on io lock call trace:
  __lll_lock_wait
  _L_lock_1004
  __pthread_mutex_lock
  qemu_mutex_lock
  kvm_cpu_exec
  qemu_kvm_cpu_thread_fn
  start_thread

qemu io thread call trace:
  ...
  qemu_net_queue_send
  tap_send
  qemu_iohandler_poll
  main_loop_wait
  main_loop
  

I think the qemu io lock time should be as small as possible, and the io work
slice should be limited at a particular ration or time.

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

diff --git a/net/tap.c b/net/tap.c
index a40f7f0..df9a0eb 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 pkt = 0;
 
     while (qemu_can_send_packet(&s->nc)) {
         uint8_t *buf = s->buf;
@@ -210,6 +211,11 @@ static void tap_send(void *opaque)
         } else if (size < 0) {
             break;
         }
+
+        /* limit io block time slice for 50 packets */
+        pkt++;
+        if (pkt >= 50)
+            break;
     }
 }
 
---
2.0.0

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

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

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-11  1:05 [Qemu-devel] [PATCH] Tap: fix vcpu long time io blocking on tap Wangkai (Kevin,C)
2014-07-11 13:04 ` Stefan Hajnoczi
2014-07-14  1:55   ` Wangkai (Kevin,C)
2014-07-14  8:43     ` Stefan Hajnoczi
2014-07-14 10:44       ` Wangkai (Kevin,C)
2014-07-15 14:59         ` Stefan Hajnoczi
2014-07-16 10:10           ` Wangkai (Kevin,C)
2014-07-17  3:43           ` Wangkai (Kevin,C)
2014-07-17  5:36             ` Jason Wang
2014-07-17  7:48               ` Wangkai (Kevin,C)
2014-07-17 12:54 ` 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).