From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M6N5H-0005gD-NU for qemu-devel@nongnu.org; Tue, 19 May 2009 07:02:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M6N5D-0005fV-2S for qemu-devel@nongnu.org; Tue, 19 May 2009 07:02:11 -0400 Received: from [199.232.76.173] (port=35559 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M6N5C-0005fS-TA for qemu-devel@nongnu.org; Tue, 19 May 2009 07:02:06 -0400 Received: from mx2.redhat.com ([66.187.237.31]:34520) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M6Mdv-0003KA-7u for qemu-devel@nongnu.org; Tue, 19 May 2009 06:33:55 -0400 Subject: Re: [Qemu-devel] [PATCH 0/13] Add generic packet buffering API From: Mark McLoughlin In-Reply-To: <4A128785.9040903@redhat.com> References: <1242726931-5726-1-git-send-email-markmc@redhat.com> <4A128785.9040903@redhat.com> Content-Type: text/plain Date: Tue, 19 May 2009 11:33:29 +0100 Message-Id: <1242729209.16653.19.camel@blaa> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Reply-To: Mark McLoughlin List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Anthony Liguori , qemu-devel@nongnu.org On Tue, 2009-05-19 at 13:18 +0300, Avi Kivity wrote: > Mark McLoughlin wrote: > > Hi, > > This patch series works towards two[1] goals: > > > > 1) Merging the code in qemu-kvm which drains the tap file descriptor > > when it is readable and buffers a packet if it fails to add it to > > the NIC receive queue > > > > 2) Using the new TAP_SETSNDBUF ioctl() to put a limit on the number > > of in-flight packets allowed on a tap device; in this case, if a > > NIC pops a packet from its transmit queue, we need to be able to > > buffer said packet if the tap queue is full > > > > Isn't it better instead to unpop the buffer? The NIC tx ring already is > a buffer, no need to add another one on top. > > It will need adjustments to the device models; for example we'll need > virtqueue_pop_commit() after we're certain the tap had enough room for > our packet and virtqueue_pop_cancel() (to unmap the buffers) if we don't. Yep, it's possible with virtio. However, you can't unpop the buffer from a tap file descriptor or socket. The alternative in those cases is to implement buffering for each, or to always check the receiving side has buffers available before popping. I choose this option because checking in advance for each packet seems expensive - i.e. a syscall for tap/socket or a trawl through the ring for virtio. Cheers, Mark.