* [PATCH 07/10] iomap: Use folio_next_pos()
[not found] <20251024170822.1427218-1-willy@infradead.org>
@ 2025-10-24 17:08 ` Matthew Wilcox (Oracle)
2025-10-24 17:10 ` Darrick J. Wong
2025-10-27 7:53 ` Christoph Hellwig
2025-10-24 17:08 ` [PATCH 09/10] xfs: " Matthew Wilcox (Oracle)
1 sibling, 2 replies; 5+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-10-24 17:08 UTC (permalink / raw)
To: linux-fsdevel, Christian Brauner
Cc: Matthew Wilcox (Oracle), Darrick J. Wong, linux-xfs
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
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 09/10] xfs: Use folio_next_pos()
[not found] <20251024170822.1427218-1-willy@infradead.org>
2025-10-24 17:08 ` [PATCH 07/10] iomap: Use folio_next_pos() Matthew Wilcox (Oracle)
@ 2025-10-24 17:08 ` Matthew Wilcox (Oracle)
2025-10-27 7:53 ` Christoph Hellwig
1 sibling, 1 reply; 5+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-10-24 17:08 UTC (permalink / raw)
To: linux-fsdevel, Christian Brauner
Cc: Matthew Wilcox (Oracle), Carlos Maiolino, linux-xfs
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: Carlos Maiolino <cem@kernel.org>
Cc: linux-xfs@vger.kernel.org
---
fs/xfs/scrub/xfarray.c | 2 +-
fs/xfs/xfs_aops.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/scrub/xfarray.c b/fs/xfs/scrub/xfarray.c
index cdd13ed9c569..ed2e8c64b1a8 100644
--- a/fs/xfs/scrub/xfarray.c
+++ b/fs/xfs/scrub/xfarray.c
@@ -834,7 +834,7 @@ xfarray_sort_scan(
si->first_folio_idx = xfarray_idx(si->array,
folio_pos(si->folio) + si->array->obj_size - 1);
- next_pos = folio_pos(si->folio) + folio_size(si->folio);
+ next_pos = folio_next_pos(si->folio);
si->last_folio_idx = xfarray_idx(si->array, next_pos - 1);
if (xfarray_pos(si->array, si->last_folio_idx + 1) > next_pos)
si->last_folio_idx--;
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index a26f79815533..ad76d5d01dd1 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -271,7 +271,7 @@ xfs_discard_folio(
* folio itself and not the start offset that is passed in.
*/
xfs_bmap_punch_delalloc_range(ip, XFS_DATA_FORK, pos,
- folio_pos(folio) + folio_size(folio), NULL);
+ folio_next_pos(folio), NULL);
}
/*
--
2.47.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 07/10] iomap: Use folio_next_pos()
2025-10-24 17:08 ` [PATCH 07/10] iomap: Use folio_next_pos() Matthew Wilcox (Oracle)
@ 2025-10-24 17:10 ` Darrick J. Wong
2025-10-27 7:53 ` Christoph Hellwig
1 sibling, 0 replies; 5+ messages in thread
From: Darrick J. Wong @ 2025-10-24 17:10 UTC (permalink / raw)
To: Matthew Wilcox (Oracle); +Cc: linux-fsdevel, Christian Brauner, linux-xfs
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
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 07/10] iomap: Use folio_next_pos()
2025-10-24 17:08 ` [PATCH 07/10] iomap: Use folio_next_pos() Matthew Wilcox (Oracle)
2025-10-24 17:10 ` Darrick J. Wong
@ 2025-10-27 7:53 ` Christoph Hellwig
1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2025-10-27 7:53 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: linux-fsdevel, Christian Brauner, Darrick J. Wong, linux-xfs
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.
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 09/10] xfs: Use folio_next_pos()
2025-10-24 17:08 ` [PATCH 09/10] xfs: " Matthew Wilcox (Oracle)
@ 2025-10-27 7:53 ` Christoph Hellwig
0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2025-10-27 7:53 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: linux-fsdevel, Christian Brauner, Carlos Maiolino, linux-xfs
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-27 7:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20251024170822.1427218-1-willy@infradead.org>
2025-10-24 17:08 ` [PATCH 07/10] iomap: Use folio_next_pos() Matthew Wilcox (Oracle)
2025-10-24 17:10 ` Darrick J. Wong
2025-10-27 7:53 ` Christoph Hellwig
2025-10-24 17:08 ` [PATCH 09/10] xfs: " Matthew Wilcox (Oracle)
2025-10-27 7:53 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox