From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:44124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qp0pn-0006E3-Kw for qemu-devel@nongnu.org; Thu, 04 Aug 2011 12:31:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qp0pm-0001VF-Kw for qemu-devel@nongnu.org; Thu, 04 Aug 2011 12:31:47 -0400 Received: from e4.ny.us.ibm.com ([32.97.182.144]:36439) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qp0pm-0001VB-H8 for qemu-devel@nongnu.org; Thu, 04 Aug 2011 12:31:46 -0400 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by e4.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p74G91B0023106 for ; Thu, 4 Aug 2011 12:09:01 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p74GVidM184032 for ; Thu, 4 Aug 2011 12:31:44 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p74GVeQX003828 for ; Thu, 4 Aug 2011 13:31:40 -0300 Message-ID: <4E3AC965.3020600@us.ibm.com> Date: Thu, 04 Aug 2011 11:31:33 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1312208590-25502-1-git-send-email-aliguori@us.ibm.com> <1312208590-25502-4-git-send-email-aliguori@us.ibm.com> <4E3AC2F5.7050805@redhat.com> In-Reply-To: <4E3AC2F5.7050805@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 03/12] char: introduce tx queue to enable Unix style flow control List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Amit Shah , Hans de Goede , qemu-devel@nongnu.org On 08/04/2011 11:04 AM, Avi Kivity wrote: > On 08/01/2011 05:23 PM, Anthony Liguori wrote: >> The char layer tries very hard to avoid using an intermediate buffer. The >> implication of this is that when the backend does a write(), the data >> for that >> write must be immediately passed to the front end. >> >> Flow control is needed to handle the likely event that the front end >> is not >> able to handle the data at this point in time. We implement flow control >> today by allowing the front ends to register a polling function. The >> polling >> function returns non-zero when it is able to receive data. >> >> This works okay because most backends are tied to some sort of file >> descriptor >> and our main loop allows polling to be included with file descriptor >> registration. >> >> This falls completely apart when dealing with the front end writing to >> the >> back end though because the front end (devices) don't have an obvious >> place to >> integrate polling. >> >> Short summary: we're broken by design. A way to fix this is to eliminate >> polling entirely and use a Unix style flow control mechanism. This >> involves >> using an intermediate buffer and allowing registration of >> notifications when >> the buffer either has data in it (readability) or is not full >> (writability). >> > > If you don't have an obvious place to integrate polling, how do you poll > for writability? You poll by trying to write. If write fails, you can set a callback for notification for when it becomes writable. > Although, providing a reasonably sized buffer and blocking the vcpu when > it's full is a lot better than what we have now. This series won't block the vcpu. The devices can (and will) register callbacks for when the pipe is writable again. Regards, Anthony Liguori >