All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Kundan Kumar <kundan.kumar@samsung.com>
To: axboe@kernel.dk, hch@lst.de, willy@infradead.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 <kundan.kumar@samsung.com>
Subject: [PATCH] block : add larger order folio size instead of pages
Date: Fri, 19 Apr 2024 14:47:21 +0530	[thread overview]
Message-ID: <20240419091721.1790-1-kundan.kumar@samsung.com> (raw)
In-Reply-To: CGME20240419092428epcas5p4f63759b0efa1f12dfbcf13c67fa8d0f0@epcas5p4.samsung.com

When mTHP is enabled, IO can contain larger folios instead of pages.
In such cases add a larger size to the bio instead of looping through
pages. This reduces the overhead of iterating through pages for larger
block sizes. perf diff before and after this change:

Perf diff for write I/O with 128K block size:
	1.22%     -0.97%  [kernel.kallsyms]  [k] bio_iov_iter_get_pages
Perf diff for read I/O with 128K block size:
	4.13%     -3.26%  [kernel.kallsyms]  [k] bio_iov_iter_get_pages

Signed-off-by: Kundan Kumar <kundan.kumar@samsung.com>
---
 block/bio.c | 37 ++++++++++++++++++++++++++++---------
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 38baedb39c6f..c507e47e3c46 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1247,8 +1247,10 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
 	struct page **pages = (struct page **)bv;
 	ssize_t size, left;
 	unsigned len, i = 0;
-	size_t offset;
+	size_t offset, folio_offset, size_folio;
 	int ret = 0;
+	unsigned short num_pages;
+	struct folio *folio;
 
 	/*
 	 * Move page array up in the allocated memory for the bio vecs as far as
@@ -1289,16 +1291,33 @@ 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];
+		folio = page_folio(page);
+
+		if (!folio_test_large(folio) ||
+		   (bio_op(bio) == REQ_OP_ZONE_APPEND)) {
+			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);
+				if (ret)
+					break;
+			} else
+				bio_iov_add_page(bio, page, len, offset);
+		} else {
+			/* See the offset of folio and the size */
+			folio_offset = (folio_page_idx(folio, page)
+					<< PAGE_SHIFT) + offset;
+			size_folio = folio_size(folio);
 
-		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);
-			if (ret)
-				break;
-		} else
-			bio_iov_add_page(bio, page, len, offset);
+			/* Calculate the length of folio to be added */
+			len = min_t(size_t, (size_folio - folio_offset), left);
+
+			num_pages = DIV_ROUND_UP(offset + len, PAGE_SIZE);
 
+			bio_iov_add_page(bio, page, len, offset);
+			/* Skip the pages which got added */
+			i = i + (num_pages - 1);
+		}
 		offset = 0;
 	}
 
-- 
2.25.1


       reply	other threads:[~2024-04-19 12:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20240419092428epcas5p4f63759b0efa1f12dfbcf13c67fa8d0f0@epcas5p4.samsung.com>
2024-04-19  9:17 ` Kundan Kumar [this message]
2024-04-19 14:16   ` [PATCH] block : add larger order folio size instead of pages Matthew Wilcox
2024-04-22  9:44     ` Kundan Kumar
2024-04-22 11:14   ` Christoph Hellwig
2024-04-24 13:22     ` Kundan Kumar
2024-04-24 17:04       ` Keith Busch
2024-04-27  8:14       ` Christoph Hellwig
2024-04-24 16:16   ` Keith Busch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240419091721.1790-1-kundan.kumar@samsung.com \
    --to=kundan.kumar@samsung.com \
    --cc=anuj20.g@samsung.com \
    --cc=axboe@kernel.dk \
    --cc=c.gameti@samsung.com \
    --cc=gost.dev@samsung.com \
    --cc=hch@lst.de \
    --cc=joshi.k@samsung.com \
    --cc=linux-block@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=nj.shetty@samsung.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.