From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2081BC433E1 for ; Tue, 23 Jun 2020 14:38:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BF594206EB for ; Tue, 23 Jun 2020 14:38:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="i8Xvf0dO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF594206EB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 452CA6B0002; Tue, 23 Jun 2020 10:38:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4030D6B0005; Tue, 23 Jun 2020 10:38:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 318F36B0006; Tue, 23 Jun 2020 10:38:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0073.hostedemail.com [216.40.44.73]) by kanga.kvack.org (Postfix) with ESMTP id 1B53A6B0002 for ; Tue, 23 Jun 2020 10:38:35 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A5279181AD021 for ; Tue, 23 Jun 2020 14:38:34 +0000 (UTC) X-FDA: 76960732548.29.owner08_230ace526e3c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 641931803017C for ; Tue, 23 Jun 2020 14:38:34 +0000 (UTC) X-HE-Tag: owner08_230ace526e3c X-Filterd-Recvd-Size: 5894 Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Tue, 23 Jun 2020 14:38:33 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id h4so16189853ior.5 for ; Tue, 23 Jun 2020 07:38:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=GO6VqQ1k5DfT8B3Hft14D4L5hj9uXyjCb94sDmddrkY=; b=i8Xvf0dO3HlBgVkDMm2UdFWATb6q5c49Gp1uR5t24gxH4xjYC+5ei4BkAqzDM2KSv/ 2gx/lezU+C8XyNWRfTI2XMPTKj6pxrB0XjEi8ZEynRWETcpvFmmMuGNdUvh/OrI+i/w5 vwWn6nfaeBN2WmpS8aNmJKRPO4tUJvKILSS4Hvp003kdC/j3G3kbQiCz9bHiXZCSdqLh wIuxpVhhkSZ4J9U47uB+OkiyAa7fBy0f0ZDAIFve5z+1F2Hhm0G1n/FAMOS6UM/N4x95 PT9eFcXR5AxlX0ghw/EevRefdUSRw1vMHUuPnw5mrl2JdpHHK03FgT984eqxkUrvctEj 1eGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=GO6VqQ1k5DfT8B3Hft14D4L5hj9uXyjCb94sDmddrkY=; b=eP8IHufiDzRzrOFy7MvlpdQ05xkGMfcwe82sp8MJmXN6XvNfVmDAiJ4O7oaniQG7k5 wRXi7pxAM2or38tI8+8dBK14A2wqUOEyu7vLN5FtqGAEtcSYhVlw6wj3UWEpLc+HHIgH 4sst6H6Ii2CtkABxcPQxhmDaIcxfxIjL1swQXkE8U27LD5nVYNd8BVkxk4M6d00WBzTH 1tE0DegW2vDJ0td9qvYtAvxE0PZVGdJ2Q7aSuQGbVX1JrYcLdzR7iq+YCm+oPTRa8kFs sZ5tc88prLS0kdxxcGizNN4nFiJrStUCS7SrBJcByIagKKuU39mwbpE6jMl9zaz81fra B7pQ== X-Gm-Message-State: AOAM533uVYvDd1tFqUPgu8dUkQd67RFNQOn/SgWoiEEfiYBxNRpANbZe 7aMi6Ubpd8nIi2Yx8qUJlqCXWQ== X-Google-Smtp-Source: ABdhPJxMOLP/f8YqjcdyvCnPvoh/iJidBaJRFad2O/9s6/oq7uoN5bcHuwnQcqjMnRJ+y18nv3dkKQ== X-Received: by 2002:a02:2417:: with SMTP id f23mr25134322jaa.28.1592923113020; Tue, 23 Jun 2020 07:38:33 -0700 (PDT) Received: from [192.168.1.56] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id a20sm6546352ila.5.2020.06.23.07.38.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Jun 2020 07:38:31 -0700 (PDT) Subject: Re: [PATCH 15/15] io_uring: support true async buffered reads, if file provides it To: Pavel Begunkov , io-uring@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org References: <20200618144355.17324-1-axboe@kernel.dk> <20200618144355.17324-16-axboe@kernel.dk> <029947e3-7615-e446-3194-d48827730e1d@gmail.com> From: Jens Axboe Message-ID: <9c368ff8-b867-d40e-cd3b-6dacbecc0515@kernel.dk> Date: Tue, 23 Jun 2020 08:38:30 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <029947e3-7615-e446-3194-d48827730e1d@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 641931803017C X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 6/23/20 6:39 AM, Pavel Begunkov wrote: > On 18/06/2020 17:43, Jens Axboe wrote: >> If the file is flagged with FMODE_BUF_RASYNC, then we don't have to punt >> the buffered read to an io-wq worker. Instead we can rely on page >> unlocking callbacks to support retry based async IO. This is a lot more >> efficient than doing async thread offload. >> >> The retry is done similarly to how we handle poll based retry. From >> the unlock callback, we simply queue the retry to a task_work based >> handler. >> >> Signed-off-by: Jens Axboe >> --- >> fs/io_uring.c | 145 +++++++++++++++++++++++++++++++++++++++++++++++--- >> 1 file changed, 137 insertions(+), 8 deletions(-) >> > ... >> static int io_read(struct io_kiocb *req, bool force_nonblock) >> { >> struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs; >> @@ -2784,10 +2907,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock) >> unsigned long nr_segs = iter.nr_segs; >> ssize_t ret2 = 0; >> >> - if (req->file->f_op->read_iter) >> - ret2 = call_read_iter(req->file, kiocb, &iter); >> - else >> - ret2 = loop_rw_iter(READ, req->file, kiocb, &iter); >> + ret2 = io_iter_do_read(req, &iter); >> >> /* Catch -EAGAIN return for forced non-blocking submission */ >> if (!force_nonblock || (ret2 != -EAGAIN && ret2 != -EIO)) { >> @@ -2799,17 +2919,26 @@ static int io_read(struct io_kiocb *req, bool force_nonblock) >> ret = io_setup_async_rw(req, io_size, iovec, >> inline_vecs, &iter); >> if (ret) >> - goto out_free; >> + goto out; >> /* any defer here is final, must blocking retry */ >> if (!(req->flags & REQ_F_NOWAIT) && >> !file_can_poll(req->file)) >> req->flags |= REQ_F_MUST_PUNT; >> + /* if we can retry, do so with the callbacks armed */ >> + if (io_rw_should_retry(req)) { >> + ret2 = io_iter_do_read(req, &iter); >> + if (ret2 == -EIOCBQUEUED) { >> + goto out; >> + } else if (ret2 != -EAGAIN) { >> + kiocb_done(kiocb, ret2); >> + goto out; >> + } >> + } >> + kiocb->ki_flags &= ~IOCB_WAITQ; >> return -EAGAIN; >> } >> } >> -out_free: >> - kfree(iovec); >> - req->flags &= ~REQ_F_NEED_CLEANUP; > > This looks fishy. For instance, if it fails early on rw_verify_area(), how would > it free yet on-stack iovec? Is it handled somehow? This was tweaked and rebased on top of the REQ_F_NEED_CLEANUP change, it should be correct in the tree: https://git.kernel.dk/cgit/linux-block/tree/fs/io_uring.c?h=for-5.9/io_uring#n2908 -- Jens Axboe