From owner-freebsd-arch@FreeBSD.ORG Fri Jul 20 19:02:40 2012 Return-Path: Delivered-To: arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3A408106566B; Fri, 20 Jul 2012 19:02:40 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) by mx1.freebsd.org (Postfix) with ESMTP id C1C908FC0C; Fri, 20 Jul 2012 19:02:39 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id DD3C91DD45A; Fri, 20 Jul 2012 21:02:38 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id B60442847B; Fri, 20 Jul 2012 21:02:38 +0200 (CEST) Date: Fri, 20 Jul 2012 21:02:38 +0200 From: Jilles Tjoelker To: davidxu@FreeBSD.org Message-ID: <20120720190238.GA90393@stack.nl> References: <3CE55F29-A5B2-44A7-8854-1ED38BAE6F16@FreeBSD.org> <50075072.5050906@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50075072.5050906@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: George Neville-Neil , arch@FreeBSD.org Subject: Re: aio in GENERIC? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jul 2012 19:02:40 -0000 On Thu, Jul 19, 2012 at 08:10:26AM +0800, David Xu wrote: > On 2012/7/18 22:43, George Neville-Neil wrote: > > I was wondering why aio is not yet in GENERIC. Now that it's > > properly locked and all. > I think one of the problem in the AIO code is it allows user code to > pass pipe, socket and other file handles to kernel, however it may > not work well, the AIO threads may be blocked forever. I suggest to > disable support for socket or pipe except normal file or disk device. Yes, there seems to be an implicit assumption in the POSIX spec that AIO is only used on "fast" devices. There is no mention how a request should be cancelled that has already partially committed, such as a large write on a blocking socket, and there is text in the aio_cancel() description suggesting that it can only remove queued requests: ] The value AIO_NOTCANCELED shall be returned if at least one of the ] requested operation(s) cannot be canceled because it is in progress. An implementation might take more liberty with the cancellation implicit in exec or exit (because status need not be returned) but the FreeBSD implementation does not. Ideally, aio_cancel() and exec/exit would abort operations in progress at least in all situations where a signal would interrupt a corresponding blocking call. Additionally, it may be helpful for very large requests that need to be split up, not to start new I/O requests for parts that have not been started yet (probably only for exec/exit). The code only considers an operation on a socket "in progress" if the socket buffer has had some data/space but this is insufficient because another operation might use up that before this one starts and a large blocking write may not fit into the socket buffer at once. > it should either fully support it or do not support it at all, not > half-baked. Agreed. The current code may get stuck indefinitely if an operation blocks indefinitely. Depending on what applications actually use this, you could try failing with [EOPNOTSUPP] if aio_read/aio_write/aio_fsync is attempted on an unsupported file type. -- Jilles Tjoelker