From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=203.254.224.33 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796286632; b=Z1M1oYt3kCsLc+6OCCYvZBng/BQw9HqUXQUKIccNcjC1fVS8ZB8Lti8Zt8yiH1Dzwt/u tF3MegjYnbccL3Bpud5B480gCgO277lBeQNbEITWLgIscg5mBnrklqLx2jzZ2Wmo9L21H CAMYJcmnrI8ZqAq5GV6uIM1YasEjnYd7MB+IhixP5/VNH80A7cabJR1oQjHjfb2AXe8gS IlplBwtgi/Ul7m1AV+DKGPKTQz80hhBljozO+/KpYAhy+3zZKBMWOKYRJ5CuChUYm2mhi kumiEebuoGSCAFZh1KxOvn2WLknFrrL/mNYzWmHtmavlweTQws1QeT4jsRtCaJOXzrw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796286632; h=DMARC-Filter:Received:DKIM-Filter:DKIM-Signature:Received:Received: Received:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer: In-Reply-To:MIME-Version:Content-Transfer-Encoding:X-CMS-MailID: X-Msg-Generator:Content-Type:X-Sendblock-Type:CMS-TYPE:cpgsPolicy: X-CFilter-Loop:X-CMS-RootMailID:References; bh=e0Wcl4+5a3N8qc9eDoQ6J+wJlPvkZKDzDoUklo+QFsc=; b=p6AplILtocYXpf7frziyorFPUimKkgUpULey1jDpJ8riEXg77LXSUITOFi0LO+BRQlWV EBzEX4oPLoP9yPeX9WeY+W1O1eESHVnRr6/7wYH2REDqZqR+HpBKu8Cu85E/jSRdhMiaD II65xr0Ir90CHOgEncULt2BaQSj/iInyn6Rsgrk+QdxrN02K5XlLawzHmZjuRBl3fPg5P naDzBlQYDNjnluzHcApp5eNc9GYV+qDQi4NFmHPQ5Qvo0y2jMSfKYsABiEZ8FRR47r0W7 dsmML9V+zHyhFnOydgdIrdKOmuWbr22sREDa+xsZcUSPxAIdawRjcLqeeM8pZEH7HiQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass header.d=samsung.com header.i=@samsung.com header.a=rsa-sha256 header.s=mail20170921 header.b=ZWpPZY+m; arc=none smtp.remote-ip=203.254.224.33 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98B35606A330 for ; Thu, 3 Dec 2026 08:30:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 98B35606A330 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.a=rsa-sha256 header.s=mail20170921 header.b=ZWpPZY+m Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20261203083023epoutp03b9e08c5da2768be4093b5c8e8c5add9b~tsSrSByhp3128431284epoutp03K for ; Thu, 3 Dec 2026 08:30:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20261203083023epoutp03b9e08c5da2768be4093b5c8e8c5add9b~tsSrSByhp3128431284epoutp03K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1796286623; bh=e0Wcl4+5a3N8qc9eDoQ6J+wJlPvkZKDzDoUklo+QFsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZWpPZY+m1w8iH/DIektvg343RYbOeMOC1jIcFIi+QlKLuuR4MbWXsvcJ9s8cLrYMb mZCNB9U59K17pwFb+flKTzE3kdLVVpOY0lUEn6xVaTLi1LPAmtcFIK/6m45CJz39LM ZtqhUbUBN5LYvpG7uKfTPOsv1j59yyYfVK24zSig= Received: from epsnrtp02.localdomain (unknown [182.195.42.154]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPS id 20261203083023epcas5p4a303a0876afc168e977ba231db8a2adb~tsSq5F8fp2798327983epcas5p4B; Thu, 3 Dec 2026 08:30:23 +0000 (GMT) Received: from epcas5p1.samsung.com (unknown [182.195.38.87]) by epsnrtp02.localdomain (Postfix) with ESMTP id 4jg79V3HxTz2SSKh; Thu, 3 Dec 2026 08:30:22 +0000 (GMT) Received: from epsmtip2.samsung.com (unknown [182.195.34.31]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20261203082933epcas5p1bfb229c6feb82b6722133923a9ff3de0~tsR8A_LFc0323903239epcas5p1t; Thu, 3 Dec 2026 08:29:33 +0000 (GMT) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20261203082931epsmtip2eb8c84f483bb64d5e70955d91359d80a~tsR65tLEq2055420554epsmtip22; Thu, 3 Dec 2026 08:29:31 +0000 (GMT) From: Anuj Gupta To: Diangang Li Cc: axboe@kernel.dk, asml.silence@gmail.com, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, Diangang Li Subject: Re: [PATCH 2/2] io_uring/rw: honour RWF_NOWAIT when a dma-buf map is missing Date: Thu, 3 Dec 2026 13:58:30 +0530 Message-Id: <20261203082830.2619053-1-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261130072837.4191677-2-diangangli@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CMS-MailID: 20261203082933epcas5p1bfb229c6feb82b6722133923a9ff3de0 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P cpgsPolicy: CPGSC10-542,Y X-CFilter-Loop: Reflected X-CMS-RootMailID: 20261203082933epcas5p1bfb229c6feb82b6722133923a9ff3de0 References: <20261130072837.4191677-1-diangangli@gmail.com> <20261130072837.4191677-2-diangangli@gmail.com> On Mon, Nov 30, 2026 at 03:28:37PM +0800, Diangang Li wrote: > On nonblocking issue, io_attach_dmabuf_map() returns -EAGAIN if no map is > available. This happens before io_rw_init_file() sets REQ_F_NOWAIT, so > an RWF_NOWAIT request is punted to io-wq and can block instead of > completing with -EAGAIN. RWF_NOWAIT is still ignored when the request is issued directly from io-wq, for example with IOSQE_ASYNC. In that case, IO_URING_F_NONBLOCK may not be set, so map creation can block. One option is to pass a nowait argument to io_attach_dmabuf_map() that takes both flags into account. Something like this, on top of this patch [1] Also, when the map is missing, an app doing only RWF_NOWAIT I/O would keep getting -EAGAIN. It would need a blocking I/O to create the map, including after invalidation. [1] diff --git a/io_uring/dma-buf.h b/io_uring/dma-buf.h index d8d9b4f224d8..cb9c2d984ab5 100644 --- a/io_uring/dma-buf.h +++ b/io_uring/dma-buf.h @@ -28,9 +28,8 @@ static inline void io_detach_dmabuf_map(struct io_kiocb *req) static inline int io_attach_dmabuf_map(struct io_kiocb *req, struct iov_iter *iter, - unsigned issue_flags) + bool nowait) { - bool nowait = issue_flags & IO_URING_F_NONBLOCK; struct dma_buf_io_map *map; struct io_buf_dma *bd; diff --git a/io_uring/rw.c b/io_uring/rw.c index 6e4e8fbc9ff1..cca27ab29c58 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -357,6 +357,8 @@ static int io_init_rw_fixed(struct io_kiocb *req, unsigned int issue_flags, { struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw); struct io_async_rw *io = req->async_data; + bool nowait = (issue_flags & IO_URING_F_NONBLOCK) || + (rw->flags & RWF_NOWAIT); int ret; if (!io->bytes_done) { @@ -367,7 +369,7 @@ static int io_init_rw_fixed(struct io_kiocb *req, unsigned int issue_flags, iov_iter_save_state(&io->iter, &io->iter_state); } - ret = io_attach_dmabuf_map(req, &io->iter, issue_flags); + ret = io_attach_dmabuf_map(req, &io->iter, nowait); if (unlikely(ret)) { /* * This runs before io_rw_init_file() sets REQ_F_NOWAIT. Set it