From patchwork Thu Jun 27 10:45:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13714401 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AF5918732D for ; Thu, 27 Jun 2024 13:14:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719494063; cv=none; b=EZEP69dGygRxNq7/Sb25s/aSTe3PAQ9iK//JVl6tS0wqehoXMHOjtKVAWHJhTY/65e2tHB8u2IB+QOeY1pqvd5sEnFq48QcaDc7jyd5emuHJsQMDvLZxlLWfCb5xy1i55AlnPjcD9Owj/2py2bGuUCBkqTDsxOp3Lz5Vhd7akMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719494063; c=relaxed/simple; bh=jNHWVbeYhZDhPFEgKWgFGR78ajz3qSFZP4uZZ8IoHx4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=CG17OVNyCOTx+DGTmLfQsvYHMIeMg2RvsSEMmOgX38crG1bj3yVjG3/Mxw4ta6hTeT2crUpiaSN8T+Cp1YNGlrPOWEVLAXefAfiJ99elFr/Xh8U3Axt7zL60LdUBG+O452Ae6+Lxbplw1DKFafM+/DV43VSg8ISjjuv04zCAu0A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=Q4jfW6Dl; arc=none smtp.client-ip=203.254.224.24 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.b="Q4jfW6Dl" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240627131418epoutp01e87636c9c82032a9969d3438049749b7~c3rxz_1ap1975719757epoutp01b for ; Thu, 27 Jun 2024 13:14:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240627131418epoutp01e87636c9c82032a9969d3438049749b7~c3rxz_1ap1975719757epoutp01b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1719494058; bh=h6p0r8QGeMeiENXxuYhDRIQeqijV9Gyk512CJzPV4Ms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q4jfW6Dl+HgdB27ZyZw4fTcEzjXScKmbkCheOcxZHUOSYiqoDiyPQHfu18Z8kwiJB CoxW1eygKeFXh1jJSFq16qY0db6l45Lo8xN9QM1VJMLO0kkTYh1axvKd7VNDzAScTb vZHY4hn9AVHVFYdAg+lpv8HbN3tcnSDqRxArsVpw= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240627131418epcas5p3e5ce668a5c2608f08d5a2eef12629fcd~c3rxXJJod0653906539epcas5p3L; Thu, 27 Jun 2024 13:14:18 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.176]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4W8zYN44Yvz4x9Pw; Thu, 27 Jun 2024 13:14:16 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id CE.6F.06857.8A56D766; Thu, 27 Jun 2024 22:14:16 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240627105404epcas5p334c7c5bd3aee98b58e60ac1008c863be~c1xVBDgd82093720937epcas5p3N; Thu, 27 Jun 2024 10:54:04 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240627105404epsmtrp217e34dfa5111e03db9004cc5e0d69924~c1xVAPDND0954409544epsmtrp2R; Thu, 27 Jun 2024 10:54:04 +0000 (GMT) X-AuditID: b6c32a4b-ae9fa70000021ac9-16-667d65a80d89 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 45.1E.19057.BC44D766; Thu, 27 Jun 2024 19:54:03 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240627105402epsmtip18392ee0ffabb9899cc12174cd8c7e685~c1xTPibz43160631606epsmtip1w; Thu, 27 Jun 2024 10:54:02 +0000 (GMT) From: Kundan Kumar To: axboe@kernel.dk, hch@lst.de, willy@infradead.org, kbusch@kernel.org Cc: linux-block@vger.kernel.org, joshi.k@samsung.com, mcgrof@kernel.org, anuj20.g@samsung.com, nj.shetty@samsung.com, c.gameti@samsung.com, gost.dev@samsung.com, Kundan Kumar Subject: [PATCH v6 1/3] block: Added folio-lized version of bio_add_hw_page() Date: Thu, 27 Jun 2024 16:15:50 +0530 Message-Id: <20240627104552.11177-2-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240627104552.11177-1-kundan.kumar@samsung.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBJsWRmVeSWpSXmKPExsWy7bCmlu6K1No0g5blUhZNE/4yW6y+289m 8X17H4vFzQM7mSxW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zCDv1a19rJ3KEd00O FN//tOCqRJ7OpbsSSizFGYmGWsxFxYkABI7Wq/MCAAA= X-CMS-MailID: 20240627105404epcas5p334c7c5bd3aee98b58e60ac1008c863be X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240627105404epcas5p334c7c5bd3aee98b58e60ac1008c863be References: <20240627104552.11177-1-kundan.kumar@samsung.com> Added new bio_add_hw_folio() function. This is a prep patch. Signed-off-by: Kundan Kumar --- block/bio.c | 33 ++++++++++++++++++++++++++++----- block/blk.h | 4 ++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/block/bio.c b/block/bio.c index e9e809a63c59..6c2db8317ae5 100644 --- a/block/bio.c +++ b/block/bio.c @@ -979,6 +979,31 @@ bool bvec_try_merge_hw_page(struct request_queue *q, struct bio_vec *bv, int bio_add_hw_page(struct request_queue *q, struct bio *bio, struct page *page, unsigned int len, unsigned int offset, unsigned int max_sectors, bool *same_page) +{ + struct folio *folio = page_folio(page); + size_t folio_offset = (folio_page_idx(folio, page) << PAGE_SHIFT) + + offset; + + return bio_add_hw_folio(q, bio, folio, len, folio_offset, max_sectors, + same_page); +} + +/** + * bio_add_hw_folio - attempt to add a folio to a bio with hw constraints + * @q: the target queue + * @bio: destination bio + * @folio: folio to add + * @len: vec entry length + * @offset: vec entry offset in the folio + * @max_sectors: maximum number of sectors that can be added + * @same_page: return if the segment has been merged inside the same folio + * + * Add a folio to a bio while respecting the hardware max_sectors, max_segment + * and gap limitations. + */ +int bio_add_hw_folio(struct request_queue *q, struct bio *bio, + struct folio *folio, size_t len, size_t offset, + unsigned int max_sectors, bool *same_page) { unsigned int max_size = max_sectors << SECTOR_SHIFT; @@ -992,8 +1017,8 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio, if (bio->bi_vcnt > 0) { struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1]; - if (bvec_try_merge_hw_page(q, bv, page, len, offset, - same_page)) { + if (bvec_try_merge_hw_page(q, bv, folio_page(folio, 0), len, + offset, same_page)) { bio->bi_iter.bi_size += len; return len; } @@ -1010,9 +1035,7 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio, return 0; } - bvec_set_page(&bio->bi_io_vec[bio->bi_vcnt], page, len, offset); - bio->bi_vcnt++; - bio->bi_iter.bi_size += len; + bio_add_folio_nofail(bio, folio, len, offset); return len; } diff --git a/block/blk.h b/block/blk.h index d0a986d8ee50..8c27fd7cc6de 100644 --- a/block/blk.h +++ b/block/blk.h @@ -529,6 +529,10 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio, struct page *page, unsigned int len, unsigned int offset, unsigned int max_sectors, bool *same_page); +int bio_add_hw_folio(struct request_queue *q, struct bio *bio, + struct folio *folio, size_t len, size_t offset, + unsigned int max_sectors, bool *same_page); + /* * Clean up a page appropriately, where the page may be pinned, may have a * ref taken on it or neither. From patchwork Thu Jun 27 10:45:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13714402 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D462313F00A for ; Thu, 27 Jun 2024 13:14:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719494082; cv=none; b=U3dKUseA4gL4sj9NRJQSt1pWR+wLj+dsnrthboBKtkJEqibnuwe1AKqap/IOlIMvPSZCET0E8jZOK388K9NJ/fWicE6L0YCtC8w2O3TFce3Xpdq1t+vQpe5RITA5Uhjc75yaM72JIk9SHFFJRlMeN7BlVl925hM+gGgUnxXkFQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719494082; c=relaxed/simple; bh=HDPHiwHv6cgL2Z9u/eNpYhdoxEW6H8O/UwkdK+XEt4Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=QOYYC7gMm4m3JTTnQEG5hsfTxddyQpH++tFEueKh1wZFgEM1pU9ZqVNqlyqcQH2RbwO44T1r5zyansjDgcePY0t0wJBmThUJkgHGRz0A4HPuctgJSQTbpNmgLxCLkaViJ8NpvGLZ/NlUkQbErNEt2kIaG5TN3ZEBG5DYFgYeT+Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=orbmRHVN; arc=none smtp.client-ip=203.254.224.33 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.b="orbmRHVN" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20240627131432epoutp0374705de52cfbca3d637ba4441a798456~c3r_x3esT1178111781epoutp036 for ; Thu, 27 Jun 2024 13:14:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20240627131432epoutp0374705de52cfbca3d637ba4441a798456~c3r_x3esT1178111781epoutp036 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1719494072; bh=yx1lS/I183VitV+qxQrDGQglsXzYSCNs/H0Gu2n36x4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=orbmRHVNJiPsEG2EQqt3Dr4MIoFylyQqwhNXEycJIKcSCggoxXw6GeZqUNuOtScVZ bQUEDEDAOSjx3qe5zxnYBXV1o6gIgxpgrT5xT8llTDs+3OpI4cHqrqae7/9YKRKRX1 WEalRAJD2czby0NtQK4CFq012MhZ+y6Mvfi7rvZA= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240627131432epcas5p360fb1f917e13a71b63a78af2743ad3c8~c3r_N1e5F2191421914epcas5p3x; Thu, 27 Jun 2024 13:14:32 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.178]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4W8zYf2PNZz4x9Pt; Thu, 27 Jun 2024 13:14:30 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id E5.3A.09989.6B56D766; Thu, 27 Jun 2024 22:14:30 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240627105410epcas5p175463086ef530a5a7f9ed555b02ed20b~c1xa0yIR12803028030epcas5p1S; Thu, 27 Jun 2024 10:54:10 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240627105410epsmtrp1e82942007c5f510636b59e2952b28876~c1xay-r840778707787epsmtrp1g; Thu, 27 Jun 2024 10:54:10 +0000 (GMT) X-AuditID: b6c32a4a-bffff70000002705-d9-667d65b65eaa Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 12.EF.18846.2D44D766; Thu, 27 Jun 2024 19:54:10 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240627105408epsmtip140ac7dea76f5f67cc573796e930c5e98~c1xY_B7sr0102701027epsmtip12; Thu, 27 Jun 2024 10:54:08 +0000 (GMT) From: Kundan Kumar To: axboe@kernel.dk, hch@lst.de, willy@infradead.org, kbusch@kernel.org Cc: linux-block@vger.kernel.org, joshi.k@samsung.com, mcgrof@kernel.org, anuj20.g@samsung.com, nj.shetty@samsung.com, c.gameti@samsung.com, gost.dev@samsung.com, Kundan Kumar Subject: [PATCH v6 2/3] block: introduce folio awareness and add a bigger size from folio Date: Thu, 27 Jun 2024 16:15:51 +0530 Message-Id: <20240627104552.11177-3-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240627104552.11177-1-kundan.kumar@samsung.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFJsWRmVeSWpSXmKPExsWy7bCmpu621No0g+Ut/BZNE/4yW6y+289m 8X17H4vFzQM7mSxWrj7KZHH0/1s2i0mHrjFabP3yldVi7y1tixsTnjJabPs9n9ni9485bA48 HptXaHlcPlvqsWlVJ5vH7psNbB59W1YxenzeJBfAFpVtk5GamJJapJCal5yfkpmXbqvkHRzv HG9qZmCoa2hpYa6kkJeYm2qr5OIToOuWmQN0oZJCWWJOKVAoILG4WEnfzqYov7QkVSEjv7jE Vim1ICWnwKRArzgxt7g0L10vL7XEytDAwMgUqDAhO2PplFPMBY/VKm6t/8bUwLhbrouRk0NC wETi8KatjF2MXBxCArsZJf4svsIM4XxilNizbR4jnDPn71wWmJZzh/qgEjsZJQ5MuMgC4Xxm lDj2ewZrFyMHB5uArsSPplCQBhEBd4mpLx+BNTALnGWUODH1EdgkYYFoie/n97GB1LMIqEo8 O2EJEuYVsJV409/ODrFMXmLmpe/sICWcAnYSXZ8qIEoEJU7OfAI2hRmopHnrbLCrJQQ6OSR+ PdzABtHrIjH55yaoo4UlXh3fAjVTSuJlfxuUnS1xqHEDE4RdIrHzSANU3F6i9VQ/M8heZgFN ifW79CHCshJTT61jgtjLJ9H7+wlUK6/Ejn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T2AUmIUkNQtJagEj0ypG0dSC4tz03OQCQ73ixNzi0rx0veT83E2M4PDXCtrBuGz9X71DjEwc jIcYJTiYlUR4Q0uq0oR4UxIrq1KL8uOLSnNSiw8xSnOwKInzKud0pggJpCeWpGanphakFsFk mTg4pRqYOhezH9LL/hl+WPTnxqLP3Zb/NySerbf5nazbqh/6XzbvX1tWwPcCj2Ob3+UurXi6 U7i1d64kw/knVY/XOzJOjVwYd0wIGHzekZH1a6+cTVXLv3rvq+Ls82+t5PtMl2nuOVg8NbL6 aNDVkh/5GQ+U+aT5X07WXyL09cYWYy1bO2HnJYZ8pdlTizf97BJ6k1TAz7zrQMWUnTrTzwUZ bbCt3zVZnzXSsjo17q9Fr+rMzhStPx9X+R3ydNwStdgoltHg4idWoZ1sz28sUL83m/VWD4Pj y+A/0ZfiOno47bOc74t+E7zn9jC25oaBhNveHdLPDs6dctXJtS91V7c+V63Ld7F7+wxzZsqt 8ttdm6TEUpyRaKjFXFScCABU5Jo47gIAAA== X-CMS-MailID: 20240627105410epcas5p175463086ef530a5a7f9ed555b02ed20b X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240627105410epcas5p175463086ef530a5a7f9ed555b02ed20b References: <20240627104552.11177-1-kundan.kumar@samsung.com> Add a bigger size from folio to bio and skip merge processing for pages. Fetch the offset of page within a folio. Depending on the size of folio and folio_offset, fetch a larger length. This length may consist of multiple contiguous pages if folio is multiorder. Using the length calculate number of pages which will be added to bio and increment the loop counter to skip those pages. Using a helper function check if pages are contiguous and belong to same folio, this is done as a COW may happen and change contiguous mapping of pages of folio. This technique helps to avoid overhead of merging pages which belong to same large order folio. Also folio-lize the functions bio_iov_add_page() and bio_iov_add_zone_append_page() Signed-off-by: Kundan Kumar --- block/bio.c | 76 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 16 deletions(-) diff --git a/block/bio.c b/block/bio.c index 6c2db8317ae5..28281135a3f5 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1227,8 +1227,8 @@ void bio_iov_bvec_set(struct bio *bio, struct iov_iter *iter) bio_set_flag(bio, BIO_CLONED); } -static int bio_iov_add_page(struct bio *bio, struct page *page, - unsigned int len, unsigned int offset) +static int bio_iov_add_folio(struct bio *bio, struct folio *folio, size_t len, + size_t offset) { bool same_page = false; @@ -1237,30 +1237,60 @@ static int bio_iov_add_page(struct bio *bio, struct page *page, if (bio->bi_vcnt > 0 && bvec_try_merge_page(&bio->bi_io_vec[bio->bi_vcnt - 1], - page, len, offset, &same_page)) { + folio_page(folio, 0), len, offset, + &same_page)) { bio->bi_iter.bi_size += len; if (same_page) - bio_release_page(bio, page); + bio_release_page(bio, folio_page(folio, 0)); return 0; } - __bio_add_page(bio, page, len, offset); + bio_add_folio_nofail(bio, folio, len, offset); return 0; } -static int bio_iov_add_zone_append_page(struct bio *bio, struct page *page, - unsigned int len, unsigned int offset) +static int bio_iov_add_zone_append_folio(struct bio *bio, struct folio *folio, + size_t len, size_t offset) { struct request_queue *q = bdev_get_queue(bio->bi_bdev); bool same_page = false; - if (bio_add_hw_page(q, bio, page, len, offset, + if (bio_add_hw_folio(q, bio, folio, len, offset, queue_max_zone_append_sectors(q), &same_page) != len) return -EINVAL; if (same_page) - bio_release_page(bio, page); + bio_release_page(bio, folio_page(folio, 0)); return 0; } +static unsigned int get_contig_folio_len(int *num_pages, struct page **pages, + int i, struct folio *folio, + size_t left, size_t offset) +{ + size_t bytes = left; + size_t contig_sz = min_t(size_t, PAGE_SIZE - offset, bytes); + unsigned int j; + + /* + * We might COW a single page in the middle of + * a large folio, so we have to check that all + * pages belong to the same folio. + */ + bytes -= contig_sz; + for (j = i + 1; j < i + *num_pages; j++) { + size_t next = min_t(size_t, PAGE_SIZE, bytes); + + if (page_folio(pages[j]) != folio || + pages[j] != pages[j - 1] + 1) { + break; + } + contig_sz += next; + bytes -= next; + } + *num_pages = j - i; + + return contig_sz; +} + #define PAGE_PTRS_PER_BVEC (sizeof(struct bio_vec) / sizeof(struct page *)) /** @@ -1280,9 +1310,9 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) unsigned short entries_left = bio->bi_max_vecs - bio->bi_vcnt; struct bio_vec *bv = bio->bi_io_vec + bio->bi_vcnt; struct page **pages = (struct page **)bv; - ssize_t size, left; - unsigned len, i = 0; - size_t offset; + ssize_t size; + unsigned int i = 0, num_pages; + size_t offset, folio_offset, left, len; int ret = 0; /* @@ -1324,15 +1354,29 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) for (left = size, i = 0; left > 0; left -= len, i++) { struct page *page = pages[i]; + struct folio *folio = page_folio(page); + + folio_offset = (folio_page_idx(folio, page) << PAGE_SHIFT) + + offset; + + len = min_t(size_t, (folio_size(folio) - folio_offset), left); + + num_pages = DIV_ROUND_UP(offset + len, PAGE_SIZE); + + if (num_pages > 1) + len = get_contig_folio_len(&num_pages, pages, i, + folio, left, offset); - len = min_t(size_t, PAGE_SIZE - offset, left); if (bio_op(bio) == REQ_OP_ZONE_APPEND) { - ret = bio_iov_add_zone_append_page(bio, page, len, - offset); + ret = bio_iov_add_zone_append_folio(bio, folio, len, + folio_offset); if (ret) break; } else - bio_iov_add_page(bio, page, len, offset); + bio_iov_add_folio(bio, folio, len, folio_offset); + + /* Skip the pages which got added */ + i = i + (num_pages - 1); offset = 0; } From patchwork Thu Jun 27 10:45:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13714403 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F48F13F00A for ; Thu, 27 Jun 2024 13:14:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719494086; cv=none; b=ZKzUU9yPQXPR4PFG2sIdVHPtB0XuR+aqujKKCsr/V7iub+SF9U+XviyfogALti9DqHWU8ZKUVWdBL9kzGVQ4SvxfEyiJXBnmm0Ksr7aC4CDlnz4k79OEK7iXETlpY9XcXaSPEYv8btpe4sGISGnIqVKnF53fiIjWf84twlSFjFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719494086; c=relaxed/simple; bh=MPgRvf4KkLoxeFxAmS+6WEZ61YbSxUQ/6Lg2fsS4SxY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=bYVzr2qhRwTFSk83DnMfEzIvLuc4tcEzgiJJ5BeJqXa1ybVcLZst94vwqybKey7ZTCxGPukZmBYfXuZJq/kxkTQlimYWswVTxUMxvdZzfxnuiDOnjVWoXql18GH3QaHF7kPptZ8gkg4hgBHij3fmPsGwga5S7550zyQTw1oznvs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=Zh7ChcZn; arc=none smtp.client-ip=203.254.224.34 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.b="Zh7ChcZn" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240627131437epoutp04657a21fd588ec97cd7db19ae1f06a97b~c3sDEwI473138831388epoutp04j for ; Thu, 27 Jun 2024 13:14:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240627131437epoutp04657a21fd588ec97cd7db19ae1f06a97b~c3sDEwI473138831388epoutp04j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1719494077; bh=SayiFRvfmct27qAqrsmRa8SVNq5pD1UBTXXsqIKLCcA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zh7ChcZnPmAZdnbmRBWVMFn+0d1LCnazYifhH8lGS+I7XftEmFPtjUIsJX2splnFz gmvX+jxvp1mk+nCr+lygMAiDpGYUc06qigxMleDUG0mWf7KHq/d/2XUsJbw40ajQzv tVpG5LLZG9XO0JBTFFqtiLs+D6MB/6PbzCnDBzTc= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240627131436epcas5p34d7333276b2d80098dcd605b65ca2e7e~c3sCjVj8t2191421914epcas5p3A; Thu, 27 Jun 2024 13:14:36 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.175]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4W8zYl0B0Xz4x9Pv; Thu, 27 Jun 2024 13:14:35 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 81.A8.11095.AB56D766; Thu, 27 Jun 2024 22:14:34 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240627105413epcas5p3384fbacd155f252a861e22cd11ee3b31~c1xdmwCE52093720937epcas5p3q; Thu, 27 Jun 2024 10:54:13 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240627105413epsmtrp178983fe8ee56d82b3dda03132fe76e60~c1xdmAtc40778707787epsmtrp1j; Thu, 27 Jun 2024 10:54:13 +0000 (GMT) X-AuditID: b6c32a49-3c3ff70000012b57-31-667d65babf9a Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 03.EF.18846.5D44D766; Thu, 27 Jun 2024 19:54:13 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240627105411epsmtip19e651837572b234d583fc6babee31d1c~c1xbvAqua0228702287epsmtip1p; Thu, 27 Jun 2024 10:54:11 +0000 (GMT) From: Kundan Kumar To: axboe@kernel.dk, hch@lst.de, willy@infradead.org, kbusch@kernel.org Cc: linux-block@vger.kernel.org, joshi.k@samsung.com, mcgrof@kernel.org, anuj20.g@samsung.com, nj.shetty@samsung.com, c.gameti@samsung.com, gost.dev@samsung.com, Kundan Kumar Subject: [PATCH v6 3/3] block: unpin user pages belonging to a folio at once Date: Thu, 27 Jun 2024 16:15:52 +0530 Message-Id: <20240627104552.11177-4-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240627104552.11177-1-kundan.kumar@samsung.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOJsWRmVeSWpSXmKPExsWy7bCmhu6u1No0g7OfrSyaJvxltlh9t5/N 4vv2PhaLmwd2MlmsXH2UyeLo/7dsFpMOXWO02PrlK6vF3lvaFjcmPGW02PZ7PrPF7x9z2Bx4 PDav0PK4fLbUY9OqTjaP3Tcb2Dz6tqxi9Pi8SS6ALSrbJiM1MSW1SCE1Lzk/JTMv3VbJOzje Od7UzMBQ19DSwlxJIS8xN9VWycUnQNctMwfoQiWFssScUqBQQGJxsZK+nU1RfmlJqkJGfnGJ rVJqQUpOgUmBXnFibnFpXrpeXmqJlaGBgZEpUGFCdsaxi7PZCvaJV9xadIa5gbFJuIuRk0NC wERi15pprF2MXBxCArsZJWb07meHcD4xSrydf5gV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tcb2Dz6tqxi9Pi8SS6ALYrLJiU1J7MstUjfLoEr49jF2WwF+8Qr bi06w9zA2CTcxcjBISFgItH2yq6LkYtDSGA7o8T1K7fZuhg5geIyErvv7mSFsIUlVv57zg5R 9JFR4ta/66wgzWwCuhI/mkJBakQEfCUWbHjOCFLDLHCdUeLG9K3MIAlhAR+Jh1vOs4DYLAKq EpPXtrKD9PIK2ErcWxwCMV9eYual72BhTgE7ia5PFSCmEFDFxhnZIBW8AoISJ2c+ARvCDFTd vHU28wRGgVlIUrOQpBYwMq1iFE0tKM5Nz00uMNQrTswtLs1L10vOz93ECA5+raAdjMvW/9U7 xMjEwXiIUYKDWUmEN7SkKk2INyWxsiq1KD++qDQntfgQozQHi5I4r3JOZ4qQQHpiSWp2ampB ahFMlomDU6qBKZLPOOUrq0joO+td2gJhs4p7orOcouq/2GtYyHb6ypuctfz0wWPazQbzmQYX 90odKJvLVneJ7bZW/zff6BmFU6eyn5Q+sNGm66NxabVJ151myUurhSb4HL7ocPixElPLtpCQ 7n+NXbcYjiUUMz9KuzBLy++wzdxjGs9MOxgeXl88T+5Q/9UHzOudX+jKuQj+fBm5eV/GwibJ 1twbv09f/Mbf0r9vg2x1XuX8n40WOo2z/ldttH7n8+9gf12KOVNZds43T4XLzoviPLU5o6x8 7q8T8tz9Lrkz+fT8M4Izm+o/h0t8+O64ZWfzORf9dWafmbT0Bfj9QgIZl95Ov/Uogi+iUszi +ZfgnrlbtG4psRRnJBpqMRcVJwIAw8b35e0CAAA= X-CMS-MailID: 20240627105413epcas5p3384fbacd155f252a861e22cd11ee3b31 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240627105413epcas5p3384fbacd155f252a861e22cd11ee3b31 References: <20240627104552.11177-1-kundan.kumar@samsung.com> Add a new function bio_release_folio() and use it to put refs by npages count. Signed-off-by: Kundan Kumar --- block/bio.c | 7 +------ block/blk.h | 7 +++++++ include/linux/mm.h | 1 + mm/gup.c | 13 +++++++++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/block/bio.c b/block/bio.c index 28281135a3f5..c367378de5c2 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1189,20 +1189,15 @@ void __bio_release_pages(struct bio *bio, bool mark_dirty) struct folio_iter fi; bio_for_each_folio_all(fi, bio) { - struct page *page; size_t nr_pages; - if (mark_dirty) { folio_lock(fi.folio); folio_mark_dirty(fi.folio); folio_unlock(fi.folio); } - page = folio_page(fi.folio, fi.offset / PAGE_SIZE); nr_pages = (fi.offset + fi.length - 1) / PAGE_SIZE - fi.offset / PAGE_SIZE + 1; - do { - bio_release_page(bio, page++); - } while (--nr_pages != 0); + bio_release_folio(bio, fi.folio, nr_pages); } } EXPORT_SYMBOL_GPL(__bio_release_pages); diff --git a/block/blk.h b/block/blk.h index 8c27fd7cc6de..e5de16d26a0e 100644 --- a/block/blk.h +++ b/block/blk.h @@ -543,6 +543,13 @@ static inline void bio_release_page(struct bio *bio, struct page *page) unpin_user_page(page); } +static inline void bio_release_folio(struct bio *bio, struct folio *folio, + unsigned long npages) +{ + if (bio_flagged(bio, BIO_PAGE_PINNED)) + unpin_user_folio(folio, npages); +} + struct request_queue *blk_alloc_queue(struct queue_limits *lim, int node_id); int disk_scan_partitions(struct gendisk *disk, blk_mode_t mode); diff --git a/include/linux/mm.h b/include/linux/mm.h index 9849dfda44d4..b902c6c39e2b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1618,6 +1618,7 @@ void unpin_user_pages_dirty_lock(struct page **pages, unsigned long npages, void unpin_user_page_range_dirty_lock(struct page *page, unsigned long npages, bool make_dirty); void unpin_user_pages(struct page **pages, unsigned long npages); +void unpin_user_folio(struct folio *folio, unsigned long npages); static inline bool is_cow_mapping(vm_flags_t flags) { diff --git a/mm/gup.c b/mm/gup.c index ca0f5cedce9b..bc96efa43d1b 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -488,6 +488,19 @@ void unpin_user_pages(struct page **pages, unsigned long npages) } EXPORT_SYMBOL(unpin_user_pages); +/** + * unpin_user_folio() - release pages of a folio + * @folio: pointer to folio to be released + * @npages: number of pages of same folio + * + * Release npages of the folio + */ +void unpin_user_folio(struct folio *folio, unsigned long npages) +{ + gup_put_folio(folio, npages, FOLL_PIN); +} +EXPORT_SYMBOL(unpin_user_folio); + /* * Set the MMF_HAS_PINNED if not set yet; after set it'll be there for the mm's * lifecycle. Avoid setting the bit unless necessary, or it might cause write