linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/6] mm, swap: clean up swap cache mapping helper
@ 2025-04-30 18:10 Kairui Song
  2025-04-30 18:10 ` [PATCH v3 1/6] fuse: drop usage of folio_index Kairui Song
                   ` (5 more replies)
  0 siblings, 6 replies; 20+ messages in thread
From: Kairui Song @ 2025-04-30 18:10 UTC (permalink / raw)
  To: linux-mm
  Cc: Andrew Morton, Matthew Wilcox, Hugh Dickins, Chris Li,
	David Hildenbrand, Yosry Ahmed, Huang, Ying, Nhat Pham,
	Johannes Weiner, linux-kernel, Kairui Song

From: Kairui Song <kasong@tencent.com>

This series removes usage of folio_index usage in fs/, and remove swap
cache checking in folio_contains.

Currently, the swap cache is already no longer directly exposed to fs,
and swap cache will be more different from page cache. Clean up the
helpers first to simplify the code and eliminate the helpers used for
resolving circular header dependency issue between filemap and swap
headers, and prepare for further changes.

---

V1: https://lore.kernel.org/linux-mm/20250427185908.90450-1-ryncsn@gmail.com/
Changes:
- Collect Reviewed-by.
- Fix a build bot error.
- Slightly update commit messages to cover a few review concerns.

V2: https://lore.kernel.org/linux-mm/20250429114949.41124-1-ryncsn@gmail.com/
Changes:
- Collect Acked-by.
- VM_BUG_ON to VM_WARN_ON and minor code style update.

Kairui Song (6):
  fuse: drop usage of folio_index
  btrfs: drop usage of folio_index
  f2fs: drop usage of folio_index
  filemap: do not use folio_contains for swap cache folios
  mm: move folio_index to mm/swap.h and remove no longer needed helper
  mm, swap: remove no longer used swap mapping helper

 fs/btrfs/extent_io.c    |  2 +-
 fs/f2fs/data.c          |  4 ++--
 fs/f2fs/inline.c        |  4 ++--
 fs/f2fs/super.c         |  2 +-
 fs/fuse/file.c          |  4 ++--
 include/linux/pagemap.h | 29 ++++-------------------------
 mm/gup.c                |  1 +
 mm/memfd.c              |  1 +
 mm/migrate.c            |  1 +
 mm/page-writeback.c     |  1 +
 mm/swap.h               | 18 ++++++++++++++++++
 mm/swapfile.c           | 15 ---------------
 12 files changed, 34 insertions(+), 48 deletions(-)

-- 
2.49.0



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v3 1/6] fuse: drop usage of folio_index
  2025-04-30 18:10 [PATCH v3 0/6] mm, swap: clean up swap cache mapping helper Kairui Song
@ 2025-04-30 18:10 ` Kairui Song
  2025-04-30 21:08   ` David Hildenbrand
  2025-04-30 18:10 ` [PATCH v3 2/6] btrfs: " Kairui Song
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 20+ messages in thread
From: Kairui Song @ 2025-04-30 18:10 UTC (permalink / raw)
  To: linux-mm
  Cc: Andrew Morton, Matthew Wilcox, Hugh Dickins, Chris Li,
	David Hildenbrand, Yosry Ahmed, Huang, Ying, Nhat Pham,
	Johannes Weiner, linux-kernel, Kairui Song, Miklos Szeredi,
	Joanne Koong, Josef Bacik, linux-fsdevel

From: Kairui Song <kasong@tencent.com>

folio_index is only needed for mixed usage of page cache and swap
cache, for pure page cache usage, the caller can just use
folio->index instead.

It can't be a swap cache folio here.  Swap mapping may only call into fs
through `swap_rw` but fuse does not use that method for SWAP.

Signed-off-by: Kairui Song <kasong@tencent.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Joanne Koong <joannelkoong@gmail.com>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: linux-fsdevel@vger.kernel.org
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/fuse/file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 754378dd9f71..6f19a4daa559 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -487,7 +487,7 @@ static inline bool fuse_folio_is_writeback(struct inode *inode,
 					   struct folio *folio)
 {
 	pgoff_t last = folio_next_index(folio) - 1;
-	return fuse_range_is_writeback(inode, folio_index(folio), last);
+	return fuse_range_is_writeback(inode, folio->index, last);
 }
 
 static void fuse_wait_on_folio_writeback(struct inode *inode,
@@ -2349,7 +2349,7 @@ static bool fuse_writepage_need_send(struct fuse_conn *fc, struct folio *folio,
 		return true;
 
 	/* Discontinuity */
-	if (data->orig_folios[ap->num_folios - 1]->index + 1 != folio_index(folio))
+	if (data->orig_folios[ap->num_folios - 1]->index + 1 != folio->index)
 		return true;
 
 	/* Need to grow the pages array?  If so, did the expansion fail? */
-- 
2.49.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 2/6] btrfs: drop usage of folio_index
  2025-04-30 18:10 [PATCH v3 0/6] mm, swap: clean up swap cache mapping helper Kairui Song
  2025-04-30 18:10 ` [PATCH v3 1/6] fuse: drop usage of folio_index Kairui Song
@ 2025-04-30 18:10 ` Kairui Song
  2025-04-30 21:06   ` Andrew Morton
                     ` (3 more replies)
  2025-04-30 18:10 ` [PATCH v3 3/6] f2fs: " Kairui Song
                   ` (3 subsequent siblings)
  5 siblings, 4 replies; 20+ messages in thread
From: Kairui Song @ 2025-04-30 18:10 UTC (permalink / raw)
  To: linux-mm
  Cc: Andrew Morton, Matthew Wilcox, Hugh Dickins, Chris Li,
	David Hildenbrand, Yosry Ahmed, Huang, Ying, Nhat Pham,
	Johannes Weiner, linux-kernel, Kairui Song, Chris Mason,
	Josef Bacik, David Sterba, linux-btrfs, Qu Wenruo

From: Kairui Song <kasong@tencent.com>

folio_index is only needed for mixed usage of page cache and swap
cache, for pure page cache usage, the caller can just use
folio->index instead.

It can't be a swap cache folio here.  Swap mapping may only call into fs
through `swap_rw` but btrfs does not use that method for swap.

Signed-off-by: Kairui Song <kasong@tencent.com>
Cc: Chris Mason <clm@fb.com> (maintainer:BTRFS FILE SYSTEM)
Cc: Josef Bacik <josef@toxicpanda.com> (maintainer:BTRFS FILE SYSTEM)
Cc: David Sterba <dsterba@suse.com> (maintainer:BTRFS FILE SYSTEM)
Cc: linux-btrfs@vger.kernel.org (open list:BTRFS FILE SYSTEM)
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/extent_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 197f5e51c474..e08b50504d13 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3509,7 +3509,7 @@ static void btree_clear_folio_dirty_tag(struct folio *folio)
 	xa_lock_irq(&folio->mapping->i_pages);
 	if (!folio_test_dirty(folio))
 		__xa_clear_mark(&folio->mapping->i_pages,
-				folio_index(folio), PAGECACHE_TAG_DIRTY);
+				folio->index, PAGECACHE_TAG_DIRTY);
 	xa_unlock_irq(&folio->mapping->i_pages);
 }
 
-- 
2.49.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 3/6] f2fs: drop usage of folio_index
  2025-04-30 18:10 [PATCH v3 0/6] mm, swap: clean up swap cache mapping helper Kairui Song
  2025-04-30 18:10 ` [PATCH v3 1/6] fuse: drop usage of folio_index Kairui Song
  2025-04-30 18:10 ` [PATCH v3 2/6] btrfs: " Kairui Song
@ 2025-04-30 18:10 ` Kairui Song
  2025-04-30 21:08   ` David Hildenbrand
                     ` (2 more replies)
  2025-04-30 18:10 ` [PATCH v3 4/6] filemap: do not use folio_contains for swap cache folios Kairui Song
                   ` (2 subsequent siblings)
  5 siblings, 3 replies; 20+ messages in thread
From: Kairui Song @ 2025-04-30 18:10 UTC (permalink / raw)
  To: linux-mm
  Cc: Andrew Morton, Matthew Wilcox, Hugh Dickins, Chris Li,
	David Hildenbrand, Yosry Ahmed, Huang, Ying, Nhat Pham,
	Johannes Weiner, linux-kernel, Kairui Song, Jaegeuk Kim, Chao Yu,
	linux-f2fs-devel

From: Kairui Song <kasong@tencent.com>

folio_index is only needed for mixed usage of page cache and swap
cache, for pure page cache usage, the caller can just use
folio->index instead.

It can't be a swap cache folio here.  Swap mapping may only call into fs
through `swap_rw` but f2fs does not use that method for swap.

Signed-off-by: Kairui Song <kasong@tencent.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org> (maintainer:F2FS FILE SYSTEM)
Cc: Chao Yu <chao@kernel.org> (maintainer:F2FS FILE SYSTEM)
Cc: linux-f2fs-devel@lists.sourceforge.net (open list:F2FS FILE SYSTEM)
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/f2fs/data.c   | 4 ++--
 fs/f2fs/inline.c | 4 ++--
 fs/f2fs/super.c  | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 54f89f0ee69b..5745b97ca1f0 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2077,7 +2077,7 @@ static int f2fs_read_single_page(struct inode *inode, struct folio *folio,
 	sector_t last_block;
 	sector_t last_block_in_file;
 	sector_t block_nr;
-	pgoff_t index = folio_index(folio);
+	pgoff_t index = folio->index;
 	int ret = 0;
 
 	block_in_file = (sector_t)index;
@@ -2392,7 +2392,7 @@ static int f2fs_mpage_readpages(struct inode *inode,
 		}
 
 #ifdef CONFIG_F2FS_FS_COMPRESSION
-		index = folio_index(folio);
+		index = folio->index;
 
 		if (!f2fs_compressed_file(inode))
 			goto read_single_page;
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index ad92e9008781..aaaec3206538 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -86,7 +86,7 @@ void f2fs_do_read_inline_data(struct folio *folio, struct page *ipage)
 	if (folio_test_uptodate(folio))
 		return;
 
-	f2fs_bug_on(F2FS_I_SB(inode), folio_index(folio));
+	f2fs_bug_on(F2FS_I_SB(inode), folio->index);
 
 	folio_zero_segment(folio, MAX_INLINE_DATA(inode), folio_size(folio));
 
@@ -130,7 +130,7 @@ int f2fs_read_inline_data(struct inode *inode, struct folio *folio)
 		return -EAGAIN;
 	}
 
-	if (folio_index(folio))
+	if (folio->index)
 		folio_zero_segment(folio, 0, folio_size(folio));
 	else
 		f2fs_do_read_inline_data(folio, ipage);
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index f087b2b71c89..eac1dcb44637 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3432,7 +3432,7 @@ static int __f2fs_commit_super(struct f2fs_sb_info *sbi, struct folio *folio,
 	bio = bio_alloc(sbi->sb->s_bdev, 1, opf, GFP_NOFS);
 
 	/* it doesn't need to set crypto context for superblock update */
-	bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(folio_index(folio));
+	bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(folio->index);
 
 	if (!bio_add_folio(bio, folio, folio_size(folio), 0))
 		f2fs_bug_on(sbi, 1);
-- 
2.49.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 4/6] filemap: do not use folio_contains for swap cache folios
  2025-04-30 18:10 [PATCH v3 0/6] mm, swap: clean up swap cache mapping helper Kairui Song
                   ` (2 preceding siblings ...)
  2025-04-30 18:10 ` [PATCH v3 3/6] f2fs: " Kairui Song
@ 2025-04-30 18:10 ` Kairui Song
  2025-04-30 18:15   ` Kairui Song
  2025-04-30 18:10 ` [PATCH v3 5/6] mm: move folio_index to mm/swap.h and remove no longer needed helper Kairui Song
  2025-04-30 18:10 ` [PATCH v3 6/6] mm, swap: remove no longer used swap mapping helper Kairui Song
  5 siblings, 1 reply; 20+ messages in thread
From: Kairui Song @ 2025-04-30 18:10 UTC (permalink / raw)
  To: linux-mm
  Cc: Andrew Morton, Matthew Wilcox, Hugh Dickins, Chris Li,
	David Hildenbrand, Yosry Ahmed, Huang, Ying, Nhat Pham,
	Johannes Weiner, linux-kernel, Kairui Song

From: Kairui Song <kasong@tencent.com>

Currently, none of the folio_contains callers should encounter swap
cache folios.

For fs/ callers, swap cache folios are never part of their workflow.

For filemap and truncate, folio_contains is only used for sanity
checks to verify the folio index matches the expected
lookup / invalidation target.

The swap cache does not utilize filemap or truncate helpers in ways
that would trigger these checks, as it mostly implements its own
cache management.

Shmem won't trigger these sanity checks either unless thing went
wrong, as it would directly trigger a BUG because swap cache index are
unrelated and almost never matches shmem index. Shmem have to handle
mixed values of folios, shadows, and swap entries, so it has its own
way of handling the mapping.

While some filemap helpers works for swap cache space, the swap cache
is different from the page cache in many ways. So this particular helper
will unlikely to work in a helpful way for swap cache folios.

So make it explicit here that folio_contains should not be used for
swap cache folios. This helps to avoid misuse, make swap cache less
exposed and remove the folio_index usage here.

Signed-off-by: Kairui Song <kasong@tencent.com>
Acked-by: David Hildenbrand <david@redhat.com>
---
 include/linux/pagemap.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index af25fb640463..0c9aff5ec77f 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -935,14 +935,14 @@ static inline struct page *folio_file_page(struct folio *folio, pgoff_t index)
  * @folio: The folio.
  * @index: The page index within the file.
  *
- * Context: The caller should have the page locked in order to prevent
- * (eg) shmem from moving the page between the page cache and swap cache
- * and changing its index in the middle of the operation.
+ * Context: The caller should have the folio locked and ensure
+ * e.g., shmem did not move this folio to the swap cache.
  * Return: true or false.
  */
 static inline bool folio_contains(struct folio *folio, pgoff_t index)
 {
-	return index - folio_index(folio) < folio_nr_pages(folio);
+	VM_WARN_ON_FOLIO(folio_test_swapcache(folio), folio);
+	return index - folio->index < folio_nr_pages(folio);
 }
 
 unsigned filemap_get_folios(struct address_space *mapping, pgoff_t *start,
-- 
2.49.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 5/6] mm: move folio_index to mm/swap.h and remove no longer needed helper
  2025-04-30 18:10 [PATCH v3 0/6] mm, swap: clean up swap cache mapping helper Kairui Song
                   ` (3 preceding siblings ...)
  2025-04-30 18:10 ` [PATCH v3 4/6] filemap: do not use folio_contains for swap cache folios Kairui Song
@ 2025-04-30 18:10 ` Kairui Song
  2025-04-30 21:11   ` David Hildenbrand
  2025-04-30 18:10 ` [PATCH v3 6/6] mm, swap: remove no longer used swap mapping helper Kairui Song
  5 siblings, 1 reply; 20+ messages in thread
From: Kairui Song @ 2025-04-30 18:10 UTC (permalink / raw)
  To: linux-mm
  Cc: Andrew Morton, Matthew Wilcox, Hugh Dickins, Chris Li,
	David Hildenbrand, Yosry Ahmed, Huang, Ying, Nhat Pham,
	Johannes Weiner, linux-kernel, Kairui Song

From: Kairui Song <kasong@tencent.com>

There are no remaining users of folio_index() outside the mm subsystem.
Move it to mm/swap.h to co-locate it with swap_cache_index(), eliminating
a forward declaration, and a function call overhead.

Also remove the helper that was used to fix circular header dependency
issue.

Signed-off-by: Kairui Song <kasong@tencent.com>
---
 include/linux/pagemap.h | 20 --------------------
 mm/gup.c                |  1 +
 mm/memfd.c              |  1 +
 mm/migrate.c            |  1 +
 mm/page-writeback.c     |  1 +
 mm/swap.h               | 18 ++++++++++++++++++
 mm/swapfile.c           |  6 ------
 7 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 0c9aff5ec77f..627cb0338e5d 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -884,26 +884,6 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping,
 			mapping_gfp_mask(mapping));
 }
 
-extern pgoff_t __folio_swap_cache_index(struct folio *folio);
-
-/**
- * folio_index - File index of a folio.
- * @folio: The folio.
- *
- * For a folio which is either in the page cache or the swap cache,
- * return its index within the address_space it belongs to.  If you know
- * the page is definitely in the page cache, you can look at the folio's
- * index directly.
- *
- * Return: The index (offset in units of pages) of a folio in its file.
- */
-static inline pgoff_t folio_index(struct folio *folio)
-{
-	if (unlikely(folio_test_swapcache(folio)))
-		return __folio_swap_cache_index(folio);
-	return folio->index;
-}
-
 /**
  * folio_next_index - Get the index of the next folio.
  * @folio: The current folio.
diff --git a/mm/gup.c b/mm/gup.c
index f32168339390..91bbf57579f0 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -26,6 +26,7 @@
 #include <asm/tlbflush.h>
 
 #include "internal.h"
+#include "swap.h"
 
 struct follow_page_context {
 	struct dev_pagemap *pgmap;
diff --git a/mm/memfd.c b/mm/memfd.c
index c64df1343059..ab367e61553d 100644
--- a/mm/memfd.c
+++ b/mm/memfd.c
@@ -20,6 +20,7 @@
 #include <linux/memfd.h>
 #include <linux/pid_namespace.h>
 #include <uapi/linux/memfd.h>
+#include "swap.h"
 
 /*
  * We need a tag: a new tag would expand every xa_node by 8 bytes,
diff --git a/mm/migrate.c b/mm/migrate.c
index f3ee6d8d5e2e..662e5dc44b33 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -50,6 +50,7 @@
 #include <trace/events/migrate.h>
 
 #include "internal.h"
+#include "swap.h"
 
 bool isolate_movable_page(struct page *page, isolate_mode_t mode)
 {
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 20e1d76f1eba..9ff44b64d3d6 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -41,6 +41,7 @@
 #include <trace/events/writeback.h>
 
 #include "internal.h"
+#include "swap.h"
 
 /*
  * Sleep at most 200ms at a time in balance_dirty_pages().
diff --git a/mm/swap.h b/mm/swap.h
index 6f4a3f927edb..521bf510ec75 100644
--- a/mm/swap.h
+++ b/mm/swap.h
@@ -201,4 +201,22 @@ static inline int swap_zeromap_batch(swp_entry_t entry, int max_nr,
 
 #endif /* CONFIG_SWAP */
 
+/**
+ * folio_index - File index of a folio.
+ * @folio: The folio.
+ *
+ * For a folio which is either in the page cache or the swap cache,
+ * return its index within the address_space it belongs to.  If you know
+ * the folio is definitely in the page cache, you can look at the folio's
+ * index directly.
+ *
+ * Return: The index (offset in units of pages) of a folio in its file.
+ */
+static inline pgoff_t folio_index(struct folio *folio)
+{
+	if (unlikely(folio_test_swapcache(folio)))
+		return swap_cache_index(folio->swap);
+	return folio->index;
+}
+
 #endif /* _MM_SWAP_H */
diff --git a/mm/swapfile.c b/mm/swapfile.c
index b86637cfb17a..9fe58284079d 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -3671,12 +3671,6 @@ struct address_space *swapcache_mapping(struct folio *folio)
 }
 EXPORT_SYMBOL_GPL(swapcache_mapping);
 
-pgoff_t __folio_swap_cache_index(struct folio *folio)
-{
-	return swap_cache_index(folio->swap);
-}
-EXPORT_SYMBOL_GPL(__folio_swap_cache_index);
-
 /*
  * add_swap_count_continuation - called when a swap count is duplicated
  * beyond SWAP_MAP_MAX, it allocates a new page and links that to the entry's
-- 
2.49.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 6/6] mm, swap: remove no longer used swap mapping helper
  2025-04-30 18:10 [PATCH v3 0/6] mm, swap: clean up swap cache mapping helper Kairui Song
                   ` (4 preceding siblings ...)
  2025-04-30 18:10 ` [PATCH v3 5/6] mm: move folio_index to mm/swap.h and remove no longer needed helper Kairui Song
@ 2025-04-30 18:10 ` Kairui Song
  5 siblings, 0 replies; 20+ messages in thread
From: Kairui Song @ 2025-04-30 18:10 UTC (permalink / raw)
  To: linux-mm
  Cc: Andrew Morton, Matthew Wilcox, Hugh Dickins, Chris Li,
	David Hildenbrand, Yosry Ahmed, Huang, Ying, Nhat Pham,
	Johannes Weiner, linux-kernel, Kairui Song

From: Kairui Song <kasong@tencent.com>

This helper existed to fix the circular header dependency issue
but it is no longer used since commit 0d40cfe63a2f ("fs: remove
folio_file_mapping()"), remove it.

Signed-off-by: Kairui Song <kasong@tencent.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: David Hildenbrand <david@redhat.com>
---
 include/linux/pagemap.h | 1 -
 mm/swapfile.c           | 9 ---------
 2 files changed, 10 deletions(-)

diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 627cb0338e5d..8c6894d0ac27 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -533,7 +533,6 @@ static inline void filemap_nr_thps_dec(struct address_space *mapping)
 }
 
 struct address_space *folio_mapping(struct folio *);
-struct address_space *swapcache_mapping(struct folio *);
 
 /**
  * folio_flush_mapping - Find the file mapping this folio belongs to.
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 9fe58284079d..026090bf3efe 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -3662,15 +3662,6 @@ struct swap_info_struct *swp_swap_info(swp_entry_t entry)
 	return swap_type_to_swap_info(swp_type(entry));
 }
 
-/*
- * out-of-line methods to avoid include hell.
- */
-struct address_space *swapcache_mapping(struct folio *folio)
-{
-	return swp_swap_info(folio->swap)->swap_file->f_mapping;
-}
-EXPORT_SYMBOL_GPL(swapcache_mapping);
-
 /*
  * add_swap_count_continuation - called when a swap count is duplicated
  * beyond SWAP_MAP_MAX, it allocates a new page and links that to the entry's
-- 
2.49.0



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 4/6] filemap: do not use folio_contains for swap cache folios
  2025-04-30 18:10 ` [PATCH v3 4/6] filemap: do not use folio_contains for swap cache folios Kairui Song
@ 2025-04-30 18:15   ` Kairui Song
  0 siblings, 0 replies; 20+ messages in thread
From: Kairui Song @ 2025-04-30 18:15 UTC (permalink / raw)
  To: linux-mm
  Cc: Andrew Morton, Matthew Wilcox, Hugh Dickins, Chris Li,
	David Hildenbrand, Yosry Ahmed, Huang, Ying, Nhat Pham,
	Johannes Weiner, linux-kernel

On Thu, May 1, 2025 at 2:11 AM Kairui Song <ryncsn@gmail.com> wrote:
>
> From: Kairui Song <kasong@tencent.com>
>
> Currently, none of the folio_contains callers should encounter swap
> cache folios.
>
> For fs/ callers, swap cache folios are never part of their workflow.
>
> For filemap and truncate, folio_contains is only used for sanity
> checks to verify the folio index matches the expected
> lookup / invalidation target.
>
> The swap cache does not utilize filemap or truncate helpers in ways
> that would trigger these checks, as it mostly implements its own
> cache management.
>
> Shmem won't trigger these sanity checks either unless thing went
> wrong, as it would directly trigger a BUG because swap cache index are
> unrelated and almost never matches shmem index. Shmem have to handle
> mixed values of folios, shadows, and swap entries, so it has its own
> way of handling the mapping.
>
> While some filemap helpers works for swap cache space, the swap cache
> is different from the page cache in many ways. So this particular helper
> will unlikely to work in a helpful way for swap cache folios.
>
> So make it explicit here that folio_contains should not be used for
> swap cache folios. This helps to avoid misuse, make swap cache less
> exposed and remove the folio_index usage here.
>
> Signed-off-by: Kairui Song <kasong@tencent.com>
> Acked-by: David Hildenbrand <david@redhat.com>
> ---
>  include/linux/pagemap.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index af25fb640463..0c9aff5ec77f 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -935,14 +935,14 @@ static inline struct page *folio_file_page(struct folio *folio, pgoff_t index)
>   * @folio: The folio.
>   * @index: The page index within the file.
>   *
> - * Context: The caller should have the page locked in order to prevent
> - * (eg) shmem from moving the page between the page cache and swap cache
> - * and changing its index in the middle of the operation.
> + * Context: The caller should have the folio locked and ensure
> + * e.g., shmem did not move this folio to the swap cache.
>   * Return: true or false.
>   */
>  static inline bool folio_contains(struct folio *folio, pgoff_t index)
>  {
> -       return index - folio_index(folio) < folio_nr_pages(folio);
> +       VM_WARN_ON_FOLIO(folio_test_swapcache(folio), folio);

Ah, my bad, it will be better to be VM_WARN_ON_ONCE_FOLIO here as
suggested by David, other than this this series should be good.

> +       return index - folio->index < folio_nr_pages(folio);
>  }
>
>  unsigned filemap_get_folios(struct address_space *mapping, pgoff_t *start,
> --
> 2.49.0
>


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 2/6] btrfs: drop usage of folio_index
  2025-04-30 18:10 ` [PATCH v3 2/6] btrfs: " Kairui Song
@ 2025-04-30 21:06   ` Andrew Morton
  2025-04-30 21:07     ` David Hildenbrand
  2025-04-30 21:08   ` David Hildenbrand
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 20+ messages in thread
From: Andrew Morton @ 2025-04-30 21:06 UTC (permalink / raw)
  To: Kairui Song
  Cc: Kairui Song, linux-mm, Matthew Wilcox, Hugh Dickins, Chris Li,
	David Hildenbrand, Yosry Ahmed, Huang, Ying, Nhat Pham,
	Johannes Weiner, linux-kernel, Chris Mason, Josef Bacik,
	David Sterba, linux-btrfs, Qu Wenruo

On Thu,  1 May 2025 02:10:48 +0800 Kairui Song <ryncsn@gmail.com> wrote:

> Cc: Chris Mason <clm@fb.com> (maintainer:BTRFS FILE SYSTEM)
> Cc: Josef Bacik <josef@toxicpanda.com> (maintainer:BTRFS FILE SYSTEM)
> Cc: David Sterba <dsterba@suse.com> (maintainer:BTRFS FILE SYSTEM)

Please tell us where these extra tags came from.  Did some tool
generate them?

I think they're quite useful - perhaps something we could encourage.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 2/6] btrfs: drop usage of folio_index
  2025-04-30 21:06   ` Andrew Morton
@ 2025-04-30 21:07     ` David Hildenbrand
  2025-05-01 10:13       ` Kairui Song
  0 siblings, 1 reply; 20+ messages in thread
From: David Hildenbrand @ 2025-04-30 21:07 UTC (permalink / raw)
  To: Andrew Morton, Kairui Song
  Cc: Kairui Song, linux-mm, Matthew Wilcox, Hugh Dickins, Chris Li,
	Yosry Ahmed, Huang, Ying, Nhat Pham, Johannes Weiner,
	linux-kernel, Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
	Qu Wenruo

On 30.04.25 23:06, Andrew Morton wrote:
> On Thu,  1 May 2025 02:10:48 +0800 Kairui Song <ryncsn@gmail.com> wrote:
> 
>> Cc: Chris Mason <clm@fb.com> (maintainer:BTRFS FILE SYSTEM)
>> Cc: Josef Bacik <josef@toxicpanda.com> (maintainer:BTRFS FILE SYSTEM)
>> Cc: David Sterba <dsterba@suse.com> (maintainer:BTRFS FILE SYSTEM)
> 
> Please tell us where these extra tags came from.  Did some tool
> generate them?
> 
> I think they're quite useful - perhaps something we could encourage.
> 

I guess that's just the get_maintainers output?

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 1/6] fuse: drop usage of folio_index
  2025-04-30 18:10 ` [PATCH v3 1/6] fuse: drop usage of folio_index Kairui Song
@ 2025-04-30 21:08   ` David Hildenbrand
  0 siblings, 0 replies; 20+ messages in thread
From: David Hildenbrand @ 2025-04-30 21:08 UTC (permalink / raw)
  To: Kairui Song, linux-mm
  Cc: Andrew Morton, Matthew Wilcox, Hugh Dickins, Chris Li,
	Yosry Ahmed, Huang, Ying, Nhat Pham, Johannes Weiner,
	linux-kernel, Miklos Szeredi, Joanne Koong, Josef Bacik,
	linux-fsdevel

On 30.04.25 20:10, Kairui Song wrote:
> From: Kairui Song <kasong@tencent.com>
> 
> folio_index is only needed for mixed usage of page cache and swap
> cache, for pure page cache usage, the caller can just use
> folio->index instead.
> 
> It can't be a swap cache folio here.  Swap mapping may only call into fs
> through `swap_rw` but fuse does not use that method for SWAP.
> 
> Signed-off-by: Kairui Song <kasong@tencent.com>
> Cc: Miklos Szeredi <miklos@szeredi.hu>
> Cc: Joanne Koong <joannelkoong@gmail.com>
> Cc: Josef Bacik <josef@toxicpanda.com>
> Cc: linux-fsdevel@vger.kernel.org
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>   fs/fuse/file.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index 754378dd9f71..6f19a4daa559 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -487,7 +487,7 @@ static inline bool fuse_folio_is_writeback(struct inode *inode,
>   					   struct folio *folio)
>   {
>   	pgoff_t last = folio_next_index(folio) - 1;
> -	return fuse_range_is_writeback(inode, folio_index(folio), last);
> +	return fuse_range_is_writeback(inode, folio->index, last);
>   }
>   
>   static void fuse_wait_on_folio_writeback(struct inode *inode,
> @@ -2349,7 +2349,7 @@ static bool fuse_writepage_need_send(struct fuse_conn *fc, struct folio *folio,
>   		return true;
>   
>   	/* Discontinuity */
> -	if (data->orig_folios[ap->num_folios - 1]->index + 1 != folio_index(folio))
> +	if (data->orig_folios[ap->num_folios - 1]->index + 1 != folio->index)
>   		return true;
>   
>   	/* Need to grow the pages array?  If so, did the expansion fail? */

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 2/6] btrfs: drop usage of folio_index
  2025-04-30 18:10 ` [PATCH v3 2/6] btrfs: " Kairui Song
  2025-04-30 21:06   ` Andrew Morton
@ 2025-04-30 21:08   ` David Hildenbrand
  2025-05-01  8:50   ` David Sterba
  2025-05-02 11:10   ` David Sterba
  3 siblings, 0 replies; 20+ messages in thread
From: David Hildenbrand @ 2025-04-30 21:08 UTC (permalink / raw)
  To: Kairui Song, linux-mm
  Cc: Andrew Morton, Matthew Wilcox, Hugh Dickins, Chris Li,
	Yosry Ahmed, Huang, Ying, Nhat Pham, Johannes Weiner,
	linux-kernel, Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
	Qu Wenruo

On 30.04.25 20:10, Kairui Song wrote:
> From: Kairui Song <kasong@tencent.com>
> 
> folio_index is only needed for mixed usage of page cache and swap
> cache, for pure page cache usage, the caller can just use
> folio->index instead.
> 
> It can't be a swap cache folio here.  Swap mapping may only call into fs
> through `swap_rw` but btrfs does not use that method for swap.
> 
> Signed-off-by: Kairui Song <kasong@tencent.com>
> Cc: Chris Mason <clm@fb.com> (maintainer:BTRFS FILE SYSTEM)
> Cc: Josef Bacik <josef@toxicpanda.com> (maintainer:BTRFS FILE SYSTEM)
> Cc: David Sterba <dsterba@suse.com> (maintainer:BTRFS FILE SYSTEM)
> Cc: linux-btrfs@vger.kernel.org (open list:BTRFS FILE SYSTEM)
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Reviewed-by: Qu Wenruo <wqu@suse.com>
> ---
>   fs/btrfs/extent_io.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 197f5e51c474..e08b50504d13 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -3509,7 +3509,7 @@ static void btree_clear_folio_dirty_tag(struct folio *folio)
>   	xa_lock_irq(&folio->mapping->i_pages);
>   	if (!folio_test_dirty(folio))
>   		__xa_clear_mark(&folio->mapping->i_pages,
> -				folio_index(folio), PAGECACHE_TAG_DIRTY);
> +				folio->index, PAGECACHE_TAG_DIRTY);
>   	xa_unlock_irq(&folio->mapping->i_pages);
>   }
>   

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 3/6] f2fs: drop usage of folio_index
  2025-04-30 18:10 ` [PATCH v3 3/6] f2fs: " Kairui Song
@ 2025-04-30 21:08   ` David Hildenbrand
  2025-05-06  8:49   ` Chao Yu
  2025-06-09 20:56   ` [f2fs-dev] " patchwork-bot+f2fs
  2 siblings, 0 replies; 20+ messages in thread
From: David Hildenbrand @ 2025-04-30 21:08 UTC (permalink / raw)
  To: Kairui Song, linux-mm
  Cc: Andrew Morton, Matthew Wilcox, Hugh Dickins, Chris Li,
	Yosry Ahmed, Huang, Ying, Nhat Pham, Johannes Weiner,
	linux-kernel, Jaegeuk Kim, Chao Yu, linux-f2fs-devel

On 30.04.25 20:10, Kairui Song wrote:
> From: Kairui Song <kasong@tencent.com>
> 
> folio_index is only needed for mixed usage of page cache and swap
> cache, for pure page cache usage, the caller can just use
> folio->index instead.
> 
> It can't be a swap cache folio here.  Swap mapping may only call into fs
> through `swap_rw` but f2fs does not use that method for swap.
> 
> Signed-off-by: Kairui Song <kasong@tencent.com>
> Cc: Jaegeuk Kim <jaegeuk@kernel.org> (maintainer:F2FS FILE SYSTEM)
> Cc: Chao Yu <chao@kernel.org> (maintainer:F2FS FILE SYSTEM)
> Cc: linux-f2fs-devel@lists.sourceforge.net (open list:F2FS FILE SYSTEM)
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 5/6] mm: move folio_index to mm/swap.h and remove no longer needed helper
  2025-04-30 18:10 ` [PATCH v3 5/6] mm: move folio_index to mm/swap.h and remove no longer needed helper Kairui Song
@ 2025-04-30 21:11   ` David Hildenbrand
  2025-05-01 10:08     ` Kairui Song
  0 siblings, 1 reply; 20+ messages in thread
From: David Hildenbrand @ 2025-04-30 21:11 UTC (permalink / raw)
  To: Kairui Song, linux-mm
  Cc: Andrew Morton, Matthew Wilcox, Hugh Dickins, Chris Li,
	Yosry Ahmed, Huang, Ying, Nhat Pham, Johannes Weiner,
	linux-kernel

On 30.04.25 20:10, Kairui Song wrote:
> From: Kairui Song <kasong@tencent.com>
> 
> There are no remaining users of folio_index() outside the mm subsystem.
> Move it to mm/swap.h to co-locate it with swap_cache_index(), eliminating
> a forward declaration, and a function call overhead.
> 
> Also remove the helper that was used to fix circular header dependency
> issue.
> 
> Signed-off-by: Kairui Song <kasong@tencent.com>
> ---
>   include/linux/pagemap.h | 20 --------------------
>   mm/gup.c                |  1 +
>   mm/memfd.c              |  1 +
>   mm/migrate.c            |  1 +
>   mm/page-writeback.c     |  1 +
>   mm/swap.h               | 18 ++++++++++++++++++
>   mm/swapfile.c           |  6 ------
>   7 files changed, 22 insertions(+), 26 deletions(-)

[...]

>   bool isolate_movable_page(struct page *page, isolate_mode_t mode)
>   {
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index 20e1d76f1eba..9ff44b64d3d6 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -41,6 +41,7 @@
>   #include <trace/events/writeback.h>
>   
>   #include "internal.h"
> +#include "swap.h"

I wonder if we should just have it in mm/internal.h instead?

In any case

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 2/6] btrfs: drop usage of folio_index
  2025-04-30 18:10 ` [PATCH v3 2/6] btrfs: " Kairui Song
  2025-04-30 21:06   ` Andrew Morton
  2025-04-30 21:08   ` David Hildenbrand
@ 2025-05-01  8:50   ` David Sterba
  2025-05-02 11:10   ` David Sterba
  3 siblings, 0 replies; 20+ messages in thread
From: David Sterba @ 2025-05-01  8:50 UTC (permalink / raw)
  To: Kairui Song
  Cc: linux-mm, Andrew Morton, Matthew Wilcox, Hugh Dickins, Chris Li,
	David Hildenbrand, Yosry Ahmed, Huang, Ying, Nhat Pham,
	Johannes Weiner, linux-kernel, Chris Mason, Josef Bacik,
	David Sterba, linux-btrfs, Qu Wenruo

On Thu, May 01, 2025 at 02:10:48AM +0800, Kairui Song wrote:
> From: Kairui Song <kasong@tencent.com>
> 
> folio_index is only needed for mixed usage of page cache and swap
> cache, for pure page cache usage, the caller can just use
> folio->index instead.
> 
> It can't be a swap cache folio here.  Swap mapping may only call into fs
> through `swap_rw` but btrfs does not use that method for swap.
> 
> Signed-off-by: Kairui Song <kasong@tencent.com>
> Cc: Chris Mason <clm@fb.com> (maintainer:BTRFS FILE SYSTEM)
> Cc: Josef Bacik <josef@toxicpanda.com> (maintainer:BTRFS FILE SYSTEM)
> Cc: David Sterba <dsterba@suse.com> (maintainer:BTRFS FILE SYSTEM)
> Cc: linux-btrfs@vger.kernel.org (open list:BTRFS FILE SYSTEM)
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Reviewed-by: Qu Wenruo <wqu@suse.com>

The patch is from a series but seems to be independent. I'd like to take
it through the btrfs tree unless you have other work that depends on it.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 5/6] mm: move folio_index to mm/swap.h and remove no longer needed helper
  2025-04-30 21:11   ` David Hildenbrand
@ 2025-05-01 10:08     ` Kairui Song
  0 siblings, 0 replies; 20+ messages in thread
From: Kairui Song @ 2025-05-01 10:08 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: linux-mm, Andrew Morton, Matthew Wilcox, Hugh Dickins, Chris Li,
	Yosry Ahmed, Huang, Ying, Nhat Pham, Johannes Weiner,
	linux-kernel

On Thu, May 1, 2025 at 5:11 AM David Hildenbrand <david@redhat.com> wrote:
>
> On 30.04.25 20:10, Kairui Song wrote:
> > From: Kairui Song <kasong@tencent.com>
> >
> > There are no remaining users of folio_index() outside the mm subsystem.
> > Move it to mm/swap.h to co-locate it with swap_cache_index(), eliminating
> > a forward declaration, and a function call overhead.
> >
> > Also remove the helper that was used to fix circular header dependency
> > issue.
> >
> > Signed-off-by: Kairui Song <kasong@tencent.com>
> > ---
> >   include/linux/pagemap.h | 20 --------------------
> >   mm/gup.c                |  1 +
> >   mm/memfd.c              |  1 +
> >   mm/migrate.c            |  1 +
> >   mm/page-writeback.c     |  1 +
> >   mm/swap.h               | 18 ++++++++++++++++++
> >   mm/swapfile.c           |  6 ------
> >   7 files changed, 22 insertions(+), 26 deletions(-)
>
> [...]
>
> >   bool isolate_movable_page(struct page *page, isolate_mode_t mode)
> >   {
> > diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> > index 20e1d76f1eba..9ff44b64d3d6 100644
> > --- a/mm/page-writeback.c
> > +++ b/mm/page-writeback.c
> > @@ -41,6 +41,7 @@
> >   #include <trace/events/writeback.h>
> >
> >   #include "internal.h"
> > +#include "swap.h"
>
> I wonder if we should just have it in mm/internal.h instead?

That will require internal.h to depend on swap.h. In follow up patches
I'd like to remove the folio_index usage in all places except migrate
and swap files, this will make the code cleaner and swap cache will be
less exposed.

>
> In any case
>
> Acked-by: David Hildenbrand <david@redhat.com>

Thanks!

>
> --
> Cheers,
>
> David / dhildenb
>
>


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 2/6] btrfs: drop usage of folio_index
  2025-04-30 21:07     ` David Hildenbrand
@ 2025-05-01 10:13       ` Kairui Song
  0 siblings, 0 replies; 20+ messages in thread
From: Kairui Song @ 2025-05-01 10:13 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: Andrew Morton, linux-mm, Matthew Wilcox, Hugh Dickins, Chris Li,
	Yosry Ahmed, Huang, Ying, Nhat Pham, Johannes Weiner,
	linux-kernel, Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
	Qu Wenruo

On Thu, May 1, 2025 at 5:07 AM David Hildenbrand <david@redhat.com> wrote:
>
> On 30.04.25 23:06, Andrew Morton wrote:
> > On Thu,  1 May 2025 02:10:48 +0800 Kairui Song <ryncsn@gmail.com> wrote:
> >
> >> Cc: Chris Mason <clm@fb.com> (maintainer:BTRFS FILE SYSTEM)
> >> Cc: Josef Bacik <josef@toxicpanda.com> (maintainer:BTRFS FILE SYSTEM)
> >> Cc: David Sterba <dsterba@suse.com> (maintainer:BTRFS FILE SYSTEM)
> >
> > Please tell us where these extra tags came from.  Did some tool
> > generate them?
> >
> > I think they're quite useful - perhaps something we could encourage.
> >
>
> I guess that's just the get_maintainers output?

Yes, `./scripts/get_maintainer.pl fs/btrfs/` generated these,
`./scripts/checkpatch.pl` didn't complain so I forgot to truncate
them. Glad to know it's considered helpful :)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 2/6] btrfs: drop usage of folio_index
  2025-04-30 18:10 ` [PATCH v3 2/6] btrfs: " Kairui Song
                     ` (2 preceding siblings ...)
  2025-05-01  8:50   ` David Sterba
@ 2025-05-02 11:10   ` David Sterba
  3 siblings, 0 replies; 20+ messages in thread
From: David Sterba @ 2025-05-02 11:10 UTC (permalink / raw)
  To: Kairui Song
  Cc: linux-mm, Andrew Morton, Matthew Wilcox, Hugh Dickins, Chris Li,
	David Hildenbrand, Yosry Ahmed, Huang, Ying, Nhat Pham,
	Johannes Weiner, linux-kernel, Chris Mason, Josef Bacik,
	David Sterba, linux-btrfs, Qu Wenruo

On Thu, May 01, 2025 at 02:10:48AM +0800, Kairui Song wrote:
> From: Kairui Song <kasong@tencent.com>
> 
> folio_index is only needed for mixed usage of page cache and swap
> cache, for pure page cache usage, the caller can just use
> folio->index instead.
> 
> It can't be a swap cache folio here.  Swap mapping may only call into fs
> through `swap_rw` but btrfs does not use that method for swap.
> 
> Signed-off-by: Kairui Song <kasong@tencent.com>
> Cc: Chris Mason <clm@fb.com> (maintainer:BTRFS FILE SYSTEM)
> Cc: Josef Bacik <josef@toxicpanda.com> (maintainer:BTRFS FILE SYSTEM)
> Cc: David Sterba <dsterba@suse.com> (maintainer:BTRFS FILE SYSTEM)
> Cc: linux-btrfs@vger.kernel.org (open list:BTRFS FILE SYSTEM)
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Reviewed-by: Qu Wenruo <wqu@suse.com>

I've added the patch to our for-next, so Andrew can drop it from his
patch queue.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 3/6] f2fs: drop usage of folio_index
  2025-04-30 18:10 ` [PATCH v3 3/6] f2fs: " Kairui Song
  2025-04-30 21:08   ` David Hildenbrand
@ 2025-05-06  8:49   ` Chao Yu
  2025-06-09 20:56   ` [f2fs-dev] " patchwork-bot+f2fs
  2 siblings, 0 replies; 20+ messages in thread
From: Chao Yu @ 2025-05-06  8:49 UTC (permalink / raw)
  To: Kairui Song, linux-mm
  Cc: chao, Andrew Morton, Matthew Wilcox, Hugh Dickins, Chris Li,
	David Hildenbrand, Yosry Ahmed, Huang, Ying, Nhat Pham,
	Johannes Weiner, linux-kernel, Jaegeuk Kim, linux-f2fs-devel

On 2025/5/1 2:10, Kairui Song wrote:
> From: Kairui Song <kasong@tencent.com>
> 
> folio_index is only needed for mixed usage of page cache and swap
> cache, for pure page cache usage, the caller can just use
> folio->index instead.
> 
> It can't be a swap cache folio here.  Swap mapping may only call into fs
> through `swap_rw` but f2fs does not use that method for swap.
> 
> Signed-off-by: Kairui Song <kasong@tencent.com>
> Cc: Jaegeuk Kim <jaegeuk@kernel.org> (maintainer:F2FS FILE SYSTEM)
> Cc: Chao Yu <chao@kernel.org> (maintainer:F2FS FILE SYSTEM)
> Cc: linux-f2fs-devel@lists.sourceforge.net (open list:F2FS FILE SYSTEM)
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [f2fs-dev] [PATCH v3 3/6] f2fs: drop usage of folio_index
  2025-04-30 18:10 ` [PATCH v3 3/6] f2fs: " Kairui Song
  2025-04-30 21:08   ` David Hildenbrand
  2025-05-06  8:49   ` Chao Yu
@ 2025-06-09 20:56   ` patchwork-bot+f2fs
  2 siblings, 0 replies; 20+ messages in thread
From: patchwork-bot+f2fs @ 2025-06-09 20:56 UTC (permalink / raw)
  To: Kairui Song
  Cc: linux-mm, kasong, nphamcs, david, chrisl, hughd, linux-kernel,
	willy, linux-f2fs-devel, yosryahmed, hannes, jaegeuk, akpm,
	ying.huang

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Andrew Morton <akpm@linux-foundation.org>:

On Thu,  1 May 2025 02:10:49 +0800 you wrote:
> From: Kairui Song <kasong@tencent.com>
> 
> folio_index is only needed for mixed usage of page cache and swap
> cache, for pure page cache usage, the caller can just use
> folio->index instead.
> 
> It can't be a swap cache folio here.  Swap mapping may only call into fs
> through `swap_rw` but f2fs does not use that method for swap.
> 
> [...]

Here is the summary with links:
  - [f2fs-dev,v3,3/6] f2fs: drop usage of folio_index
    https://git.kernel.org/jaegeuk/f2fs/c/fe15ec046431

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2025-06-09 20:55 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-30 18:10 [PATCH v3 0/6] mm, swap: clean up swap cache mapping helper Kairui Song
2025-04-30 18:10 ` [PATCH v3 1/6] fuse: drop usage of folio_index Kairui Song
2025-04-30 21:08   ` David Hildenbrand
2025-04-30 18:10 ` [PATCH v3 2/6] btrfs: " Kairui Song
2025-04-30 21:06   ` Andrew Morton
2025-04-30 21:07     ` David Hildenbrand
2025-05-01 10:13       ` Kairui Song
2025-04-30 21:08   ` David Hildenbrand
2025-05-01  8:50   ` David Sterba
2025-05-02 11:10   ` David Sterba
2025-04-30 18:10 ` [PATCH v3 3/6] f2fs: " Kairui Song
2025-04-30 21:08   ` David Hildenbrand
2025-05-06  8:49   ` Chao Yu
2025-06-09 20:56   ` [f2fs-dev] " patchwork-bot+f2fs
2025-04-30 18:10 ` [PATCH v3 4/6] filemap: do not use folio_contains for swap cache folios Kairui Song
2025-04-30 18:15   ` Kairui Song
2025-04-30 18:10 ` [PATCH v3 5/6] mm: move folio_index to mm/swap.h and remove no longer needed helper Kairui Song
2025-04-30 21:11   ` David Hildenbrand
2025-05-01 10:08     ` Kairui Song
2025-04-30 18:10 ` [PATCH v3 6/6] mm, swap: remove no longer used swap mapping helper Kairui Song

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).