Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1150032ybl; Fri, 13 Dec 2019 10:24:06 -0800 (PST) X-Google-Smtp-Source: APXvYqwClB9ZwjJ3A3zT3r507b9EP0dXvUTP1fXybZTdtWi7S6p9s1rCKunil9c9zs6rUzyhQRbD X-Received: by 2002:a05:6830:1e5a:: with SMTP id e26mr15168471otj.351.1576261446208; Fri, 13 Dec 2019 10:24:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576261446; cv=none; d=google.com; s=arc-20160816; b=TfT3ILcGmugYLK9czeSs2w7IbahmJyTKv5ljswXRCEAHI0Yxj08/2IomVF3huPFgE4 7yGafs//72H3wYa7udJ+nLI1bH87P/pXM9hTbWqck/nAQ6ng8U/Do5g4YLWkNWJsFdvu WGHZxMUfM7rtlbNp53q+4bXqB8xDHGTvouDLZ+AnraEo/JZWX6+fhcqgXPCyT3E/kFKC N4wOHCVvJkx+rhsrPYVoOHFxJjF18fd/k4jFtBW51Ap0OXIhRlb0DuMfHURt7gf4vc/V 5j1z3/XlkWriVqkrRCQis3UqI3far2tfEyVAPfrWGyZ9y1UH0DueDCxzynAHAvRMf5oV fL6A== 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=HpocJd7ZVW8aqsXghWaXWyBEujhMqhHxlf0cK+XS6no=; b=lVSP1xVXsFnYk31Mo3wGjn4ZrTTTwdSuP4r6hj9vfhXHOp3tdNl7l4PCX9gxw0NOQt SYlHL5XFmT1STLntjT2YIMjgb2F6EZFfH/FB+sG/DVFEhWkB+kHg2nNwr8RZVNpz/W9L VhfiljKoquEtxkcMd75nwn9wgHiz6AwUiyMwqeYdpO2iF6F7rCW3Bklu5s7SkZgG2J/0 H8mQWwX7/YwKMw8CC0/CjJHt/wPAhuPWAkH5DFGT3dZ4AJmEIyY5PSRzSWGbr/YialMs STDZYAiq6TetzUIsUFlLopdbrxFgSaXMpovK/Z/7ygeCtUGIJfq14LKEEDgSaR5JxTNr B+0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b="Rqg/Ovmi"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t20si5426672otr.64.2019.12.13.10.23.54; Fri, 13 Dec 2019 10:24:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b="Rqg/Ovmi"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728773AbfLMSWt (ORCPT + 99 others); Fri, 13 Dec 2019 13:22:49 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:35517 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728693AbfLMSWt (ORCPT ); Fri, 13 Dec 2019 13:22:49 -0500 Received: by mail-io1-f67.google.com with SMTP id v18so368808iol.2 for ; Fri, 13 Dec 2019 10:22:49 -0800 (PST) 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=HpocJd7ZVW8aqsXghWaXWyBEujhMqhHxlf0cK+XS6no=; b=Rqg/OvmizrBtTm3kiJrpDSeR1+kUYCkrSayQpyg6tZ1FpM4zpcENIWmluYZCNiLQsf mcnIyNhSdvU7L13bX7IFVftUuiEqUZ03dqGoWi8vAT+thWksY7jy0hD/05fwtmRGpZpx WjDbYiPt23rEi9W6Ews0hOUuaFpAM+EGAK3+6VhoAqbuoSH4MJTJyZk91WRzw90R0SQk 3bvTUPIwgI/lq9J/QmW8xtf0t/Emw5AIqCvsQ5IOX1fQ6JqIeLyDUTR0cezcIeaCWFo3 MDPlTX3F8LKzr7Vjs62YyJNnydUO/HK/ZWS6tTYp5A5a0/xnamNwxE8HxxKMBgojXuBQ 2l4g== 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=HpocJd7ZVW8aqsXghWaXWyBEujhMqhHxlf0cK+XS6no=; b=dH1a+ijRfnP2QtsT82GcTWU9i4INr5SIOyXhp/eP7OyiERYdM6KEK6QRav7i6vvUxO IlbisePkAAUtzQrJ1j4isK0tJtmCnDtgGlsyxTludHqN3qDk1oOSalm6MoDOLx5gzGad z1FWtK7PFudN78u+HcDiM+SLSKh6+R7EjyJ3lUyeyFxukTGGagYnX+mtEx02iXlPby1B LYcF4pJ2pHfSPzpozPDNWbio1kbjprYbdzHsYDC8FaNKmwpm6pUquwyjJNarpjCxBHbg Umrjn/HCrcJ0xUng1i+Vh5XnskRJt8dtTQEufURXRqgcLerXFTz9aoPsTRSZ/PhC7DOg mIlA== X-Gm-Message-State: APjAAAVbCQxA+JQCqyfHaejrbIDTlnkhhILh/5eBzVzyOOiIPLwvj88N niXIVTGIL2u9JrdljJPG4Ktljl2I5/Tx6A== X-Received: by 2002:a6b:7b41:: with SMTP id m1mr8002940iop.191.1576261368225; Fri, 13 Dec 2019 10:22:48 -0800 (PST) Received: from [192.168.1.159] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id d7sm3018102ilk.11.2019.12.13.10.22.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 Dec 2019 10:22:47 -0800 (PST) Subject: Re: [PATCH 1/1] io_uring: don't wait when under-submitting To: Pavel Begunkov , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org References: <5caa38be87f069eb4cc921d58ee1a98ff5d53978.1576223348.git.asml.silence@gmail.com> From: Jens Axboe Message-ID: <21ca72b0-c35d-96b7-399f-d4034d976c27@kernel.dk> Date: Fri, 13 Dec 2019 11:22:46 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <5caa38be87f069eb4cc921d58ee1a98ff5d53978.1576223348.git.asml.silence@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 12/13/19 12:51 AM, Pavel Begunkov wrote: > There is no reliable way to submit and wait in a single syscall, as > io_submit_sqes() may under-consume sqes (in case of an early error). > Then it will wait for not-yet-submitted requests, deadlocking the user > in most cases. Why not just cap the wait_nr? If someone does to_submit = 8, wait_nr = 8, and we only submit 4, just wait for 4? Ala: diff --git a/fs/io_uring.c b/fs/io_uring.c index 81219a631a6d..4a76ccbb7856 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -5272,6 +5272,10 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit, submitted = io_submit_sqes(ctx, to_submit, f.file, fd, &cur_mm, false); mutex_unlock(&ctx->uring_lock); + if (submitted <= 0) + goto done; + if (submitted != to_submit && min_complete > submitted) + min_complete = submitted; } if (flags & IORING_ENTER_GETEVENTS) { unsigned nr_events = 0; @@ -5284,7 +5288,7 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit, ret = io_cqring_wait(ctx, min_complete, sig, sigsz); } } - +done: percpu_ref_put(&ctx->refs); out_fput: fdput(f); -- Jens Axboe