Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3840034ybt; Tue, 23 Jun 2020 12:02:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKl4bTFAujeGFfIDqlTfLZ3fqKmGo7Zn0W2VXxDDJloJq675zfCsq90R8vYjHG20HUyXMD X-Received: by 2002:aa7:d297:: with SMTP id w23mr12712752edq.49.1592938937321; Tue, 23 Jun 2020 12:02:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592938937; cv=none; d=google.com; s=arc-20160816; b=LTOYlhn4U68GNM9nkZC14JGN7oeEHRQ6OGbHh3rfxgxHnblV8TDLuBBgqyUlB8zDZ0 vRbbEtW6AEMMNc8oDUVie/pmMIwKnKQZMplFpKI9996UoHdWOkX2Y2zSjknX2rikMl+0 zkJwqHdl50Lw7a2pKjTH7uDLIaQ4WVKpVXcdd6BI1eh6GVz3nvHu+PToKOs9b1n0EOp4 FCAAZgzh57hcPmWRKEd+GHo+NRzN58OWGPvwgAKl4iPPybMMDOZb/hemMMEnmEfuUOUu CdDcXQiYldT39ZOCckM3W0W4NDzDlM9TLdPSahEr0IFuMN5zKfni+dT9oUAfqffwUP1/ AFwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=fyjbQaae0NsOAvrxvCCKUMOuMj6tKFODQMatWItt/Yc=; b=AnbGgKIB5F8JNnpuKfrNFLVba484g/256wVP1cGjpAFcztAPa2MH5zgPUJ92LAcm5C NPwC+M+1jxxDo7GOzVEORdSf9qFErOwhCtCf1Yt0loeXFNOOcLrZDut2FxHGmAomJc/Z 86lzCUa/kCeuStxf5yCg8xrqaW042z1rT29oExjyEyVjUvCyI+SeV/66McBFPLg50hyM 2Hg1PLAFCvgqCF3IA2z4sDoU3civ2mgP730faXBaC7MAeJfifpjzG7hTNGHn31+5ZAlY UTYLkNy4SH7Lw+3dexOnmOYHQTjm/ym7RgUJ04VDy2OY3JvEzDgb7qz4D08BbgzwuIHi rGEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=12ocHWdA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i24si11538382eds.397.2020.06.23.12.01.53; Tue, 23 Jun 2020 12:02:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=12ocHWdA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733255AbgFWTBf (ORCPT + 99 others); Tue, 23 Jun 2020 15:01:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733200AbgFWTBe (ORCPT ); Tue, 23 Jun 2020 15:01:34 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BDF4C061755 for ; Tue, 23 Jun 2020 12:01:33 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id w9so6573530ilk.13 for ; Tue, 23 Jun 2020 12:01:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=fyjbQaae0NsOAvrxvCCKUMOuMj6tKFODQMatWItt/Yc=; b=12ocHWdATKVhsusr9pw/ZzGbXNfGtGLgEK7lm+zqveEaASn/HtWRW2GyDQmdikfU6f e18yFxs95bPGbophgL9JMyevGdF0L66cCZfwqInWflTALvAptqBlMIlcmAT9rkwzESoM 0yiDj2Tk1/5aRWSXk+l/IuKOYh/sSh0syTDEFs85yK7KJV0Z4JyCBZlxLwbEALH7bXwy 6SAlUFkaKhF60lU5GYI+5gZyRNhJIC1PcCv4+Q9Sdv2t8ofszYIOD8Ru60lcLobD290X Cru1NqHkveGwCFHx+evF3MGY1lyafhaeqHwASnFOO0L6qXkzBU+xIoypXABzh6GGwL16 8OLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=fyjbQaae0NsOAvrxvCCKUMOuMj6tKFODQMatWItt/Yc=; b=Z7gd3ZhhJeadX0OEznzKAWDX6u1VSW0birHhjx6aHSPM96oaIu9/HXllBw/Ax6apl4 dnPzaeujTTkZ8bP1AjrG3JeQlshalnUr6d5olCY6EXQRLpwcb8aF6Bsr6feNtjn3Q2xI jYHS46sLGdyQnksgbc4l/McX/6DazSEyJCk/LDxO0bJRRhXMb5PSV3P6DhOg/RipHrK3 +eFRerTcfE3oUMqz5MtaiSgfkpl53+BcbIIqyjkB6WEK2hsaU3yF3nZgD7bd9WTd7Nk6 /bso4hSYEWwLGPDYxuUWIp2ZfotYeUVvGwVukVjxzH4fHxj7U/Q1Z9KUEFh+CFp6SLAO TAgA== X-Gm-Message-State: AOAM532hlSuyeXFsGp63rdI/+oG9ONlCL29cClzQy6fY3byFTokbEUE+ 3rKxv/OSoALd4Jefl+H4zfqh0C5muVo= X-Received: by 2002:a92:d789:: with SMTP id d9mr12228762iln.107.1592938892319; Tue, 23 Jun 2020 12:01:32 -0700 (PDT) Received: from [192.168.1.56] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id t5sm10769796iov.53.2020.06.23.12.01.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Jun 2020 12:01:31 -0700 (PDT) Subject: Re: [PATCH 1/4] io_uring: fix hanging iopoll in case of -EAGAIN To: Pavel Begunkov , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org References: <0301f35644823a01cbae87e440df7d58ebcf2279.1592863245.git.asml.silence@gmail.com> <95b720a6-926c-a208-e929-1d0203fa8701@kernel.dk> <6714cb8f-894c-9ff1-7b3a-4f86d7dbe52a@gmail.com> From: Jens Axboe Message-ID: Date: Tue, 23 Jun 2020 13:01:29 -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: <6714cb8f-894c-9ff1-7b3a-4f86d7dbe52a@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/23/20 5:57 AM, Pavel Begunkov wrote: > On 23/06/2020 05:18, Jens Axboe wrote: >> On 6/22/20 8:07 PM, Jens Axboe wrote: >>> On 6/22/20 4:16 PM, Pavel Begunkov wrote: >>>> io_do_iopoll() won't do anything with a request unless >>>> req->iopoll_completed is set. So io_complete_rw_iopoll() has to set >>>> it, otherwise io_do_iopoll() will poll a file again and again even >>>> though the request of interest was completed long ago. >>> >>> I need to look at this again, because with this change, I previously >>> got various use-after-free. I haven't seen any issues with it, but >>> I agree, from a quick look that I'm not quite sure how it's currently >>> not causing hangs. Yet I haven't seen any, with targeted -EAGAIN >>> testing. > > Can io_complete_rw_iopoll() get -EAGAIN after being successfully enqueued > (i.e. EIOCBQUEUED)? It's reliably fails for me, because my hacked nullblk > _can_ (i.e. probabilistically returns BLK_STS_AGAIN from ->iopoll()). Yes it can. The primary example would be a polled bio that gets split, into let's say 4 bio's. First one queues fine, but one of the subsequent ones run into request allocation failures and it gets marked as -EAGAIN. >> Ah I think I know what it is - if we run into: >> >> if (req->result == -EAGAIN) >> return -EAGAIN >> >> in io_issue_sqe() and race with it, we'll reissue twice potentially. >> So the above isn't quite enough, we'll need something a bit broader. > > I see, I'll deal with it. Thanks! -- Jens Axboe