Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp652924ybg; Thu, 19 Mar 2020 06:27:28 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvC5t8lFY24bPzLBmA4BOcTBUTkXBlputL/3XPmCuBd+g9Hs5Pmy8dE1dS4kRkflXgYVUh3 X-Received: by 2002:a54:478d:: with SMTP id o13mr2380994oic.166.1584624448268; Thu, 19 Mar 2020 06:27:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584624448; cv=none; d=google.com; s=arc-20160816; b=JTBQ4564wmtaQeEP2m5dynbMTUTXK5UcfxvIql0+aFXtAhO3ogg+1frk9350Hco26a 9lk9WpH7uoK6t5T10SuIGutqxCCLdBSKuW0RWOCd3IBwL8mZ6sT8r9+521zLrk/9CzIZ 5hpW9qrtf0l5+Nf1yFdc3BtbTClVAtwJ0T0qlG3kP/cBirHnUuI5keppLQg8flfrr6TM AeJ2OydSGbx0OcV03CtK+4h1eE0YwjNbn/fu5q+MoUNO5n650EbbnM0AFi9twPywIUlo 8ZD1Vk82B44ObIUqeaGBS1XhI1YXvjdBZad61DI/1BqjTNakt3Bwlv1JE7k1Ms790ctr kPgw== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RdDhJSrcBcSkP5AsPZVgIzojMF0jcu5YSEk/+MC9F2U=; b=su9b3LnB+p7K8n2inBVrvs16i+ehd07L4GP2hFW+SsgtFBuCNBodSmdpLq+C2fBjXo MRml5yLLM9A6d57P5FnKScC69oX2TPEe+aAXx9/sWf9ZGslZ/QaOlHDn0gTdnAQckr3r knwRBs0bwuWsvt+jkPKFaCQc58Yo0bES+2tccXdBRAS33DCTu/2HtkS9+HAx0GGnlLoL 8o0VJT+z2wfhh/MEkXRQRILFRJNO8AvY4gV2oy5d3oV2u3lp0z/36p/chq0E2+PwsPgt mD/xJxFAx0j7L/SEm/9Ub7zSvwmG4NWNBO9+ZVSVbhnDBty0P7Do6AL8AJGD1twCCAgO ZfPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cFT1SgD6; 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 a11si1064337oid.121.2020.03.19.06.27.15; Thu, 19 Mar 2020 06:27:28 -0700 (PDT) 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.org header.s=default header.b=cFT1SgD6; 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 S1730841AbgCSN1B (ORCPT + 99 others); Thu, 19 Mar 2020 09:27:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:55088 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730598AbgCSN07 (ORCPT ); Thu, 19 Mar 2020 09:26:59 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A8602208C3; Thu, 19 Mar 2020 13:26:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584624419; bh=b3bOkk7ZC4+C3aa6UbVcLXBKkb5po7Ss9Qec2vR6Up0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cFT1SgD6b4R8ct+vcdRaEx/O3CarG/OOozlQHKp+6CW/IREBt7TpcKiQmlLbLg4Jq q+qOuLnG0avd7yqkJfem1Wm+5n3AiMYfmn93b7gcUpqOHK2aXlvPOdXT0khhHuOjEP QQUnSitFjKHJUz5/8FaObGdMBgtI1tvk9YGOkC4A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Begunkov , Jens Axboe , Sasha Levin Subject: [PATCH 5.5 36/65] io_uring: pick up link work on submit reference drop Date: Thu, 19 Mar 2020 14:04:18 +0100 Message-Id: <20200319123937.881530419@linuxfoundation.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200319123926.466988514@linuxfoundation.org> References: <20200319123926.466988514@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jens Axboe [ Upstream commit 2a44f46781617c5040372b59da33553a02b1f46d ] If work completes inline, then we should pick up a dependent link item in __io_queue_sqe() as well. If we don't do so, we're forced to go async with that item, which is suboptimal. This also fixes an issue with io_put_req_find_next(), which always looks up the next work item. That should only be done if we're dropping the last reference to the request, to prevent multiple lookups of the same work item. Outside of being a fix, this also enables a good cleanup series for 5.7, where we never have to pass 'nxt' around or into the work handlers. Reviewed-by: Pavel Begunkov Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- fs/io_uring.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index c8f8cc2463986..2547c6395d5e4 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1099,10 +1099,10 @@ static void io_free_req(struct io_kiocb *req) __attribute__((nonnull)) static void io_put_req_find_next(struct io_kiocb *req, struct io_kiocb **nxtptr) { - io_req_find_next(req, nxtptr); - - if (refcount_dec_and_test(&req->refs)) + if (refcount_dec_and_test(&req->refs)) { + io_req_find_next(req, nxtptr); __io_free_req(req); + } } static void io_put_req(struct io_kiocb *req) @@ -3569,7 +3569,7 @@ static void __io_queue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe) err: /* drop submission reference */ - io_put_req(req); + io_put_req_find_next(req, &nxt); if (linked_timeout) { if (!ret) -- 2.20.1