From patchwork Thu Jul 4 07:03:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13723372 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 764EC1A38F9 for ; Thu, 4 Jul 2024 08:02:02 +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=1720080124; cv=none; b=mXxJAX2ke7B6hwQZ7h0bSK8qxSlZI3svEhJviHquInkGaFvFP+Ie05hStBYOBN+FVMh2IKSSWD5SUoTmxSi2Syv1X/nAu4qiqdinz7MVnkDOgyGSITgL0FobKn2mFO9vioULmq9Q/2TGQKv2/LyZxgIoP3ejpinwVmF/HpoVo/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720080124; c=relaxed/simple; bh=hNUQ67ZVEN3DNgwF+lZ5HRlC7EC3f5effW9v6MlmfhI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=odpoaEfK15gXpsIE8J4TyFWtuzMC3dMJKVPFXX4aRELzLpiU+IIzyP3R+SI/qoBLCriXNILVnukAnqRmKO5I+p/nIlhsC3CyBWwNZnkCfN3elh0YlKa8OWioSxzSYoFhZnb3HYUXe4QtCxO0H2c7QUQuI6kc0m5fxYahTObR020= 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=GMhF3a+L; 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="GMhF3a+L" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20240704080200epoutp03cfdcbe9b1882b346a57c61e617ba3c04~e88Gge7yB1806918069epoutp039 for ; Thu, 4 Jul 2024 08:02:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20240704080200epoutp03cfdcbe9b1882b346a57c61e617ba3c04~e88Gge7yB1806918069epoutp039 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1720080120; bh=FAgmrDRvLDUpW+VRyqQXXE6A2RXvHS99RuUFNiqOOlc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GMhF3a+L/jYKr5aJfXkkilcMiZA/9v9T56XnqqlTesBce8JgaMdflq0VsyBG1LJ4c cacIsH0Nfud6b9ghJvR8aTp+pF1DA/31kTW8cBywzTc1Qc04HPwqiw5rIZyLQHP/L/ TKby9lIYurgkwYSSGi9Ymj6GHqjOH7MA5ZlZTE5Y= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240704080200epcas5p2e9b016b7ba18cdd472050711b9f00e32~e88GHmsLw0737207372epcas5p2i; Thu, 4 Jul 2024 08:02:00 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.182]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4WF8Hn73wLz4x9QH; Thu, 4 Jul 2024 08:01:57 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 6D.A7.09989.4F656866; Thu, 4 Jul 2024 17:01:56 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240704071122epcas5p12a52967e486a69375ee77db86f2594a0~e8P5GjRP31116911169epcas5p1N; Thu, 4 Jul 2024 07:11:22 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240704071122epsmtrp289bcc797feab911bbb9b88a3e47641df~e8P5Fu_bL0957709577epsmtrp2z; Thu, 4 Jul 2024 07:11:22 +0000 (GMT) X-AuditID: b6c32a4a-bffff70000002705-e6-668656f43a92 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 73.28.29940.A1B46866; Thu, 4 Jul 2024 16:11:22 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240704071120epsmtip2451f355e56c8c475c6ff776b5351222f~e8P3O_Dx31296012960epsmtip2J; Thu, 4 Jul 2024 07:11:20 +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 v7 1/4] block: Added folio-lized version of bvec_try_merge_hw_page() Date: Thu, 4 Jul 2024 12:33:54 +0530 Message-Id: <20240704070357.1993-2-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240704070357.1993-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+NgFlrFJsWRmVeSWpSXmKPExsWy7bCmpu6XsLY0g1MH1SyaJvxltlh9t5/N 4vv2PhaLmwd2Mlms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Tr0dxdNN 1qyUfpQksHjHAffVHUosxRmJhlrMRcWJAI6PwrT1AgAA X-CMS-MailID: 20240704071122epcas5p12a52967e486a69375ee77db86f2594a0 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240704071122epcas5p12a52967e486a69375ee77db86f2594a0 References: <20240704070357.1993-1-kundan.kumar@samsung.com> Added new function bvec_try_merge_hw_folio(). This is a prep patch. Signed-off-by: Kundan Kumar Reviewed-by: Christoph Hellwig --- block/bio.c | 17 +++++++++++++++++ block/blk.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/block/bio.c b/block/bio.c index e9e809a63c59..c10f5fa0ba27 100644 --- a/block/bio.c +++ b/block/bio.c @@ -952,6 +952,23 @@ bool bvec_try_merge_hw_page(struct request_queue *q, struct bio_vec *bv, struct page *page, unsigned len, unsigned offset, bool *same_page) { + struct folio *folio = page_folio(page); + + return bvec_try_merge_hw_folio(q, bv, folio, len, + ((size_t)folio_page_idx(folio, page) << PAGE_SHIFT) + + offset, same_page); +} + +/* + * Try to merge a folio into a segment, while obeying the hardware segment + * size limit. This is not for normal read/write bios, but for passthrough + * or Zone Append operations that we can't split. + */ +bool bvec_try_merge_hw_folio(struct request_queue *q, struct bio_vec *bv, + struct folio *folio, size_t len, size_t offset, + bool *same_page) +{ + struct page *page = folio_page(folio, 0); unsigned long mask = queue_segment_boundary(q); phys_addr_t addr1 = page_to_phys(bv->bv_page) + bv->bv_offset; phys_addr_t addr2 = page_to_phys(page) + offset + len - 1; diff --git a/block/blk.h b/block/blk.h index 47dadd2439b1..17478657c5ef 100644 --- a/block/blk.h +++ b/block/blk.h @@ -94,6 +94,10 @@ bool bvec_try_merge_hw_page(struct request_queue *q, struct bio_vec *bv, struct page *page, unsigned len, unsigned offset, bool *same_page); +bool bvec_try_merge_hw_folio(struct request_queue *q, struct bio_vec *bv, + struct folio *folio, size_t len, size_t offset, + bool *same_page); + static inline bool biovec_phys_mergeable(struct request_queue *q, struct bio_vec *vec1, struct bio_vec *vec2) { From patchwork Thu Jul 4 07:03:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13723373 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 7298A18637 for ; Thu, 4 Jul 2024 08:02:11 +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=1720080133; cv=none; b=aS+knk05RwwkcHs2Q/AgIf+L5YiGcSBsqqvtg1HyT27CfNQAU5zMqkcKtj9kMNsnJe9TNXrvX1EWwAFU3oroL6y87shLDKQs7aTfEUtHaDe4KrCm8UvmI2XI7nvndPYaLejIuC6oEEFXW6e45aO8+kNi4aFeGrejl8wAsBk+Xis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720080133; c=relaxed/simple; bh=RUPBTsuCCMz3bH/NxphWPI4KU8Jh6d2AesWl/vnCbno=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=pm7RDCosIZYWUW8OnX1YrzUcJ+a87MI4dU8lLpC7bLL5oiu1Ri3UUZYrC5hA/0h3zja1jGYHyucl/xfamZh6nG7rlmKJ+hheg7GwtjYQK+WzTTawnxuUAPWYQgLCUGPOkivvnZ6q3qdloHJA5Yji/RWuLvhx/xk+Wr6M19bym60= 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=po2CGivw; 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="po2CGivw" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240704080208epoutp020dcf16bd25c10b82f2391f9d7cf1ed04~e88N8qpwc2819828198epoutp02N for ; Thu, 4 Jul 2024 08:02:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240704080208epoutp020dcf16bd25c10b82f2391f9d7cf1ed04~e88N8qpwc2819828198epoutp02N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1720080128; bh=C3COj6yzvcsM80qGx7kwUsuNpzi9iGWUY6hjfKEM+vs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=po2CGivwiuxO+64741eB7UY+H9AVDN6vyVFa0vOF+McdL2PbHJ+4mxGXQNq2Awn76 GkiLbfh+q+aJwNsapPVvDfddrN5Rf9jcNm86dj2yBj/nQfUSDAGSrvqJLpO8r4f3Oo iQ7mwk0HFFae0nGYORvkjQk4YWRKxhdjU420qfRs= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240704080207epcas5p4d3f9da8ae6311826ca69191d24fa2934~e88NMQbEU1450214502epcas5p4h; Thu, 4 Jul 2024 08:02:07 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.182]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4WF8Hx4v5Cz4x9Pt; Thu, 4 Jul 2024 08:02:05 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 85.B7.09989.AF656866; Thu, 4 Jul 2024 17:02:02 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240704071126epcas5p2572342c5d25c3292a9a39cb8c798a42c~e8P8grwLG3204032040epcas5p2q; Thu, 4 Jul 2024 07:11:26 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240704071126epsmtrp1a6fec1ee346bd33da9604e91282ecfc3~e8P8fMD_O0702607026epsmtrp1S; Thu, 4 Jul 2024 07:11:26 +0000 (GMT) X-AuditID: b6c32a4a-e57f970000002705-fe-668656fa7ff6 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 9B.C8.19057.E1B46866; Thu, 4 Jul 2024 16:11:26 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240704071123epsmtip2092a1d540d185f03192f077640be5e42~e8P6KfB9a1296012960epsmtip2K; Thu, 4 Jul 2024 07:11:23 +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 v7 2/4] block: Added folio-lized version of bio_add_hw_page() Date: Thu, 4 Jul 2024 12:33:55 +0530 Message-Id: <20240704070357.1993-3-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240704070357.1993-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+NgFlrFJsWRmVeSWpSX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Zf9FbRM5NvqWrD1n/eDI15kReoXvzz8y2dbiHpkYM3tqqZ5ZlUGSoJnF /Iv7l3ctEenJV+QxVWIpzkg01GIuKk4EANRWPm30AgAA X-CMS-MailID: 20240704071126epcas5p2572342c5d25c3292a9a39cb8c798a42c X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240704071126epcas5p2572342c5d25c3292a9a39cb8c798a42c References: <20240704070357.1993-1-kundan.kumar@samsung.com> Added new bio_add_hw_folio() function. This is a prep patch. Signed-off-by: Kundan Kumar Reviewed-by: Christoph Hellwig --- block/bio.c | 32 +++++++++++++++++++++++++++----- block/blk.h | 4 ++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/block/bio.c b/block/bio.c index c10f5fa0ba27..05d624f016f0 100644 --- a/block/bio.c +++ b/block/bio.c @@ -996,6 +996,30 @@ bool bvec_try_merge_hw_folio(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); + + return bio_add_hw_folio(q, bio, folio, len, + ((size_t)folio_page_idx(folio, page) << PAGE_SHIFT) + + 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; @@ -1009,8 +1033,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_folio(q, bv, folio, len, offset, + same_page)) { bio->bi_iter.bi_size += len; return len; } @@ -1027,9 +1051,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 17478657c5ef..0c8857fe4079 100644 --- a/block/blk.h +++ b/block/blk.h @@ -534,6 +534,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 Jul 4 07:03:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13723374 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 4C7BD1A0AE0 for ; Thu, 4 Jul 2024 08:02:13 +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=1720080135; cv=none; b=OxHKHio8M4LXqige+6+czZEWldZrtf1b41HxL6jKT/NfKlD/md2ncnqPmrzTM8typ7+Am0rUZnKX/kOc/Y9i/mRC5aMnt/EBgc3VQKx+/r8CoSmGrKail/rWuAUI1jNjkM8/wtsw5OJxCKsisWf4QptscYkk41idobxC/+u0g6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720080135; c=relaxed/simple; bh=eCpbEk1K12ePXWai2MBUhBsul4wZ2/1YtiCE/H0Acsg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=jY6mQLuaK/kIHxsXLdbyFIAKZ8Q401aUpVnj+1wIa40uUgTxOvFvLMXuqs00CmeA6Whl+fuTbZhnbbKOvrmoZ2KkoByZpv+4M+4+/d2hbaJ5RN9vZHERdt9Dr9F8V5e17tdhll2Qkepi8iqNVI+bCZnZzPxhdyPrdWcuSA5hb+w= 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=O1yXmHGf; 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="O1yXmHGf" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240704080211epoutp0426c636281e862e449e8a04061e3fa020~e88QmHaPE0205702057epoutp04_ for ; Thu, 4 Jul 2024 08:02:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240704080211epoutp0426c636281e862e449e8a04061e3fa020~e88QmHaPE0205702057epoutp04_ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1720080131; bh=yegwE09m26FWH64rUFlry2fVF/9zd8SeheQSpERjDmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O1yXmHGfWjb9PExQBDgXyfKxFodmlpZVFXVsiBjjnmZxBBUDNNK6bTFpCZKqTNyhn 2VBgmNc0iLcmKuIPB7GGmZ5qaFQOnVol1uinzG9PoT1uchBkYq+l5ghHVo2v85fgkX YWUbqDYv1iCVhvJyj1QFVeLEL0l7IDu9nhyORwpg= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240704080211epcas5p4349f73f26f5dbbc0c63deb5332ff9cb1~e88QLHxmg2264922649epcas5p4b; Thu, 4 Jul 2024 08:02:11 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.175]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4WF8J11TChz4x9QR; Thu, 4 Jul 2024 08:02:09 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id B6.F4.11095.EF656866; Thu, 4 Jul 2024 17:02:06 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240704071130epcas5p131b210c30237386f2c786e81c88355f6~e8QAC33JL0634606346epcas5p1C; Thu, 4 Jul 2024 07:11:30 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240704071130epsmtrp1255e05321ba5ebdf900fac29ca016a87~e8QAB-bQz0734707347epsmtrp1B; Thu, 4 Jul 2024 07:11:30 +0000 (GMT) X-AuditID: b6c32a49-423b770000012b57-aa-668656fe9086 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 56.3B.18846.12B46866; Thu, 4 Jul 2024 16:11:29 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240704071127epsmtip2ec6fa7aa852b6a246383b85727a04e0a~e8P9i2gjr1296012960epsmtip2L; Thu, 4 Jul 2024 07:11:27 +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 v7 3/4] block: introduce folio awareness and add a bigger size from folio Date: Thu, 4 Jul 2024 12:33:56 +0530 Message-Id: <20240704070357.1993-4-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240704070357.1993-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+NgFlrNJsWRmVeSWpSXmKPExsWy7bCmpu6/sLY0gzN7pC2aJvxltlh9t5/N 4vv2PhaLmwd2MlmsXH2UyeLo/7dsFpMOXWO02PrlK6vF3lvaFjcmPGW02PZ7PrPF7x9z2Bx4 PDav0PK4fLbUY9OqTjaP3Tcb2Dz6tqxi9Pi8SS6ALSrbJiM1MSW1SCE1Lzk/JTMv3VbJOzje Od7UzMBQ19DSwlxJIS8xN9VWycUnQNctMwfoQiWFssScUqBQQGJxsZK+nU1RfmlJqkJGfnGJ rVJqQUpOgUmBXnFibnFpXrpeXmqJlaGBgZEpUGFCdsaLHbEFLeoVaxb9Zm1gvCLXxcjJISFg IrHg80vmLkYuDiGB3YwSlxY8YIVwPjFK7GrpYoZzzkxcxgbTsm/rbjaIxE5GiT+rFkE5nxkl bs87D9TCwcEmoCvxoykUpEFEwF1i6stHjCA1zAJnGSVOTH3EApIQFoiWuH//FTOIzSKgKnFi 3XImEJtXwEbix68jzBDb5CVmXvrODmJzCthKdPyaxghRIyhxcuYTsDnMQDXNW2eDnSoh0Msh 8WfZanaIZheJc/e3MUHYwhKvjm+BiktJvOxvg7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s4OYnMK2Ep0/JrGCGILAdXcu3meBaJeUOLkzCdgNjNQffPW 2cwTGAVmIUnNQpJawMi0ilE0taA4Nz03ucBQrzgxt7g0L10vOT93EyM4BrSCdjAuW/9X7xAj EwfjIUYJDmYlEV6p981pQrwpiZVVqUX58UWlOanFhxilOViUxHmVczpThATSE0tSs1NTC1KL YLJMHJxSDUwyi14ut382p/xme3ik/lTbnQx3F2WFnSgUjr5jMePcWgPBXwUOQtPnLL/47anN Zxau84x/FHy013MLlv7vtlh4aWukXMX00rM3L+wrirdZxD85/PeyzSf3NLgytWzV2vrp05dX KgIblhqXRXHUV846vuGnZm5r99HOJ9efTDl8lev7bauUNb6FQlu9p2tx28Q53J80s/p088zN LrNLltqfqW79Os186+OcFBOOK1HXXMTmPAzOcdINUk8NzbxUZ3T9sYXc0nXCITuWscVGVVd7 HHhaGzv3kGXMvXcXvx0TZ1Pmca94cSDyieCG6ph1fxaks3n7ST02MrLZeVxtzl1u2/6S+uJN nVuCBf6uzbVUYinOSDTUYi4qTgQAxfOMHfACAAA= X-CMS-MailID: 20240704071130epcas5p131b210c30237386f2c786e81c88355f6 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240704071130epcas5p131b210c30237386f2c786e81c88355f6 References: <20240704070357.1993-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 Reviewed-by: Christoph Hellwig --- block/bio.c | 77 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 16 deletions(-) diff --git a/block/bio.c b/block/bio.c index 05d624f016f0..32c9c6d80384 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1243,8 +1243,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; @@ -1253,30 +1253,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 *)) /** @@ -1296,9 +1327,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; /* @@ -1340,15 +1371,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 = ((size_t)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 Jul 4 07:03:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13723375 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 F0B1A1A0AE0 for ; Thu, 4 Jul 2024 08:02:16 +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=1720080138; cv=none; b=Wm7j2ans68iTxW+W1TsNyUdkKNLlv30E8IU57keQ4Q2n1Ypbh16KHlB3RwCtEePplnBxCoLSSQYMglAo36fwdUZyRHOAXLIFhGmaxk44LPUxxs0plUyMhpug8xcUJSsfM39bkuWtjSEhPohoUYz4P7bx0tW1E0beorH+7t3IJEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720080138; c=relaxed/simple; bh=BaXjJSTCGyNPM4Udc8hEgVtLoly6k43XUS4eKNnx7JQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=ZL3wBOwos/AknhzP5dSOSiQo8DIS7ClGEotnFuPyCfGEcApPMiX/Upb9UcIaiEdxcus4n6bz9KhExj+aRDBWdJ9hDdV1NhTpFGlfGAYOUAz6rSUBHGec3W2XMIUXC2tyBmCWsgMxRSMXP7/0lJatvXTvVrBsZnPwl+PsydO6Dzw= 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=ZiFW2QVV; 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="ZiFW2QVV" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240704080215epoutp016e2e1ea51b8fedf9b8b9cd8fe62da3f8~e88T4sYTH3040630406epoutp01N for ; Thu, 4 Jul 2024 08:02:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240704080215epoutp016e2e1ea51b8fedf9b8b9cd8fe62da3f8~e88T4sYTH3040630406epoutp01N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1720080135; bh=mmXLAMm20kZ9sA7M0jMUFOOHuzSAh1ATl08lEFOf+3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZiFW2QVV9aScEl96vGYuliuZghh79RTjXr7T8BTyIUYb1+Kvfj4o5HnDQONAVvdL+ ekqaYo40uT2gEe0alZLGydgdiatbjyj4B0c9Me1hKBYpTthJMHRIl5X7rtRmnDv7FZ B0dLk/lVLsmrZY1CfEF7YjRpl7OeZKHD53eD+kt8= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240704080214epcas5p19419fe1e86d7caba1b5c9cd8e0973939~e88TVBasJ1028410284epcas5p1l; Thu, 4 Jul 2024 08:02:14 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.181]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4WF8J41pV9z4x9QP; Thu, 4 Jul 2024 08:02:12 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 98.F4.11095.20756866; Thu, 4 Jul 2024 17:02:10 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240704071134epcas5p2ec6160369e9092de98a051e05750bd4f~e8QEQ0qX10606106061epcas5p29; Thu, 4 Jul 2024 07:11:34 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240704071134epsmtrp12b48dbf6ec9fef05883975c33dab9a6a~e8QEP-zFQ0702607026epsmtrp1c; Thu, 4 Jul 2024 07:11:34 +0000 (GMT) X-AuditID: b6c32a49-423b770000012b57-b6-668657028597 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id F9.41.07412.62B46866; Thu, 4 Jul 2024 16:11:34 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240704071131epsmtip2e63a283d3e3e3c25173c1ba6606c39e9~e8QBQOscN1296012960epsmtip2N; Thu, 4 Jul 2024 07:11:31 +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 v7 4/4] block: unpin user pages belonging to a folio at once Date: Thu, 4 Jul 2024 12:33:57 +0530 Message-Id: <20240704070357.1993-5-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240704070357.1993-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+NgFlrGJsWRmVeSWpSXmKPExsWy7bCmhi5TeFuawZJz/BZNE/4yW6y+289m 8X17H4vFzQM7mSxWrj7KZHH0/1s2i0mHrjFabP3yldVi7y1tixsTnjJabPs9n9ni9485bA48 HptXaHlcPlvqsWlVJ5vH7psNbB59W1YxenzeJBfAFpVtk5GamJJapJCal5yfkpmXbqvkHRzv HG9qZmCoa2hpYa6kkJeYm2qr5OIToOuWmQN0oZJCWWJOKVAoILG4WEnfzqYov7QkVSEjv7jE Vim1ICWnwKRArzgxt7g0L10vL7XEytDAwMgUqDAhO2PGfYeCf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/1s2i0mHrjFabP3yldVi7y1tixsTnjJabPs9n9ni9485bA48 HptXaHlcPlvqsWlVJ5vH7psNbB59W1YxenzeJBfAFsVlk5Kak1mWWqRvl8CVMeO+Q8E+8YrO D9/ZGxibhLsYOTkkBEwk9je1sXYxcnEICexmlHgyoYUFIiEjsfvuTlYIW1hi5b/n7BBFHxkl NnYuYu5i5OBgE9CV+NEUClIjIuArsWDDc0aQGmaB64wSN6ZvBasRFvCRePQWrIZFQFWi7ctH sPm8AjYSL1YcZYaYLy8x89J3dhCbU8BWouPXNEYQWwio5t7N81D1ghInZz4Bs5mB6pu3zmae wCgwC0lqFpLUAkamVYySqQXFuem5yYYFhnmp5XrFibnFpXnpesn5uZsYwZGgpbGD8d78f3qH GJk4GA8xSnAwK4nwSr1vThPiTUmsrEotyo8vKs1JLT7EKM3BoiTOazhjdoqQQHpiSWp2ampB ahFMlomDU6qBSTekJzP020T9tO5QqZgEDrYmQf2ZlRcOKrobC9adCmH6fldXv9X/dHHq5FU/ N/yKrzz5faa6Ts3e9S6vH3mVmW86wP5PxsPea9sUwQCWiATT4F/+SUYLnHZ7LttTMWnnnAeN K3h3iTgsPlnts+2oMVOc8gPlG4v0G/9ksP3d+m33jf1KU6r/PVJ7l3jrbK7z2npXyVsic69t WJZ5XI1ty+0J9XxB6Xyr/Lkrfsqsf3/thLihYZJBIb/j/oTbF5tFOKYkq6vFBRccPCvC3Kd9 8817rrgDFov2z13tKvdtxv62VC6+t8uWZO9xe7BD4s/xZxaPhYPXPbi6J++yyfS6S/dLJkiF 5LTsmRvyi22zuBJLcUaioRZzUXEiAOcqTIvzAgAA X-CMS-MailID: 20240704071134epcas5p2ec6160369e9092de98a051e05750bd4f X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240704071134epcas5p2ec6160369e9092de98a051e05750bd4f References: <20240704070357.1993-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 32c9c6d80384..0d923140006e 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1205,20 +1205,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 0c8857fe4079..18520b05c6ce 100644 --- a/block/blk.h +++ b/block/blk.h @@ -548,6 +548,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