From 60a70e61430b2d568bc5e96f629c5855ee159ace Mon Sep 17 00:00:00 2001 From: "Matthew Wilcox (Oracle)" Date: Fri, 24 Oct 2025 18:08:18 +0100 Subject: mm: Use folio_next_pos() 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) Link: https://patch.msgid.link/20251024170822.1427218-11-willy@infradead.org Reviewed-by: David Hildenbrand Reviewed-by: Christoph Hellwig Cc: Hugh Dickins Cc: Baolin Wang Cc: Andrew Morton Cc: linux-mm@kvack.org Signed-off-by: Christian Brauner --- mm/truncate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mm/truncate.c') diff --git a/mm/truncate.c b/mm/truncate.c index 91eb92a5ce4f..a3d673533e32 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -387,7 +387,7 @@ void truncate_inode_pages_range(struct address_space *mapping, same_folio = (lstart >> PAGE_SHIFT) == (lend >> PAGE_SHIFT); folio = __filemap_get_folio(mapping, lstart >> PAGE_SHIFT, FGP_LOCK, 0); if (!IS_ERR(folio)) { - same_folio = lend < folio_pos(folio) + folio_size(folio); + same_folio = lend < folio_next_pos(folio); if (!truncate_inode_partial_folio(folio, lstart, lend)) { start = folio_next_index(folio); if (same_folio) -- cgit v1.2.3