From: Davidlohr Bueso <dave@stgolabs.net>
To: brauner@kernel.org
Cc: jack@suse.cz, viro@zeniv.linux.org.uk, mcgrof@kernel.org,
dave@stgolabs.net, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] fs/buffer: avoid redundant lookup in getblk slowpath
Date: Thu, 15 May 2025 10:39:23 -0700 [thread overview]
Message-ID: <20250515173925.147823-3-dave@stgolabs.net> (raw)
In-Reply-To: <20250515173925.147823-1-dave@stgolabs.net>
__getblk_slow() already implies failing a first lookup
as the fastpath, so try to create the buffers immediately
and avoid the redundant lookup. This saves 5-10% of the
total cost/latency of the slowpath.
Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
fs/buffer.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/buffer.c b/fs/buffer.c
index 5a4342881f3b..b02cced96529 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1139,15 +1139,15 @@ __getblk_slow(struct block_device *bdev, sector_t block,
for (;;) {
struct buffer_head *bh;
+ if (!grow_buffers(bdev, block, size, gfp))
+ return NULL;
+
if (blocking)
bh = __find_get_block_nonatomic(bdev, block, size);
else
bh = __find_get_block(bdev, block, size);
if (bh)
return bh;
-
- if (!grow_buffers(bdev, block, size, gfp))
- return NULL;
}
}
--
2.39.5
next prev parent reply other threads:[~2025-05-15 17:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-15 17:39 [PATCH -next 0/4] fs/buffer: misc optimizations Davidlohr Bueso
2025-05-15 17:39 ` [PATCH 1/4] fs/buffer: use sleeping lookup in __getblk_slowpath() Davidlohr Bueso
2025-05-16 10:11 ` Jan Kara
2025-05-15 17:39 ` Davidlohr Bueso [this message]
2025-05-16 10:12 ` [PATCH 2/4] fs/buffer: avoid redundant lookup in getblk slowpath Jan Kara
2025-05-15 17:39 ` [PATCH 3/4] fs/buffer: remove superfluous statements Davidlohr Bueso
2025-05-16 10:13 ` Jan Kara
2025-05-15 17:39 ` [PATCH 4/4] fs/buffer: optimize discard_buffer() Davidlohr Bueso
2025-05-16 10:17 ` Jan Kara
2025-05-19 10:06 ` [PATCH -next 0/4] fs/buffer: misc optimizations Christian Brauner
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=20250515173925.147823-3-dave@stgolabs.net \
--to=dave@stgolabs.net \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).