From patchwork Wed Sep 11 06:49:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13800165 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 5286818592A for ; Wed, 11 Sep 2024 10:16:36 +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=1726049799; cv=none; b=LPioFvl3W/pJNd4YnihWJ2R4AxGJVUIT3wEm18wbCoYMC0roor08JydcHBKvWVWHdZOBJgbwpYDJSy9c+frLGZevH+eTVxZxng/T6omIxVgr9tGle+9SsgjCY0BvICYcAOzuZfrM2/6ApHBhlwxDNsFsrhkzSsjZ3FIualtoQJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726049799; c=relaxed/simple; bh=WAkOVAwwamnujEFGE2a4OD68FfuJjjANRzbwtc08quc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=WGY4bMnN6X8JW2ah85cexi+blmPB7QpAARq1WkUPG9920BDkrPD8XDpcF4K508L4PgqMd6tvA9wFWy7d0LIwrqFCIAaeiveUWfzxdH93PxrJwBSgx5jKKXiexBY2R8+2G/dK07GX65J1h5pbtsWCV/TGpQyl5Ukyv9lfW8znBBI= 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=Vhen8FnJ; 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="Vhen8FnJ" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240911101634epoutp04c4fbbc9afab5574e5ae1ab19f4793763~0KSST5PFn0832608326epoutp04j for ; Wed, 11 Sep 2024 10:16:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240911101634epoutp04c4fbbc9afab5574e5ae1ab19f4793763~0KSST5PFn0832608326epoutp04j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1726049794; bh=UzIhHAg39DcSb8cXxMjMCgJSfhKXz707G0JqpnSnnJA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vhen8FnJogT1WXGWqQi2LgUkaF0T/32Kw96ooZKHI/LFPknJ9uZJRwCQbDsSmljO9 jQKt+qruHLGde18Puaod7+6famoOivaSJA3WEqboerKhZ9UEvrnd+q8Q9jwhXnqSQF qRMTR7ZP4Z9kuHQQO4ZpDydtu/f1cC5FpIQCjsD4= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240911101633epcas5p117ca4a0706cf0f47bab4bfaca138a9e6~0KSRskIaY0582305823epcas5p1g; Wed, 11 Sep 2024 10:16:33 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.179]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4X3c1B6M10z4x9Q0; Wed, 11 Sep 2024 10:16:30 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id BA.ED.09743.EFD61E66; Wed, 11 Sep 2024 19:16:30 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240911065714epcas5p485cedd2626301a5920924e93595ba338~0HkQSOnCg0337403374epcas5p4n; Wed, 11 Sep 2024 06:57:14 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240911065714epsmtrp132bf90c11d944d13708beb625760f8cb~0HkQRObvh1549315493epsmtrp1E; Wed, 11 Sep 2024 06:57:14 +0000 (GMT) X-AuditID: b6c32a4a-14fff7000000260f-92-66e16dfe8165 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id C1.CA.08456.A4F31E66; Wed, 11 Sep 2024 15:57:14 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240911065712epsmtip18b08288745893c3a52ffb3743d4175fa~0HkOK07o00656206562epsmtip10; Wed, 11 Sep 2024 06:57:12 +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, vishak.g@samsung.com, gost.dev@samsung.com, Kundan Kumar Subject: [PATCH v10 1/4] block: Added folio-ized version of bio_add_hw_page() Date: Wed, 11 Sep 2024 12:19:32 +0530 Message-Id: <20240911064935.5630-2-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240911064935.5630-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+NgFlrPJsWRmVeSWpSXmKPExsWy7bCmhu6/3IdpBpta9CyaJvxltlh9t5/N 4vv2PhaLmwd2MlmsXH2UyeLo/7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3a+Pi7/U/LhH3eZ8TMQWu13vzrV+nhLvXvj6 sNjbvwlX3PXuXOsqFeGTUWIpzkg01GIuKk4EAKrgBGb4AgAA X-CMS-MailID: 20240911065714epcas5p485cedd2626301a5920924e93595ba338 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240911065714epcas5p485cedd2626301a5920924e93595ba338 References: <20240911064935.5630-1-kundan.kumar@samsung.com> Added new bio_add_hw_folio() function as a wrapper around bio_add_hw_page(). This is a prep patch. Signed-off-by: Kundan Kumar Tested-by: Luis Chamberlain Reviewed-by: Matthew Wilcox (Oracle) --- block/bio.c | 23 +++++++++++++++++++++++ block/blk.h | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/block/bio.c b/block/bio.c index c4053d49679a..f9d759315f4d 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1016,6 +1016,29 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio, return len; } +/** + * 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) +{ + if (len > UINT_MAX || offset > UINT_MAX) + return 0; + return bio_add_hw_page(q, bio, folio_page(folio, 0), len, offset, + max_sectors, same_page); +} + /** * bio_add_pc_page - attempt to add page to passthrough bio * @q: the target queue diff --git a/block/blk.h b/block/blk.h index 1a1a18d118f7..c718e4291db0 100644 --- a/block/blk.h +++ b/block/blk.h @@ -574,6 +574,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 Wed Sep 11 06:49:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13799879 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 4E6D814D456 for ; Wed, 11 Sep 2024 08:38:12 +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=1726043894; cv=none; b=oOF5siqU8MgqiMVj3sJ6jCAnjsucu0yLpDg3bWm9nCXAv68f1THdG0FDzKTOtAcJCqcAPSXsWDYI4Z3Qs0NSclAbfsFIrKgPBr7H97YwjvnnRH7vPVGLz1Df7xdGCf8xBPBpyOr2AXWvMQ5ePbqzjjC//jTINAPjWSsXwvrY65s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726043894; c=relaxed/simple; bh=gphdJCyT8dsY/SC4thVOf8u06Ixv+9Mx+oiojCb0n78=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=b39J+UzpC+VbkQXiK8HUQ4wgU89x+aNsv1X+j20MzlBpRer50YXIA57ssjT6W1kxYM/XsxmkUqEuFUhcwphvqS9jZyQFWczhqpq19iTLAxrgN+6j2hSYWDq0bPf8jXwAMpybqUjbbSt7JZlPysxkr4+Hty+w88wuqym7uS+lOnc= 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=ddYC+B+Y; 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="ddYC+B+Y" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20240911083810epoutp03485ad8715ec41c86d32472dc4c9380aa~0I8Xye7zY2166021660epoutp03K for ; Wed, 11 Sep 2024 08:38:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20240911083810epoutp03485ad8715ec41c86d32472dc4c9380aa~0I8Xye7zY2166021660epoutp03K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1726043890; bh=aVurS7KTKWbGqtF8qmomzgJgC4xAT+DW6fn+FxsUYws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ddYC+B+YHaLLC7GsZBZjI1NRnNkKWcARjIhQNx3ypDmUJsrtjkyp4kcmH7aniAHwI XW6jpln+YaRFUM7KS/wHl74yUkQfnOqFgYwKVjXEBtYz3YFzjWWbvbyuCfq53WYizA 6ej4DD/U27rHE1O+FOv5TYwAYEl9PGuvU1992yaM= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240911083809epcas5p445ac95de7d33e55f5649fd7ef28b6d71~0I8XH5hdK1972819728epcas5p4x; Wed, 11 Sep 2024 08:38:09 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.180]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4X3Yqh3dtJz4x9Q3; Wed, 11 Sep 2024 08:38:08 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 54.E4.09642.0F651E66; Wed, 11 Sep 2024 17:38:08 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240911065717epcas5p2c488df64821b4c40f73460d501d0326d~0HkSfE4ir0582105821epcas5p2w; Wed, 11 Sep 2024 06:57:17 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240911065717epsmtrp15b72d67e4164ce556bb4548f1ae6ae08~0HkSeOjH81549315493epsmtrp1N; Wed, 11 Sep 2024 06:57:17 +0000 (GMT) X-AuditID: b6c32a4b-879fa700000025aa-a0-66e156f0f043 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id F5.2A.08964.D4F31E66; Wed, 11 Sep 2024 15:57:17 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240911065714epsmtip13d995a4f319f8ebc294985d16f46a1ac~0HkQU8Dxs0524005240epsmtip1j; Wed, 11 Sep 2024 06:57:14 +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, vishak.g@samsung.com, gost.dev@samsung.com, Kundan Kumar Subject: [PATCH v10 2/4] block: introduce folio awareness and add a bigger size from folio Date: Wed, 11 Sep 2024 12:19:33 +0530 Message-Id: <20240911064935.5630-3-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240911064935.5630-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+NgFlrHJsWRmVeSWpSXmKPExsWy7bCmlu6HsIdpBpuXC1k0TfjLbLH6bj+b xfftfSwWNw/sZLJYufook8XR/2/ZLCYdusZosfXLV1aLvbe0LW5MeMpose33fGaL87PmsFv8 /jGHzYHXY/MKLY/LZ0s9Nq3qZPPYfbOBzaNvyypGj8+b5ALYorJtMlITU1KLFFLzkvNTMvPS bZW8g+Od403NDAx1DS0tzJUU8hJzU22VXHwCdN0yc4DOVFIoS8wpBQoFJBYXK+nb2RTll5ak KmTkF5fYKqUWpOQUmBToFSfmFpfmpevlpZZYGRoYGJkCFSZkZxx408lS0KdVcfbLMbYGxlmK XYycHBICJhLHz29h6mLk4hAS2M0osXb6d3YI5xOjRPukp1DON0aJ3YdfscG0rPqzlQXEFhLY yyjxa0M2RNFnRol1j64DJTg42AR0JX40hYLUiAi4S0x9+YgRpIZZ4CmjxJUvP1lBEsICMRLv vr5jB7FZBFQlph3cwATSyytgI3F9einELnmJmZe+g5VwCthKHP7xmAnE5hUQlDg58wnYDcxA Nc1bZzODzJcQmMsh0bh3PdShLhKX/sxigbCFJV4d38IOYUtJvOxvg7KzJQ41bmCCsEskdh5p gIrbS7Se6mcGuYdZQFNi/S59iLCsxNRT65gg9vJJ9P5+AtXKK7FjHoytJjHn3VSotTISCy/N gIp7SDRsesQOCbcJjBJrZrpNYFSYheSdWUjemYWweQEj8ypGydSC4tz01GLTAuO81HJ4HCfn 525iBCdcLe8djI8efNA7xMjEwXiIUYKDWUmEt9/uXpoQb0piZVVqUX58UWlOavEhRlNgcE9k lhJNzgem/LySeEMTSwMTMzMzE0tjM0Mlcd7XrXNThATSE0tSs1NTC1KLYPqYODilGpgCV+3a zZV7X/6iXtdPyzddYQ/Ct97sEHmyJMl2wfk3AaU170O7LH1k3j7dOvfOwvkT3ZyiLhbPqb1w 4Z42rwLTncvJPzbz/fkZ8JjJODJZ4pLOaa2O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XtsfSmNKGS KpPXj394S8Vtun8koNox8sbqha/lNjo01ptkyj1cuOhkeP2sCU9e57E927GV/ZyD0PYbawJv Xj50p/mxQc5V7kiW06831npN6DX437D/8yLj/iyTzYs9S1IkrJ889HjkspJ7l8jvGMk/Mgta pe7O8/c3tQq6Gc4QFbbrUtet5ColluKMREMt5qLiRADTehNH+AIAAA== X-CMS-MailID: 20240911065717epcas5p2c488df64821b4c40f73460d501d0326d X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240911065717epcas5p2c488df64821b4c40f73460d501d0326d References: <20240911064935.5630-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. This technique helps to avoid overhead of merging pages which belong to same large order folio. Also folio-ize the functions bio_iov_add_page() and bio_iov_add_zone_append_page() Signed-off-by: Kundan Kumar Tested-by: Luis Chamberlain Reviewed-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) --- block/bio.c | 79 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 18 deletions(-) diff --git a/block/bio.c b/block/bio.c index f9d759315f4d..d8b52bc54549 100644 --- a/block/bio.c +++ b/block/bio.c @@ -931,7 +931,8 @@ static bool bvec_try_merge_page(struct bio_vec *bv, struct page *page, if (!zone_device_pages_have_same_pgmap(bv->bv_page, page)) return false; - *same_page = ((vec_end_addr & PAGE_MASK) == page_addr); + *same_page = ((vec_end_addr & PAGE_MASK) == ((page_addr + off) & + PAGE_MASK)); if (!*same_page) { if (IS_ENABLED(CONFIG_KMSAN)) return false; @@ -1227,8 +1228,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 +1238,61 @@ 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(unsigned int *num_pages, + struct page **pages, unsigned 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 +1312,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 num_pages, i = 0; + size_t offset, folio_offset, left, len; int ret = 0; /* @@ -1322,17 +1354,28 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) goto out; } - for (left = size, i = 0; left > 0; left -= len, i++) { + for (left = size, i = 0; left > 0; left -= len, i += num_pages) { struct page *page = pages[i]; + struct folio *folio = page_folio(page); + + folio_offset = ((size_t)folio_page_idx(folio, page) << + PAGE_SHIFT) + offset; + + len = min(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); offset = 0; } From patchwork Wed Sep 11 06:49:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13799882 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (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 90CF514D6EE for ; Wed, 11 Sep 2024 08:38:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726043903; cv=none; b=QKP+uyYYMH9GTu25IstdtzUZ3d4aYAybI+mbINJrMllNkoH/ov7n5F2rkzYNrwxUJ0JDefipf5tgQRN8Zi8gsR6ht7IMcEWhCKJBiWXfeMI+N0R2+edC+WY49HSvb0cu8EEddAySpz2Hbuf9r3CNuNQUNJcaRpRHwWWCSsfUef0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726043903; c=relaxed/simple; bh=AOOXX/PpXpHShWSxYqscfUQ6a5aimIvfQ/8rvqPY/ZU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=mWJRHo8oHjQWbjmortfZ3QAIBs4zZ5xToccuuruimfL+ftBWLLfXSb8q3d/OrJfkkGkG3Bd1if66Oa1luFg/wzZi4M9py1jiOlbXFV9N6aDqN/SrQSmHrBWEGpGUjkSatSV1JfD/Gji1BQKuey5lOLO89MYepY/SJQpcNLxrgb0= 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=Rbl9SEIW; arc=none smtp.client-ip=203.254.224.25 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="Rbl9SEIW" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240911083814epoutp0221387b6bce43597c24b08ee66700e41d~0I8bYdb0H3006130061epoutp02d for ; Wed, 11 Sep 2024 08:38:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240911083814epoutp0221387b6bce43597c24b08ee66700e41d~0I8bYdb0H3006130061epoutp02d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1726043894; bh=uOnA/n2n1TxoIKZ93GC+m5sD2RuswlYMcSPB6a+VORU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rbl9SEIWOafwG+Cm2DB9ZBDeLWE4zaOaRhK2SQwTx+zuL0LnjCU95Bl4HUmK4rPBN MFc/prSN5OxGSoYSFN7O9ZGkbOJq8jS0RiUQ7L3vknwX0mXIiiX4TNF5qi5E8G8QMQ SBVUuTv9GhRA+PFt5Yt4xoeaNBbb3LZYpNOExUlc= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240911083813epcas5p4c130ed6eb77c979d16c01e1a9a90bec6~0I8a21VOV2676726767epcas5p4h; Wed, 11 Sep 2024 08:38:13 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.176]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4X3Yql1Z13z4x9Py; Wed, 11 Sep 2024 08:38:11 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 8A.1C.09743.2F651E66; Wed, 11 Sep 2024 17:38:11 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240911065719epcas5p2c9312abec1eada7df3d08c883f1557bb~0HkUocEqy0581905819epcas5p2x; Wed, 11 Sep 2024 06:57:19 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240911065719epsmtrp277700653aa42902d09727b95c5099461~0HkUnoNmc0673206732epsmtrp2l; Wed, 11 Sep 2024 06:57:19 +0000 (GMT) X-AuditID: b6c32a4a-3b1fa7000000260f-96-66e156f295f3 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 05.D1.19367.F4F31E66; Wed, 11 Sep 2024 15:57:19 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240911065717epsmtip16623d3a9a4808b44c00f3a979fb525f6~0HkSnPV3l0661206612epsmtip1Z; Wed, 11 Sep 2024 06:57:17 +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, vishak.g@samsung.com, gost.dev@samsung.com, Kundan Kumar Subject: [PATCH v10 3/4] mm: release number of pages of a folio Date: Wed, 11 Sep 2024 12:19:34 +0530 Message-Id: <20240911064935.5630-4-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240911064935.5630-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+NgFlrLJsWRmVeSWpSXmKPExsWy7bCmhu7nsIdpBusbmCyaJvxltlh9t5/N 4vv2PhaLmwd2MlmsXH2UyeLo/7dsFpMOXWO02PrlK6vF3lvaFjcmPGW02PZ7PrPF+Vlz2C1+ /5jD5sDrsXmFlsfls6Uem1Z1snnsvtnA5tG3ZRWjx+dNcgFsUdk2GamJKalFCql5yfkpmXnp tkrewfHO8aZmBoa6hpYW5koKeYm5qbZKLj4Bum6ZOUBnKimUJeaUAoUCEouLlfTtbIryS0tS FTLyi0tslVILUnIKTAr0ihNzi0vz0vXyUkusDA0MjEyBChOyMx4/bWUs6OermPrzBVsD41Xu LkZODgkBE4mG/6eZQWwhgd2MEhfn1HYxcgHZnxgl/q6Yxgbn3OiaxAzT8XQRSAdIYiejxJ6P 81kgnM+MEg17zwO1cHCwCehK/GgKBWkQEXCXmPryESNIDbPAU0aJK19+soLUCAvYS1ybY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JxNNFp5lBbCGB7YwSX1f6QsRlJHbf3ckKYQtLrPz3nL2L kQuo5iOjxPeF31m6GDk42AR0JX40hYLUiAj4SizY8JwRxGYWeM8ocXuJNEiJsIC9xLUJJiBh FgFViXs3DrGChHkFbCQ+/qmHmC4vMfPSd3YQm1PAVuLwj8dMENfYSPzZ0Ap2Aa+AoMTJmU9Y IKbLSzRvnc08gVFgFpLULCSpBYxMqxhFUwuKc9NzkwsM9YoTc4tL89L1kvNzNzGC40AraAfj svV/9Q4xMnEwHmKU4GBWEuHtt7uXJsSbklhZlVqUH19UmpNafIhRmoNFSZxXOaczRUggPbEk NTs1tSC1CCbLxMEp1cCUbZSVym9o79gvuu/oXt0dF1asbckwznEqW7i5Uj7gKNP0nFcl/1Kr T6snavz9Y7c1aOaXzz37ErOtNT9fUW9X+dZ76Y/R2TD+Z8WlLNla9SmaZyzOzRb8LPplbsnv ax1thzX4gjdFHctYlqa3+oDBxUfJLQIPXFo4FPK9uY76/TfdsTnLNyfRcX6Kfa/7q5Zqrc7H PG7lLdJWyc8vT7P6k3q/dV2q1ZkjrVH6nQU3PhoHbM+Z9GPWIm9ftrlnF8gveFTN4Db977aj h6rVhNbs/f4/L7+N+xh7kSqr+7qVigfOW15zL+i0ferQUcGs8qFl4WH/rgNHZ3pJ5fI+N8uf dsn8bnePFcMCpkrPNCWW4oxEQy3mouJEAKoZomDyAgAA X-CMS-MailID: 20240911065719epcas5p2c9312abec1eada7df3d08c883f1557bb X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240911065719epcas5p2c9312abec1eada7df3d08c883f1557bb References: <20240911064935.5630-1-kundan.kumar@samsung.com> Add a new function unpin_user_folio() to put the refs of a folio by npages count. The check for BIO_PAGE_PINNED flag is removed as it is already checked in bio_release_pages(). Signed-off-by: Kundan Kumar Tested-by: Luis Chamberlain Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 1 + mm/gup.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 6549d0979b28..3de55d295cb9 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1597,6 +1597,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); void unpin_folios(struct folio **folios, unsigned long nfolios); static inline bool is_cow_mapping(vm_flags_t flags) diff --git a/mm/gup.c b/mm/gup.c index 54d0dc3831fb..02c46ae33028 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -415,6 +415,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); + /** * unpin_folios() - release an array of gup-pinned folios. * @folios: array of folios to be marked dirty and released. From patchwork Wed Sep 11 06:49:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13799881 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 60904155386 for ; Wed, 11 Sep 2024 08:38:18 +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=1726043900; cv=none; b=i7QOAGE0slOb0bjl20N6niYoqST3+whb6HVXXa3X8AsDzJGDaceBwF3QgVIzb5cmxztSpthao7viBrROZu2cgDG8KCV0dHp3rnjpb/yGD3JxSWcd/wwNVi+QAl+LARVpqtZjgsA4IMO72wzngn4qtj99R2uhUXwM3FaJZJx72zs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726043900; c=relaxed/simple; bh=dtlegLlU07witWvTzTwbtRmeFKQGBkFF+O7xn7lU2gY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=JzzN1CH+0g1QRQSH+5BkeT/e4k3JXl8HXUZM/Myoo2bm0dG5iA+Ssutb/ESyraFPJbQzZFWJee0k8sqdOE9rKIwhHfMsGkvqXlivaHD5QCuU2ebgYOauyIXUDp19mvsk3KrcqsPFKFmpyyw/ZH7M+xiyrkPJ+8YQ0H6hP+elgOA= 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=AFnfIKGf; 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="AFnfIKGf" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240911083816epoutp04329e2d6aff16fa4f37a1b9e4b3f72c32~0I8dZ6zU81125711257epoutp04W for ; Wed, 11 Sep 2024 08:38:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240911083816epoutp04329e2d6aff16fa4f37a1b9e4b3f72c32~0I8dZ6zU81125711257epoutp04W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1726043896; bh=CSqhCksDJDKePWzl3I60/6bY4Ms7uxfAgICqp6nPHOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AFnfIKGfGd42bucbT3cVIFgghMxCvn7MTmUNnYRZ+mg3lHNX98WWiRpU2DdbdE/qs 1YoCU21N6TYIrRvyIYfbSolzfaByW0gfE+5fdn5/OvQbrhXBR13y3AbseT18lPm4EK M0XS7j7XpMBSBobeQX2lsjTBjPfS3rhqS/vFDmV4= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240911083815epcas5p39d028b0b9ccc26ed236b7f776cd76244~0I8dGSqBn0410304103epcas5p3h; Wed, 11 Sep 2024 08:38:15 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.183]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4X3Yqn4N9Fz4x9QR; Wed, 11 Sep 2024 08:38:13 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 13.8C.19863.5F651E66; Wed, 11 Sep 2024 17:38:13 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240911065722epcas5p29397d448658d52c5ef511138a6e7ed7d~0HkXMs0F00582105821epcas5p26; Wed, 11 Sep 2024 06:57:22 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240911065722epsmtrp1e586ff15c8486ca2663032f3d1f2934d~0HkXL8RR51549315493epsmtrp1Z; Wed, 11 Sep 2024 06:57:22 +0000 (GMT) X-AuditID: b6c32a50-c73ff70000004d97-a0-66e156f5850e Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E0.8D.07567.25F31E66; Wed, 11 Sep 2024 15:57:22 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240911065719epsmtip105fd36ad2e4cb91dd35a8eb459bbf2a1~0HkUxBIUF0661306613epsmtip1K; Wed, 11 Sep 2024 06:57:19 +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, vishak.g@samsung.com, gost.dev@samsung.com, Kundan Kumar Subject: [PATCH v10 4/4] block: unpin user pages belonging to a folio at once Date: Wed, 11 Sep 2024 12:19:35 +0530 Message-Id: <20240911064935.5630-5-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240911064935.5630-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+NgFtrIJsWRmVeSWpSXmKPExsWy7bCmuu7XsIdpBj+my1s0TfjLbLH6bj+b xfftfSwWNw/sZLJYufook8XR/2/ZLCYdusZosfXLV1aLvbe0LW5MeMpose33fGaL87PmsFv8 /jGHzYHXY/MKLY/LZ0s9Nq3qZPPYfbOBzaNvyypGj8+b5ALYorJtMlITU1KLFFLzkvNTMvPS bZW8g+Od403NDAx1DS0tzJUU8hJzU22VXHwCdN0yc4DOVFIoS8wpBQoFJBYXK+nb2RTll5ak KmTkF5fYKqUWpOQUmBToFSfmFpfmpevlpZZYGRoYGJkCFSZkZzTP6WYtaOWvWHdvNVMD43Se LkZODgkBE4kzC9uZuhi5OIQE9jBKNBzexwLhfGKUODV7MzuE841R4vGO7UBlHGAtr74nQcT3 MkqcebsKquMzo8SrM88ZQYrYBHQlfjSFgqwQEXCXmPryESNIDbPAU0aJK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pRfp2CVwZzXO6 WQta+SvW3VvN1MA4naeLkYNDQsBE4tX3pC5GLg4hgd2MEgd6JzF1MXICxWUkdt/dyQphC0us /PecHaLoI6PEurvP2UCa2QR0JX40hYLUiAj4SizY8JwRxGYWeM8ocXuJNIgtDBT/NH0D2EwW AVWJFxePMoPYvAI2EpM+rGWDmC8vMfPSd3YQm1PAVuLwj8dg9UJANX82tLJC1AtKnJz5hAVi vrxE89bZzBMYBWYhSc1CklrAyLSKUTK1oDg3PTfZsMAwL7Vcrzgxt7g0L10vOT93EyM4JrQ0 djDem/9P7xAjEwfjIUYJDmYlEd5+u3tpQrwpiZVVqUX58UWlOanFhxilOViUxHkNZ8xOERJI TyxJzU5NLUgtgskycXBKNTApRppcTVkb+v7do3MmLc/fXT1+snnnf6Z/7GFr3l3y3PTvRM6B bVPLSnXWbrxlP/V5Ss6B2kusR9TPCh+QKy4K+tAquXXJzcauTK1K13c5L1OdZdprwj853T19 idFk+unLDbdm6Jv+vvUh7Oha2UL3OaFFFn22lfyRBrxuJh8f7d7vdjtgKW+xwaRz75Uia45Y thZcvvb5EJuGS5XJG9ePa9Z67PhoWsh0Zc1hk9XukjxabgFcNfkWjI9KDsusnDo1YH/u3Ihl LRo5HjVb3qQ5fpjQyr7m1J5FjPNPachN4j/+5N3EX9NadS0sgte2Jeg9ZQvb8DnTNUbgxZdz T+5c5nizTO4Ua9pmofjVetcuKrEUZyQaajEXFScCAKrd/qL4AgAA X-CMS-MailID: 20240911065722epcas5p29397d448658d52c5ef511138a6e7ed7d X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240911065722epcas5p29397d448658d52c5ef511138a6e7ed7d References: <20240911064935.5630-1-kundan.kumar@samsung.com> Use newly added mm function unpin_user_folio() to put refs by npages count. Signed-off-by: Kundan Kumar Tested-by: Luis Chamberlain --- block/bio.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/block/bio.c b/block/bio.c index d8b52bc54549..ac4d77c88932 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1190,7 +1190,6 @@ 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) { @@ -1198,12 +1197,9 @@ void __bio_release_pages(struct bio *bio, bool mark_dirty) 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); + unpin_user_folio(fi.folio, nr_pages); } } EXPORT_SYMBOL_GPL(__bio_release_pages); @@ -1241,8 +1237,8 @@ static int bio_iov_add_folio(struct bio *bio, struct folio *folio, size_t len, folio_page(folio, 0), len, offset, &same_page)) { bio->bi_iter.bi_size += len; - if (same_page) - bio_release_page(bio, folio_page(folio, 0)); + if (same_page && bio_flagged(bio, BIO_PAGE_PINNED)) + unpin_user_folio(folio, 1); return 0; } bio_add_folio_nofail(bio, folio, len, offset); @@ -1258,8 +1254,8 @@ static int bio_iov_add_zone_append_folio(struct bio *bio, struct folio *folio, 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, folio_page(folio, 0)); + if (same_page && bio_flagged(bio, BIO_PAGE_PINNED)) + unpin_user_folio(folio, 1); return 0; }