From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7lCj-0005B3-7Y for qemu-devel@nongnu.org; Thu, 17 Jul 2014 08:54:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X7lCd-0007Cx-Q0 for qemu-devel@nongnu.org; Thu, 17 Jul 2014 08:54:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2270) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7lCd-0007Br-H6 for qemu-devel@nongnu.org; Thu, 17 Jul 2014 08:54:27 -0400 Date: Thu, 17 Jul 2014 13:54:02 +0100 From: Stefan Hajnoczi Message-ID: <20140717125402.GA24256@stefanha-thinkpad.redhat.com> References: <87B246BB5ED53A4C98E4F9A35839EDE128F6F49D@nkgeml506-mbs.china.huawei.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tThc/1wpZn/ma/RB" Content-Disposition: inline In-Reply-To: <87B246BB5ED53A4C98E4F9A35839EDE128F6F49D@nkgeml506-mbs.china.huawei.com> Subject: Re: [Qemu-devel] [PATCH] Tap: fix vcpu long time io blocking on tap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Wangkai (Kevin,C)" Cc: Lee yang , "qemu-devel@nongnu.org" , "aliguori@amazon.com" --tThc/1wpZn/ma/RB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 11, 2014 at 01:05:30AM +0000, Wangkai (Kevin,C) wrote: > When used a tap as net driver for vm, if too many packets was delivered t= o the=20 > 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. Please tweak this description to explain clearly that the tap_send() loop can execute for a very long time if more packets are received by the host during tap_send(). It seems that the guest does not require the QEMU global mutex often during virtio-net receive, otherwise the rx virtqueue would fill up and tap_send() would return. > 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 =3D opaque; > int size; > + int pkt =3D 0; > =20 > while (qemu_can_send_packet(&s->nc)) { > uint8_t *buf =3D 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 >=3D 50) > + break; Please use scripts/checkpatch.pl to check coding style. QEMU always uses curlies around if statement bodies, even when they are only one line. --tThc/1wpZn/ma/RB Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJTx8dqAAoJEJykq7OBq3PIcQUH/0Sl6YpXQwD26Q28miaPQI2O N+x/JQzbe7SfAab7VUz8VR2WRoBUJp0Te45eTv7JhRZdLrtdIjiV88FrAQT+IUub XrajSFFtmCjz2xWphauD6T2jKIsLPcTnZXME1IBRKRjqPA56CsOEBKwm6HsQ1CgJ Wo3SKTiB2hjxfdGPC22/9nSDB0Afdkc/S/dL6serINnXCSFsFDMhB46LxE8HzLpM uBAnbldAfUY0hjrV6KdCNb/1WthfkDMWiMCuHuEoXsHm3FQxIAHMIENNE93Cwyw/ SzvB5q9MIBbUPoBSP1s75WAcCG4Makiw/nDihBvW0Uy6eQb2eBCMF6xLCpwYclg= =X0Wt -----END PGP SIGNATURE----- --tThc/1wpZn/ma/RB--