diff mbox

[v2] Tap: fix vcpu long time io blocking on tap

Message ID 87B246BB5ED53A4C98E4F9A35839EDE128F715AD@nkgeml506-mbs.china.huawei.com
State New
Headers show

Commit Message

Wangkai (Kevin,C) July 18, 2014, 9:33 a.m. UTC
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>


--
2.0.0

Comments

Stefan Hajnoczi July 28, 2014, 3:52 p.m. UTC | #1
On Fri, Jul 18, 2014 at 09:33:42AM +0000, Wangkai (Kevin,C) wrote:
> 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>

Thanks, applied to my net-next tree:
https://github.com/stefanha/qemu/commits/net-next

The patch did not apply cleanly so I had to do it manually:

  Applying: Tap: fix vcpu long time io blocking on tap
  fatal: corrupt patch at line 32
  Repository lacks necessary blobs to fall back on 3-way merge.
  Cannot fall back to three-way merge.
  Patch failed at 0001 Tap: fix vcpu long time io blocking on tap

Please use git-send-email(1).

I also adjusted the commit message and doc comments to fit QEMU style
and for grammar.

Stefan
Wangkai (Kevin,C) July 29, 2014, 12:02 p.m. UTC | #2
> -----Original Message-----

> From: Stefan Hajnoczi [mailto:stefanha@gmail.com]

> Sent: Monday, July 28, 2014 11:53 PM

> To: Wangkai (Kevin,C)

> Cc: qemu-devel@nongnu.org; Lee yang; aliguori@amazon.com; Stefan

> Hajnoczi

> Subject: Re: [Qemu-devel] [PATCH v2] Tap: fix vcpu long time io

> blocking on tap

> 

> On Fri, Jul 18, 2014 at 09:33:42AM +0000, Wangkai (Kevin,C) wrote:

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

> 

> Thanks, applied to my net-next tree:

> https://github.com/stefanha/qemu/commits/net-next

> 

> The patch did not apply cleanly so I had to do it manually:

> 

>   Applying: Tap: fix vcpu long time io blocking on tap

>   fatal: corrupt patch at line 32

>   Repository lacks necessary blobs to fall back on 3-way merge.

>   Cannot fall back to three-way merge.

>   Patch failed at 0001 Tap: fix vcpu long time io blocking on tap

> 

> Please use git-send-email(1).

> 

> I also adjusted the commit message and doc comments to fit QEMU style

> and for grammar.

> 

> Stefan

[Wangkai (Kevin,C)] 


Hi Stefan,
I will send a patch v3 use git send-email to you.

Wangkai
Stefan Hajnoczi July 29, 2014, 12:43 p.m. UTC | #3
On Tue, Jul 29, 2014 at 1:02 PM, Wangkai (Kevin,C) <wangkai86@huawei.com> wrote:
>
>
>> -----Original Message-----
>> From: Stefan Hajnoczi [mailto:stefanha@gmail.com]
>> Sent: Monday, July 28, 2014 11:53 PM
>> To: Wangkai (Kevin,C)
>> Cc: qemu-devel@nongnu.org; Lee yang; aliguori@amazon.com; Stefan
>> Hajnoczi
>> Subject: Re: [Qemu-devel] [PATCH v2] Tap: fix vcpu long time io
>> blocking on tap
>>
>> On Fri, Jul 18, 2014 at 09:33:42AM +0000, Wangkai (Kevin,C) wrote:
>> > 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>
>>
>> Thanks, applied to my net-next tree:
>> https://github.com/stefanha/qemu/commits/net-next
>>
>> The patch did not apply cleanly so I had to do it manually:
>>
>>   Applying: Tap: fix vcpu long time io blocking on tap
>>   fatal: corrupt patch at line 32
>>   Repository lacks necessary blobs to fall back on 3-way merge.
>>   Cannot fall back to three-way merge.
>>   Patch failed at 0001 Tap: fix vcpu long time io blocking on tap
>>
>> Please use git-send-email(1).
>>
>> I also adjusted the commit message and doc comments to fit QEMU style
>> and for grammar.
>>
>> Stefan
> [Wangkai (Kevin,C)]
>
>
> Hi Stefan,
> I will send a patch v3 use git send-email to you.

There is no need, I have already applied v2.

Thanks,
Stefan
diff mbox

Patch

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;
+        }
     }
 }