Return-Path: Received: from mail-pg1-f194.google.com ([209.85.215.194]:39302 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730556AbeLUO2S (ORCPT ); Fri, 21 Dec 2018 09:28:18 -0500 Received: by mail-pg1-f194.google.com with SMTP id w6so2596095pgl.6 for ; Fri, 21 Dec 2018 06:28:18 -0800 (PST) Subject: Re: [PATCH 07/22] aio: support for IO polling To: Christoph Hellwig Cc: linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, viro@zeniv.linux.org.uk References: <20181218154230.3120-1-axboe@kernel.dk> <20181218154230.3120-8-axboe@kernel.dk> <20181221112533.GC7319@lst.de> From: Jens Axboe Message-ID: <58cad03b-9d4e-5229-2446-c2bd499a5363@kernel.dk> Date: Fri, 21 Dec 2018 07:28:15 -0700 MIME-Version: 1.0 In-Reply-To: <20181221112533.GC7319@lst.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 12/21/18 4:25 AM, Christoph Hellwig wrote: > On Tue, Dec 18, 2018 at 08:42:15AM -0700, Jens Axboe wrote: >> Add polled variants of PREAD/PREADV and PWRITE/PWRITEV. These act >> like their non-polled counterparts, except we expect to poll for >> completion of them. The polling happens at io_getevent() time, and >> works just like non-polled IO. > > This description is highly misleading as it doesn't match the code. > > Also needs a Cc to linux-api and a man page addition. > >> +#define AIO_IOPOLL_BATCH 8 > > We later rename this to AIO_POLL batch and move it up the file, > it would be great if we could that fold in here. It is moved, but it's never renamed. I'll get rid of the move. >> + /* >> + * Handle EAGAIN from resource limits with polled IO inline, don't >> + * pass the event back to userspace. >> + */ > > This comment looks confusing. I think this is the RWF_NOWAIT failure? > I'd say either explain it way better or not at all. Right, it's for RQF_NOWAIT. The point is we return that in the submission path, not through an io_event. I'll update the comment. >> + if (unlikely(res == -EAGAIN)) >> + set_bit(KIOCB_F_POLL_EAGAIN, &iocb->ki_flags); >> + else { >> + aio_fill_event(&iocb->ki_ev, iocb, res, res2); >> + set_bit(KIOCB_F_POLL_COMPLETED, &iocb->ki_flags); >> + } > > Please always use braces on both sides of the else. Fixed >> + if (iocb->aio_flags & IOCB_FLAG_HIPRI) { >> + /* shares space in the union, and is rather pointless.. */ >> + ret = -EINVAL; >> + if (iocb->aio_flags & IOCB_FLAG_RESFD) >> + goto out_fput; >> + >> + /* can't submit polled IO to a non-polled ctx */ >> + if (!(ctx->flags & IOCTX_FLAG_IOPOLL)) >> + goto out_fput; > > Given that we can't mix and match polled and non-polled I/O we > should drop IOCB_FLAG_HIPRI entirely. I kind of like how it's explicit like that, even if it isn't strictly needed. It makes it easier to verify apps are doing the right thing too. Don't feel super strongly about it, though. -- Jens Axboe