From: "Darrick J. Wong" <djwong@kernel.org>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: linux-fsdevel@vger.kernel.org,
Christian Brauner <brauner@kernel.org>,
linux-xfs@vger.kernel.org
Subject: Re: [PATCH 07/10] iomap: Use folio_next_pos()
Date: Fri, 24 Oct 2025 10:10:56 -0700 [thread overview]
Message-ID: <20251024171056.GJ4015566@frogsfrogsfrogs> (raw)
In-Reply-To: <20251024170822.1427218-8-willy@infradead.org>
On Fri, Oct 24, 2025 at 06:08:15PM +0100, Matthew Wilcox (Oracle) wrote:
> This is one instruction more efficient than open-coding folio_pos() +
> folio_size(). It's the equivalent of (x + y) << z rather than
> x << z + y << z.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Cc: Christian Brauner <brauner@kernel.org>
> Cc: "Darrick J. Wong" <djwong@kernel.org>
> Cc: linux-xfs@vger.kernel.org
Looks like a nice win, even if a small one
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/iomap/buffered-io.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index 8b847a1e27f1..32a27f36372d 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -707,7 +707,7 @@ static int __iomap_write_begin(const struct iomap_iter *iter,
> * are not changing pagecache contents.
> */
> if (!(iter->flags & IOMAP_UNSHARE) && pos <= folio_pos(folio) &&
> - pos + len >= folio_pos(folio) + folio_size(folio))
> + pos + len >= folio_next_pos(folio))
> return 0;
>
> ifs = ifs_alloc(iter->inode, folio, iter->flags);
> @@ -1097,8 +1097,7 @@ static void iomap_write_delalloc_ifs_punch(struct inode *inode,
> if (!ifs)
> return;
>
> - last_byte = min_t(loff_t, end_byte - 1,
> - folio_pos(folio) + folio_size(folio) - 1);
> + last_byte = min_t(loff_t, end_byte - 1, folio_next_pos(folio) - 1);
> first_blk = offset_in_folio(folio, start_byte) >> blkbits;
> last_blk = offset_in_folio(folio, last_byte) >> blkbits;
> for (i = first_blk; i <= last_blk; i++) {
> @@ -1129,8 +1128,7 @@ static void iomap_write_delalloc_punch(struct inode *inode, struct folio *folio,
> * Make sure the next punch start is correctly bound to
> * the end of this data range, not the end of the folio.
> */
> - *punch_start_byte = min_t(loff_t, end_byte,
> - folio_pos(folio) + folio_size(folio));
> + *punch_start_byte = min_t(loff_t, end_byte, folio_next_pos(folio));
> }
>
> /*
> @@ -1170,7 +1168,7 @@ static void iomap_write_delalloc_scan(struct inode *inode,
> start_byte, end_byte, iomap, punch);
>
> /* move offset to start of next folio in range */
> - start_byte = folio_pos(folio) + folio_size(folio);
> + start_byte = folio_next_pos(folio);
> folio_unlock(folio);
> folio_put(folio);
> }
> --
> 2.47.2
>
next prev parent reply other threads:[~2025-10-24 17:10 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-24 17:08 [PATCH 00/10] Add and use folio_next_pos() Matthew Wilcox (Oracle)
2025-10-24 17:08 ` [PATCH 01/10] filemap: Add folio_next_pos() Matthew Wilcox (Oracle)
2025-10-27 7:53 ` Christoph Hellwig
2025-10-27 8:33 ` Joseph Qi
2025-10-24 17:08 ` [PATCH 02/10] btrfs: Use folio_next_pos() Matthew Wilcox (Oracle)
2025-10-30 18:14 ` David Sterba
2025-10-24 17:08 ` [PATCH 03/10] buffer: " Matthew Wilcox (Oracle)
2025-10-27 7:54 ` Christoph Hellwig
2025-10-30 9:35 ` Jan Kara
2025-10-24 17:08 ` [PATCH 04/10] ext4: " Matthew Wilcox (Oracle)
2025-10-25 3:20 ` Zhang Yi
2025-10-27 7:54 ` Christoph Hellwig
2025-10-24 17:08 ` [PATCH 05/10] f2fs: " Matthew Wilcox (Oracle)
2025-10-27 11:57 ` Chao Yu
2025-12-09 17:18 ` [f2fs-dev] " patchwork-bot+f2fs
2025-10-24 17:08 ` [PATCH 06/10] gfs2: " Matthew Wilcox (Oracle)
2025-10-24 17:08 ` [PATCH 07/10] iomap: " Matthew Wilcox (Oracle)
2025-10-24 17:10 ` Darrick J. Wong [this message]
2025-10-27 7:53 ` Christoph Hellwig
2025-10-24 17:08 ` [PATCH 08/10] netfs: " Matthew Wilcox (Oracle)
2025-10-24 17:36 ` Paulo Alcantara
2025-10-27 14:16 ` David Howells
2025-10-27 14:50 ` Matthew Wilcox
2025-10-24 17:08 ` [PATCH 09/10] xfs: " Matthew Wilcox (Oracle)
2025-10-27 7:53 ` Christoph Hellwig
2025-10-24 17:08 ` [PATCH 10/10] mm: " Matthew Wilcox (Oracle)
2025-10-27 7:54 ` Christoph Hellwig
2025-10-27 15:43 ` David Hildenbrand
2025-11-08 5:00 ` Matthew Wilcox
2025-11-11 9:59 ` Christian Brauner
2025-10-31 12:12 ` [PATCH 00/10] Add and use folio_next_pos() 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=20251024171056.GJ4015566@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox