From patchwork Thu Jun 27 10:45:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kundan Kumar X-Patchwork-Id: 13714401 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AF5918732D for ; Thu, 27 Jun 2024 13:14:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719494063; cv=none; b=EZEP69dGygRxNq7/Sb25s/aSTe3PAQ9iK//JVl6tS0wqehoXMHOjtKVAWHJhTY/65e2tHB8u2IB+QOeY1pqvd5sEnFq48QcaDc7jyd5emuHJsQMDvLZxlLWfCb5xy1i55AlnPjcD9Owj/2py2bGuUCBkqTDsxOp3Lz5Vhd7akMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719494063; c=relaxed/simple; bh=jNHWVbeYhZDhPFEgKWgFGR78ajz3qSFZP4uZZ8IoHx4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=CG17OVNyCOTx+DGTmLfQsvYHMIeMg2RvsSEMmOgX38crG1bj3yVjG3/Mxw4ta6hTeT2crUpiaSN8T+Cp1YNGlrPOWEVLAXefAfiJ99elFr/Xh8U3Axt7zL60LdUBG+O452Ae6+Lxbplw1DKFafM+/DV43VSg8ISjjuv04zCAu0A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=Q4jfW6Dl; arc=none smtp.client-ip=203.254.224.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Q4jfW6Dl" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240627131418epoutp01e87636c9c82032a9969d3438049749b7~c3rxz_1ap1975719757epoutp01b for ; Thu, 27 Jun 2024 13:14:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240627131418epoutp01e87636c9c82032a9969d3438049749b7~c3rxz_1ap1975719757epoutp01b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1719494058; bh=h6p0r8QGeMeiENXxuYhDRIQeqijV9Gyk512CJzPV4Ms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q4jfW6Dl+HgdB27ZyZw4fTcEzjXScKmbkCheOcxZHUOSYiqoDiyPQHfu18Z8kwiJB CoxW1eygKeFXh1jJSFq16qY0db6l45Lo8xN9QM1VJMLO0kkTYh1axvKd7VNDzAScTb vZHY4hn9AVHVFYdAg+lpv8HbN3tcnSDqRxArsVpw= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240627131418epcas5p3e5ce668a5c2608f08d5a2eef12629fcd~c3rxXJJod0653906539epcas5p3L; Thu, 27 Jun 2024 13:14:18 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.176]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4W8zYN44Yvz4x9Pw; Thu, 27 Jun 2024 13:14:16 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id CE.6F.06857.8A56D766; Thu, 27 Jun 2024 22:14:16 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240627105404epcas5p334c7c5bd3aee98b58e60ac1008c863be~c1xVBDgd82093720937epcas5p3N; Thu, 27 Jun 2024 10:54:04 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240627105404epsmtrp217e34dfa5111e03db9004cc5e0d69924~c1xVAPDND0954409544epsmtrp2R; Thu, 27 Jun 2024 10:54:04 +0000 (GMT) X-AuditID: b6c32a4b-ae9fa70000021ac9-16-667d65a80d89 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 45.1E.19057.BC44D766; Thu, 27 Jun 2024 19:54:03 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240627105402epsmtip18392ee0ffabb9899cc12174cd8c7e685~c1xTPibz43160631606epsmtip1w; Thu, 27 Jun 2024 10:54:02 +0000 (GMT) From: Kundan Kumar To: axboe@kernel.dk, hch@lst.de, willy@infradead.org, kbusch@kernel.org Cc: linux-block@vger.kernel.org, joshi.k@samsung.com, mcgrof@kernel.org, anuj20.g@samsung.com, nj.shetty@samsung.com, c.gameti@samsung.com, gost.dev@samsung.com, Kundan Kumar Subject: [PATCH v6 1/3] block: Added folio-lized version of bio_add_hw_page() Date: Thu, 27 Jun 2024 16:15:50 +0530 Message-Id: <20240627104552.11177-2-kundan.kumar@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240627104552.11177-1-kundan.kumar@samsung.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBJsWRmVeSWpSXmKPExsWy7bCmlu6K1No0g5blUhZNE/4yW6y+289m 8X17H4vFzQM7mSxW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zCDv1a19rJ3KEd00O FN//tOCqRJ7OpbsSSizFGYmGWsxFxYkABI7Wq/MCAAA= X-CMS-MailID: 20240627105404epcas5p334c7c5bd3aee98b58e60ac1008c863be X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240627105404epcas5p334c7c5bd3aee98b58e60ac1008c863be References: <20240627104552.11177-1-kundan.kumar@samsung.com> Added new bio_add_hw_folio() function. This is a prep patch. Signed-off-by: Kundan Kumar --- block/bio.c | 33 ++++++++++++++++++++++++++++----- block/blk.h | 4 ++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/block/bio.c b/block/bio.c index e9e809a63c59..6c2db8317ae5 100644 --- a/block/bio.c +++ b/block/bio.c @@ -979,6 +979,31 @@ bool bvec_try_merge_hw_page(struct request_queue *q, struct bio_vec *bv, int bio_add_hw_page(struct request_queue *q, struct bio *bio, struct page *page, unsigned int len, unsigned int offset, unsigned int max_sectors, bool *same_page) +{ + struct folio *folio = page_folio(page); + size_t folio_offset = (folio_page_idx(folio, page) << PAGE_SHIFT) + + offset; + + return bio_add_hw_folio(q, bio, folio, len, folio_offset, max_sectors, + same_page); +} + +/** + * bio_add_hw_folio - attempt to add a folio to a bio with hw constraints + * @q: the target queue + * @bio: destination bio + * @folio: folio to add + * @len: vec entry length + * @offset: vec entry offset in the folio + * @max_sectors: maximum number of sectors that can be added + * @same_page: return if the segment has been merged inside the same folio + * + * Add a folio to a bio while respecting the hardware max_sectors, max_segment + * and gap limitations. + */ +int bio_add_hw_folio(struct request_queue *q, struct bio *bio, + struct folio *folio, size_t len, size_t offset, + unsigned int max_sectors, bool *same_page) { unsigned int max_size = max_sectors << SECTOR_SHIFT; @@ -992,8 +1017,8 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio, if (bio->bi_vcnt > 0) { struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1]; - if (bvec_try_merge_hw_page(q, bv, page, len, offset, - same_page)) { + if (bvec_try_merge_hw_page(q, bv, folio_page(folio, 0), len, + offset, same_page)) { bio->bi_iter.bi_size += len; return len; } @@ -1010,9 +1035,7 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio, return 0; } - bvec_set_page(&bio->bi_io_vec[bio->bi_vcnt], page, len, offset); - bio->bi_vcnt++; - bio->bi_iter.bi_size += len; + bio_add_folio_nofail(bio, folio, len, offset); return len; } diff --git a/block/blk.h b/block/blk.h index d0a986d8ee50..8c27fd7cc6de 100644 --- a/block/blk.h +++ b/block/blk.h @@ -529,6 +529,10 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio, struct page *page, unsigned int len, unsigned int offset, unsigned int max_sectors, bool *same_page); +int bio_add_hw_folio(struct request_queue *q, struct bio *bio, + struct folio *folio, size_t len, size_t offset, + unsigned int max_sectors, bool *same_page); + /* * Clean up a page appropriately, where the page may be pinned, may have a * ref taken on it or neither.