From patchwork Thu Jul 11 05:07:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13730000 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 34D9E381CC for ; Thu, 11 Jul 2024 05:20:03 +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=1720675205; cv=none; b=TRJPLhanpvBiLmoFh9e9FonE0/3nCRRDqsgXtMwGYkAPGofuezKjKX53MknVKiaJ4v1z4zgA+agPhqjdK82/6dAUs2bWCuUQYbVgAh+OCV5mpAYOCVC0vR414lRy9PWZkL6IDJMdt9kZxNkg6MtybbwEY3CRBtW6yIBg8wmpwCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720675205; c=relaxed/simple; bh=AgPzpnl76A59ZoOKASAH06+ps/h9++7shcfDxB84nBY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=buZYcqlnn6Z58e5JdGt1tgAIMZqk1XrNgoX1p6GmwtiQkOGzDGRBPJfjTEQtsSpQYtl+M45AbqvVaddh94qVuzKmFld2JxCG/0Y0el4fyxKstQm5uuE3YKAmUslneGTn1l0Kg02NlfX+BoTBJPq7tHFnR2ud7P0C0vwdttqMNDk= 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=mxgp6B26; 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="mxgp6B26" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240711052000epoutp04f5fd5640da3d7422f4c9df9892be271b~hEPqNX_Bj1223812238epoutp04h for ; Thu, 11 Jul 2024 05:20:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240711052000epoutp04f5fd5640da3d7422f4c9df9892be271b~hEPqNX_Bj1223812238epoutp04h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1720675200; bh=6n03T2JEGN3vj8I+QUtWy7BDCiBg5RtsiSgviI1bsHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mxgp6B26KAISSUrKblgY/Ergl+QSPJbPqr41rESJZxnOxhrh9hOEVvDZginl9ZddA YOXr2kqDBrsPibSWvGOWJcP16UUp88bu9Dx5HRztEIDifj2V+xxF7Tn1BY3B4X4SgK aogjjL4Yk4gxerEKAALj7o2Hpxq81i4MicJ/p89E= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240711052000epcas5p33266c6709c8d694a484b6b0053ccf63b~hEPpuq3-80960609606epcas5p3g; Thu, 11 Jul 2024 05:20:00 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.182]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4WKNMf3N4Yz4x9Q7; Thu, 11 Jul 2024 05:19:58 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 8D.55.07307.E7B6F866; Thu, 11 Jul 2024 14:19:58 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240711051529epcas5p1aaf694dfa65859b8a32bdffce5239bf6~hELtPh7NW0839808398epcas5p1C; Thu, 11 Jul 2024 05:15:29 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240711051529epsmtrp13a20764128ec3b4be07b6f3ec87c7aff~hELtOwQ_I1247512475epsmtrp1Y; Thu, 11 Jul 2024 05:15:29 +0000 (GMT) X-AuditID: b6c32a44-3f1fa70000011c8b-00-668f6b7e850d Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 89.9D.19057.17A6F866; Thu, 11 Jul 2024 14:15:29 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240711051527epsmtip14d158fec9577ac15732908f9335b8582~hELrfBjrN0104201042epsmtip1W; Thu, 11 Jul 2024 05:15: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 v8 1/5] block: Added folio-ized version of bvec_try_merge_hw_page() Date: Thu, 11 Jul 2024 10:37:46 +0530 Message-Id: <20240711050750.17792-2-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240711050750.17792-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+NgFlrFJsWRmVeSWpSXmKPExsWy7bCmhm5ddn+awaZt4hZNE/4yW6y+289m 8X17H4vFzQM7mSxWrj7KZHH0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N3+ 32BhdbNe0KAk63pnrBJLcUaioRZzUXEiAMwR7ZbyAgAA X-CMS-MailID: 20240711051529epcas5p1aaf694dfa65859b8a32bdffce5239bf6 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240711051529epcas5p1aaf694dfa65859b8a32bdffce5239bf6 References: <20240711050750.17792-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 | 27 +++++++++++++++++++++++---- block/blk.h | 4 ++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/block/bio.c b/block/bio.c index c4053d49679a..7018eded8d7b 100644 --- a/block/bio.c +++ b/block/bio.c @@ -931,7 +931,9 @@ 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); + if (off < PAGE_SIZE) + *same_page = ((vec_end_addr & PAGE_MASK) == page_addr); + if (!*same_page) { if (IS_ENABLED(CONFIG_KMSAN)) return false; @@ -944,14 +946,15 @@ static bool bvec_try_merge_page(struct bio_vec *bv, struct page *page, } /* - * Try to merge a page into a segment, while obeying the hardware segment + * 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_page(struct request_queue *q, struct bio_vec *bv, - struct page *page, unsigned len, unsigned offset, +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 = bvec_phys(bv); phys_addr_t addr2 = page_to_phys(page) + offset + len - 1; @@ -963,6 +966,22 @@ bool bvec_try_merge_hw_page(struct request_queue *q, struct bio_vec *bv, return bvec_try_merge_page(bv, page, len, offset, same_page); } +/* + * Try to merge a page 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_page(struct request_queue *q, struct bio_vec *bv, + struct page *page, unsigned int len, unsigned int 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); +} + /** * bio_add_hw_page - attempt to add a page to a bio with hw constraints * @q: the target queue diff --git a/block/blk.h b/block/blk.h index e180863f918b..6a566b78a0a8 100644 --- a/block/blk.h +++ b/block/blk.h @@ -91,6 +91,10 @@ struct bio_vec *bvec_alloc(mempool_t *pool, unsigned short *nr_vecs, gfp_t gfp_mask); void bvec_free(mempool_t *pool, struct bio_vec *bv, unsigned short nr_vecs); +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); + bool bvec_try_merge_hw_page(struct request_queue *q, struct bio_vec *bv, struct page *page, unsigned len, unsigned offset, bool *same_page); From patchwork Thu Jul 11 05:07:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13730001 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 E4E5A5821A for ; Thu, 11 Jul 2024 05:20:12 +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=1720675214; cv=none; b=qSv05ClNR7efeX2RQ2nFnIHr2NzwL0Wj7HfOrKAtZLe/u8Dvz9mmKen1HVgdf5j0Xanc2PK7pyH/tDFtN8cdTfgTRyfylxbC9gaYaJt/zdxiBdbmZJcKxGTi04s3tJ4KdVXuk5MCsbj0XWo1BHDb6Qukfi2OzYNBZOH75V0walo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720675214; c=relaxed/simple; bh=MOErW+3cwzKhNWrsaEfV0Kp3dW8ivvUuZbDORFwshfk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=rR8ZIDZGbOQifr7Uo2eqGh2heBliRTJA1/BDEt1bPudR1M87YCIkUr2EMAsHS1KXtcPvdY7KIpAXcqcddkFHaj9IZzDW2T0WGXf6TD18O/tqvMInuIyPrt94DR66URldisTBiptmfj/vtjRp/YVaFsZB7kffVp1XAldkDbWKdE0= 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=YsjIgvRw; 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="YsjIgvRw" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240711052011epoutp01fe225f4da2b16e9a20a31f1fbcca443a~hEPzmqdGi0543005430epoutp01F for ; Thu, 11 Jul 2024 05:20:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240711052011epoutp01fe225f4da2b16e9a20a31f1fbcca443a~hEPzmqdGi0543005430epoutp01F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1720675211; bh=T3jsnH2IlRJgZk3DwZtmFeE4PLHu5FwsealKd2ct36c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YsjIgvRw3N0XgG1YW41K1JjyN4EFro722wIdEn/zv6VbriWRSgpFnnffcvAgkWXzh 0po8uXq+Ppe3u73Lwk5/AyjlW3ffmrqUN4ytR4LpN/Y8tlmxJ+wH97xZn5Ou3A5CCD DYFFwgNXyWKH6MzsLMBoTi3CaoBD+TXGgQLXdziM= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240711052004epcas5p3de0715fb91cde06c96ec910d86819021~hEPtZcOKE1244412444epcas5p3k; Thu, 11 Jul 2024 05:20:04 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.179]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4WKNMk1pHnz4x9Ps; Thu, 11 Jul 2024 05:20:02 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 89.1E.06857.28B6F866; Thu, 11 Jul 2024 14:20:02 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240711051532epcas5p360e92f46b86eca56e73643a71950783a~hELwI-Xpy1631916319epcas5p3t; Thu, 11 Jul 2024 05:15:32 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240711051532epsmtrp2f677df2bb7a211f899db7036185bbe30~hELwINXGD1668816688epsmtrp2_; Thu, 11 Jul 2024 05:15:32 +0000 (GMT) X-AuditID: b6c32a4b-88bff70000021ac9-3b-668f6b82e2b5 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id E6.9E.18846.47A6F866; Thu, 11 Jul 2024 14:15:32 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240711051530epsmtip1cf5c979561437fa2f30ee651be594211~hELubciw-0258502585epsmtip1x; Thu, 11 Jul 2024 05:15:30 +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 v8 2/5] block: Added folio-ized version of bio_add_hw_page() Date: Thu, 11 Jul 2024 10:37:47 +0530 Message-Id: <20240711050750.17792-3-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240711050750.17792-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+NgFlrNJsWRmVeSWpSXmKPExsWy7bCmum5Tdn+aQddUdoumCX+ZLVbf7Wez +L69j8Xi5oGdTBYrVx9lsjj6/y2bxaRD1xgttn75ymqx95a2xY0JTxkttv2ez2zx+8ccNgce j80rtDwuny312LSqk81j980GNo++LasYPT5vkgtgi8q2yUhNTEktUkjNS85PycxLt1XyDo53 jjc1MzDUNbS0MFdSyEvMTbVVcvEJ0HXLzAG6UEmhLDGnFCgUkFhcrKRvZ1OUX1qSqpCRX1xi q5RakJJTYFKgV5yYW1yal66Xl1piZWhgYGQKVJiQnbH64yP2gh75iv2tE9gaGNsluxg5OSQE TCSOfp/P3MXIxSEksJtR4uWTJewQzidGiZ/7V7LBORc+LGCHadm7dwUrRGIno8Sn98tYIJzP jBJzvjwCquLgYBPQlfjRFArSICLgLjH15SNGkBpmgbOMEiemPmIBSQgL+EisvL6BCcRmEVCV aJu+iBHE5hWwlfjVdpkZYpu8xMxL38E2cwrYSWz8844FokZQ4uTMJ2A2M1BN89b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7Fgw3NGkDnMAtcZJW5M3wo2R1jAR2Ll9Q1MIDaLgKpE 2/RFjCA2r4CtxK+2y1C75CVmXvoONp9TwE5i4593LBC7bCX+b7vCDlEvKHFy5hOwODNQffPW 2cwTGAVmIUnNQpJawMi0ilE0taA4Nz03ucBQrzgxt7g0L10vOT93EyM4BrSCdjAuW/9X7xAj EwfjIUYJDmYlEd75N7rThHhTEiurUovy44tKc1KLDzFKc7AoifMq53SmCAmkJ5akZqemFqQW wWSZODilGphU9cvuqxUW7Zx3eNLJfw2/jsiciTix8Lm/n9q0CRP2vp7J8O+mxFk/vkYm3UwD 4cs9WyMvfn5/egJzQEnHmr81k5co94Xse3xH4/05sy0tUUam1xZw6h913fum9O6i/Q5XYoId HBemdZoL+tTsnCE8MSfq8XntQnZB30/+brGlqgo7TO7PX1qxb07M/9MuV/sczt9uKdLeEuD0 a7XTk5Az71Vjzr0v5LWeMzXTfPmSfzwPzl2ceHOGWI/0lAVbpu76dkBUP2qmwJ0Nf7sNW6Oq LphOWvG9rs5R9BRrd1N5164J6d/EXs+P+Dkn9vCLozPeLzbvKy7+vn/LHa0zRYL94m4fP5T+ 0Li38cmqwpm7PiixFGckGmoxFxUnAgDUOXVe8AIAAA== X-CMS-MailID: 20240711051532epcas5p360e92f46b86eca56e73643a71950783a X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240711051532epcas5p360e92f46b86eca56e73643a71950783a References: <20240711050750.17792-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 | 46 ++++++++++++++++++++++++++++++++++------------ block/blk.h | 4 ++++ 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/block/bio.c b/block/bio.c index 7018eded8d7b..a7442f4bbfc6 100644 --- a/block/bio.c +++ b/block/bio.c @@ -983,20 +983,20 @@ bool bvec_try_merge_hw_page(struct request_queue *q, struct bio_vec *bv, } /** - * bio_add_hw_page - attempt to add a page to a bio with hw constraints + * bio_add_hw_folio - attempt to add a folio to a bio with hw constraints * @q: the target queue * @bio: destination bio - * @page: page to add + * @folio: folio to add * @len: vec entry length - * @offset: vec entry offset + * @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 page + * @same_page: return if the segment has been merged inside the same folio * - * Add a page to a bio while respecting the hardware max_sectors, max_segment + * Add a folio to a bio while respecting the hardware max_sectors, max_segment * and gap limitations. */ -int bio_add_hw_page(struct request_queue *q, struct bio *bio, - struct page *page, unsigned int len, unsigned int offset, +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; @@ -1011,8 +1011,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; } @@ -1029,12 +1029,34 @@ 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; } +/** + * bio_add_hw_page - attempt to add a page to a bio with hw constraints + * @q: the target queue + * @bio: destination bio + * @page: page to add + * @len: vec entry length + * @offset: vec entry offset + * @max_sectors: maximum number of sectors that can be added + * @same_page: return if the segment has been merged inside the same page + * + * Add a page to a bio while respecting the hardware max_sectors, max_segment + * and gap limitations. + */ +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_pc_page - attempt to add page to passthrough bio * @q: the target queue diff --git a/block/blk.h b/block/blk.h index 6a566b78a0a8..777e1486f0de 100644 --- a/block/blk.h +++ b/block/blk.h @@ -540,6 +540,10 @@ void bdev_set_nr_sectors(struct block_device *bdev, sector_t sectors); struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id, struct lock_class_key *lkclass); +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); + 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); From patchwork Thu Jul 11 05:07:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13730003 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 5D1A61C3D for ; Thu, 11 Jul 2024 05:20:13 +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=1720675215; cv=none; b=F1MCbmA/HQb8LWYGQMRAGoVoR5StWWZKdWQBI1sELtcWRc6lY6TwT/R83/lcDvtk8TEorV3x9hfNbVfGIwn3zKqvm55oXMYfnAFpYjziNdJ2/ZNucg8+0XNZwwGr3+UvJMlLutmNrr+TNcFSQJgr664ZFp4Pd1M8VZ2qwWAPZZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720675215; c=relaxed/simple; bh=sljjdn0XYpgAEo5+oljdSRtflgnvsKmYeG/iraAYyJs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=YO1s9MUWuqy41xKRWKQzWLa9qVHo82b3tvhAZ0aDz7dONZeLKha+tl1jxGPc3Qn0D/U5hDzBINv9AU10nAElhI2eUTDM5xbu8Xl/mYmqKm122webKNZMX3ffMHSTvSWgFHvEHpLuD8tt4C7oyUpDVcEkCsAgdWJA/jmpaPj7zDc= 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=GGMItoK7; 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="GGMItoK7" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20240711052011epoutp03d51be55a444826823dadb4f4de1625b3~hEPzy4Llj1589315893epoutp03s for ; Thu, 11 Jul 2024 05:20:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20240711052011epoutp03d51be55a444826823dadb4f4de1625b3~hEPzy4Llj1589315893epoutp03s DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1720675211; bh=+Yo/gGquQ+4cJGGCI1Dv5+q2paTXnhvf0gqLMlGXuLo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GGMItoK7syHSZbn9Ge1tpfn3PbAL/vYa+TZKD3sJt1160ctP/ry3nMowSyatkPHPN Kpgr35ZTodGLKfwAPRUC7gpMJUVFxthE4WDY8SNYMHhhi/9f03v3BEdGjtNxW6XxX8 DifD1NmvkO/R+sMmu6pTn5sEtHXE2xvtyJBoy460= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240711052007epcas5p46a9aaceb7aae44e8f72b9c3077d0d391~hEPwOko7O1595615956epcas5p4n; Thu, 11 Jul 2024 05:20:07 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.174]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4WKNMn3tDRz4x9QF; Thu, 11 Jul 2024 05:20:05 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 8D.1E.06857.58B6F866; Thu, 11 Jul 2024 14:20:05 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240711051536epcas5p369e005a83fb16d9f6d9636585cc66e3b~hELz-LIeK2616926169epcas5p3J; Thu, 11 Jul 2024 05:15:36 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240711051536epsmtrp10d5afb758cf916af158a2c625218b40f~hELz_WaUE1252312523epsmtrp1E; Thu, 11 Jul 2024 05:15:36 +0000 (GMT) X-AuditID: b6c32a4b-88bff70000021ac9-4b-668f6b85dd50 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 7C.0E.29940.87A6F866; Thu, 11 Jul 2024 14:15:36 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240711051534epsmtip1233eab6fd33b934e3846fefe72c89ed6~hELyLrkyg0104201042epsmtip1Z; Thu, 11 Jul 2024 05:15:34 +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 v8 3/5] block: introduce folio awareness and add a bigger size from folio Date: Thu, 11 Jul 2024 10:37:48 +0530 Message-Id: <20240711050750.17792-4-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240711050750.17792-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+NgFlrJJsWRmVeSWpSXmKPExsWy7bCmhm5rdn+awamHkhZNE/4yW6y+289m 8X17H4vFzQM7mSxWrj7KZHH0/1s2i0mHrjFabP3yldVi7y1tixsTnjJabPs9n9ni9485bA48 HptXaHlcPlvqsWlVJ5vH7psNbB59W1YxenzeJBfAFpVtk5GamJJapJCal5yfkpmXbqvkHRzv HG9qZmCoa2hpYa6kkJeYm2qr5OIToOuWmQN0oZJCWWJOKVAoILG4WEnfzqYov7QkVSEjv7jE Vim1ICWnwKRArzgxt7g0L10vL7XEytDAwMgUqDAhO2Pq8x1MBRvVK2Yce8rewPhHrouRk0NC wETi+YQG1i5GLg4hgd2MEn+m/oByPjFKrF43gRHC+cYo0d33lL2LkQOs5dkDFZBuIYG9jBLP H2ZB1HxmlJh+ewkzSA2bgK7Ej6ZQkBoRAXeJqS8fgc1hFjjLKHFi6iMWkISwQLTEv89TGUFs FgFViWMHl7GB9PIK2Eoc3VwNcZ28xMxL39lBbE4BO4mNf96BtfIKCEqcnPkEzGYGqmneOpsZ ZL6EwFQOiSlv3zNCNLtI9M6eBGULS7w6voUdwpaSeNnfBmVnSxxq3MAEYZdI7DzSABW3l2g9 1Q/2C7OApsT6XfoQYVmJqafWMUHs5ZPo/f0EqpVXYsc8GFtNYs67qSwQtozEwkszoOIeEo+/ TGKH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Xmq5XnFibnFpXrpecn7uJkZwJGhp7mDc vuqD3iFGJg7GQ4wSHMxKIrzzb3SnCfGmJFZWpRblxxeV5qQWH2KU5mBREucVf9GbIiSQnliS mp2aWpBaBJNl4uCUamCaXrJWVFGaryFkcSVH7LPTnre2Kv/sz3z4ZeI+7faZQmY8dzYtVvpn OyWd8fSZDc5mM30SH356PNX+lavd37JDdyaqrruqJ54wfdf5F3OTF/E9iDGYZ7ri6cSjB5uS WdcWJH6LK8+q52tiWZWg0uApqru2L25P3mXB56qPl3zbuoD9mPt/3fXHeat+h5k+uvX207JJ V5anzVWPP3zm+pPt/1hPNBxq92g5UZbw01gvT3F7Z+DOHiOdNL7GvvXrYtacCu6/vedPZsze B2XJV6t7tiZJ51ROVth+SZRFTD/GpE7pr6nqN8M0dwU9Za9p83ZrL7jW+nr3uX9WelsW+wqc Onni6LobR89b38xP4uU6rMRSnJFoqMVcVJwIAKUe7bXzAgAA X-CMS-MailID: 20240711051536epcas5p369e005a83fb16d9f6d9636585cc66e3b X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240711051536epcas5p369e005a83fb16d9f6d9636585cc66e3b References: <20240711050750.17792-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 a7442f4bbfc6..b4df3af3e303 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1245,8 +1245,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; @@ -1255,30 +1255,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 *)) /** @@ -1298,9 +1329,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; /* @@ -1342,15 +1373,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 11 05:07:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13730002 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 E1BE557C9A for ; Thu, 11 Jul 2024 05:20:12 +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=1720675214; cv=none; b=p9kne4jUa2cMhHJpmZ/HFJUCS40FfgLowGCyehZyF2tGImEfYGLJJ7Tb5sd5VkknT2bNqlmkK44PzaIUfLVD1dCNZVzRfZRSujz+qiVzopfVE5KCCrxVubE5fh8ldnEJl/HJ0WaD+BbSUK43cLbHTZwBoD9H0yBKm0xhiIEqupo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720675214; c=relaxed/simple; bh=rSKYGNVjFYQH02tNPX+U7xM3SxzXt/NKEpLblMc1exY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=TNbqWTw4EIKkE/TTodj7bytW2UnCZhM3s98ys1xy6Dk1jhfRd/ZOPmKAP3MdOJEEQAnbZ2q4VdXcQ0eLMGQU0ilOiqybE9OREeZOv7lWxzzdHH3U7vUzmvb9JPfFsc7wQVKuZvSjOj5xJctsG4R81mCZcQ9Qrbb1rEHPgWjHtnw= 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=aoytN8pJ; 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="aoytN8pJ" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240711052011epoutp02322b0d6b1372819b82de9b533f15ad29~hEPzlnZ3w2369923699epoutp02H for ; Thu, 11 Jul 2024 05:20:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240711052011epoutp02322b0d6b1372819b82de9b533f15ad29~hEPzlnZ3w2369923699epoutp02H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1720675211; bh=yHVjrWtU8SuENtWXOsNgz4Dsm3fiKVmVwCBSAJkmvHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aoytN8pJxPq/TbUL8o7O8vmYZV7iq3Hr1yO9mYpPrWmnFD675bQJGvJEJYJAaFm3q hvVpUkxpOiKj2xAQl5sERuen5G0a/h6R9quVYd+vk45NTgHNfXazDiu4qvRXSjZp7R Itqqs/UE8EvHszUuDiAjJII/rJahFUgWWMs560ho= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240711052010epcas5p4e8f042da2d3120aa0bea8fa9ecd470a4~hEPzMGKKU1595615956epcas5p4x; Thu, 11 Jul 2024 05:20:10 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.176]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4WKNMr4t8pz4x9QL; Thu, 11 Jul 2024 05:20:08 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 5F.AB.09989.88B6F866; Thu, 11 Jul 2024 14:20:08 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240711051539epcas5p2842f564375dc2f1c3de1a869c938436b~hEL28b6982906029060epcas5p2E; Thu, 11 Jul 2024 05:15:39 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240711051539epsmtrp22634bc89d99894ebd9917ecc2d9d1288~hEL27nuUX1688716887epsmtrp2G; Thu, 11 Jul 2024 05:15:39 +0000 (GMT) X-AuditID: b6c32a4a-e57f970000002705-f1-668f6b889ecd Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 78.C5.07412.B7A6F866; Thu, 11 Jul 2024 14:15:39 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240711051537epsmtip1e11024a9e8cbedd25132a557d3f93cef~hEL1QeGWe0258502585epsmtip13; Thu, 11 Jul 2024 05:15:37 +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 v8 4/5] mm: release number of pages of a folio Date: Thu, 11 Jul 2024 10:37:49 +0530 Message-Id: <20240711050750.17792-5-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240711050750.17792-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+NgFlrJJsWRmVeSWpSXmKPExsWy7bCmum5Hdn+awctvChZNE/4yW6y+289m 8X17H4vFzQM7mSxWrj7KZHH0/1s2i0mHrjFabP3yldVi7y1tixsTnjJabPs9n9ni9485bA48 HptXaHlcPlvqsWlVJ5vH7psNbB59W1YxenzeJBfAFpVtk5GamJJapJCal5yfkpmXbqvkHRzv HG9qZmCoa2hpYa6kkJeYm2qr5OIToOuWmQN0oZJCWWJOKVAoILG4WEnfzqYov7QkVSEjv7jE Vim1ICWnwKRArzgxt7g0L10vL7XEytDAwMgUqDAhO+NW1w+mgqU8FRMfhzQwtnJ1MXJwSAiY SCxZH9/FyMUhJLCbUeLfn81MEM4nRokrl/pZuhg5g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lVJ5vH7psNbB59W1YxenzeJBfAFsVlk5Kak1mWWqRvl8CVcavrB1PBUp6K iY9DGhhbuboYOTkkBEwkWn7NZu9i5OIQEtjNKNFx+DQrREJGYvfdnVC2sMTKf8+hij4ySpxr ucTcxcjBwSagK/GjKRSkRkTAV2LBhueMIDXMAtcZJW5M38oMkhAWsJP4fuoBC4jNIqAq8WF3 ByOIzStgK3F99iaoBfISMy99ZwexOYHqN/55B1YvBFTzf9sVdoh6QYmTM5+AxZmB6pu3zmae wCgwC0lqFpLUAkamVYySqQXFuem5yYYFhnmp5XrFibnFpXnpesn5uZsYwbGgpbGD8d78f3qH GJk4GA8xSnAwK4nwzr/RnSbEm5JYWZValB9fVJqTWnyIUZqDRUmc13DG7BQhgfTEktTs1NSC 1CKYLBMHp1QDEz+b4YL1lWHBlWIsHSz33iZOkY9ySJT8dDJm3m8tObOVsX3l835Wn4rwaGi4 nnWQd/v3sttzZ7rnhy10nfpPno2nyfqQd3R02IabO4VrpSb/mrBaMKI2b3vuvAy982eqpk3/ 1KX7wWDtLV2vKY02VltaUz+tddPcNbN6/sTC1aolU7fMUTRoz3SaE/Xvs/NvW7V95lZSSot/ /DjVZfb8UJzYvJP6m3Y3sE87c9WGawtrq833iYfCw+TtF6vKL3+RzbyjamPAxPPJiZfuMxpP uF20vmBFXO6VmWVaubcvmu99mchsdlTXyMZ+xqEoldUss9tmd/HbbVWcns4y+bF8SPy+K+Z3 ok09Pvd6+9YyK7EUZyQaajEXFScCALUoE+/0AgAA X-CMS-MailID: 20240711051539epcas5p2842f564375dc2f1c3de1a869c938436b X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240711051539epcas5p2842f564375dc2f1c3de1a869c938436b References: <20240711050750.17792-1-kundan.kumar@samsung.com> Add a new function unpin_user_folio() to put the refs of a folio by npages count. Signed-off-by: Kundan Kumar --- 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 eb7c96d24ac0..fcf9b6263326 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1623,6 +1623,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 From patchwork Thu Jul 11 05:07: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: 13730004 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 D7EE65FB9B for ; Thu, 11 Jul 2024 05:20:15 +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=1720675217; cv=none; b=ExfI0My59rOsF8HPbi7ks5XFnylRnZBQKQXRtC8rOYRDk8F5P3Yg6+pbgDLvm6zSF6y0ZOZLM55DB1msLVlpwxatj7sNFj5CbHTrXoe5mUZfbPYCQI4R06FkEsnPXFLqD5ft3sNxdnamauli5gDaehmhaqjLRhhLUP0bbppcCNk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720675217; c=relaxed/simple; bh=uRDISmRMMsPbNCOgomSZwWRkp7ktFqa48Pr3xhL9cds=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=hF7KkW8sbrNqI+rugKVCFbJs6Fgotje5A6BB4f1Diyr70qDLyQFU1BdeTS1VkTi6D7mvQY8Ze0AYSyhhlz6fhe0gexAao6mfhzCNKnbuqxIzEbwmu7xRTMCOuM5dMgu4+DQ7Ggj/mqAzLm3LiU7pz8tECWHhScaScqX3zKSTIR0= 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=gCSG2ePN; 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="gCSG2ePN" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20240711052013epoutp0362aac82f79c9bdc2bc7053bcad79f225~hEP2Xgz6R1551215512epoutp03t for ; Thu, 11 Jul 2024 05:20:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20240711052013epoutp0362aac82f79c9bdc2bc7053bcad79f225~hEP2Xgz6R1551215512epoutp03t DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1720675214; bh=jUURJxBXiQxlMyE0MeIkequPl8VktsiHIXGRDMikDxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gCSG2ePNfFeM2T+z/O6a8q8eW5pdBcuO7dTwaHO/aY1A0TUNL6ttCXbzGQs8oHDt2 zMzHIEIlfivGYj0qEMrVCW1Y1JIVBTK1G1jGjU+sorbkBhiTTRV27cW+t0I0pfmIni GF4qXiEsajDoFl93QDhPPM0iUrGACR04YQKFFdgk= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240711052013epcas5p4cef469c4aebafa4b624919b1a2b89657~hEP1xd7MY1591415914epcas5p45; Thu, 11 Jul 2024 05:20:13 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.182]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4WKNMv3w02z4x9Q7; Thu, 11 Jul 2024 05:20:11 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id D2.F3.19174.B8B6F866; Thu, 11 Jul 2024 14:20:11 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240711051543epcas5p364f770974e2367d27c685a626cc9dbb5~hEL6NOGoP1516315163epcas5p3R; Thu, 11 Jul 2024 05:15:43 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240711051543epsmtrp223e0bd154980a012976ff051adf2f2de~hEL6MYEch1668816688epsmtrp2L; Thu, 11 Jul 2024 05:15:43 +0000 (GMT) X-AuditID: b6c32a50-b33ff70000004ae6-25-668f6b8bb394 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 79.C5.07412.F7A6F866; Thu, 11 Jul 2024 14:15:43 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240711051541epsmtip1342f7ade2d7406fe3a3402c67c802db7~hEL4apagb0217802178epsmtip1-; Thu, 11 Jul 2024 05:15:41 +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 v8 5/5] block: unpin user pages belonging to a folio at once Date: Thu, 11 Jul 2024 10:37:50 +0530 Message-Id: <20240711050750.17792-6-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240711050750.17792-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+NgFlrNJsWRmVeSWpSXmKPExsWy7bCmlm53dn+awdO/MhZNE/4yW6y+289m 8X17H4vFzQM7mSxWrj7KZHH0/1s2i0mHrjFabP3yldVi7y1tixsTnjJabPs9n9ni9485bA48 HptXaHlcPlvqsWlVJ5vH7psNbB59W1YxenzeJBfAFpVtk5GamJJapJCal5yfkpmXbqvkHRzv HG9qZmCoa2hpYa6kkJeYm2qr5OIToOuWmQN0oZJCWWJOKVAoILG4WEnfzqYov7QkVSEjv7jE Vim1ICWnwKRArzgxt7g0L10vL7XEytDAwMgUqDAhO6Nj6SPmghs8FTt75zE3MC7i6mLk5JAQ MJF4sH4JexcjF4eQwB5Gia+btjNBOJ8YJVZcPgPlfGOU2DbnPztMy6etc8FsIYG9jBLLD8ZD FH1mlNh38AhrFyMHB5uArsSPplCQGhEBd4mpLx8xgtQwC5xllDgx9RELSEJYwEfiw+NbYDaL gKrEv7V3GUF6eQVsJabdYI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GgASjBwcEmoCvxoykUpEZEwFdiwYbnjCA1zALXGSVuTN/KDJIQFvCR+PD4FguIzSKgKvFv 7V1GkF5eAVuJaTeYIebLS8y89J0dxOYUsJPY+OcdWLkQUMn/bVfA4rwCghInZz4BizMD1Tdv nc08gVFgFpLULCSpBYxMqxglUwuKc9Nzkw0LDPNSy/WKE3OLS/PS9ZLzczcxgmNBS2MH4735 //QOMTJxMB5ilOBgVhLhnX+jO02INyWxsiq1KD++qDQntfgQozQHi5I4r+GM2SlCAumJJanZ qakFqUUwWSYOTqkGpm1X+M8+6Jw9qa5mZeFjV+5F5TMWxk1m+irItlqPM19/9/H/Vi1ps+5u kr6f8TCkcntcSv2Ub91b7gnc4BbzfeWz/9ulNL/zAYumpp0+ZrctiFNaMk37z2HVpXIPK+Ir S/u17Y5/U+5QvsTRvyNJt+Dg/MUTDhz1VlmxT2zB/Nc/Tx5d2jGLQc7b4K+XZ/72ljeX5CdO yq4qi33TforTWk767hLviIO81zdFrPr6o76HwbvH5LpT9cXrCw4K+nzsMpn7f/Z805LqeWaM G8VYbLfWyNjt7n3/tYFhtfWmiamMhwRvNfAema8/b/Gk2L2Ldn7bXpKk8YxH1rPbd9aWhOcH owpD3v1d/u/117YSvnNKLMUZiYZazEXFiQDjegb79AIAAA== X-CMS-MailID: 20240711051543epcas5p364f770974e2367d27c685a626cc9dbb5 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240711051543epcas5p364f770974e2367d27c685a626cc9dbb5 References: <20240711050750.17792-1-kundan.kumar@samsung.com> Add a new wrapper bio_release_folio() and use it to put refs by npages count. Signed-off-by: Kundan Kumar --- block/bio.c | 6 +----- block/blk.h | 6 ++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/block/bio.c b/block/bio.c index b4df3af3e303..ca249f2c99a7 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1207,7 +1207,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) { @@ -1215,12 +1214,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); + 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 777e1486f0de..8e266f0ace2b 100644 --- a/block/blk.h +++ b/block/blk.h @@ -558,6 +558,12 @@ 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) +{ + 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);