]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mm: move folio_index to mm/swap.h and remove no longer needed helper
authorKairui Song <kasong@tencent.com>
Wed, 30 Apr 2025 18:10:51 +0000 (02:10 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 13 May 2025 06:50:50 +0000 (23:50 -0700)
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.

Link: https://lkml.kernel.org/r/20250430181052.55698-6-ryncsn@gmail.com
Signed-off-by: Kairui Song <kasong@tencent.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Chao Yu <chao@kernel.org>
Cc: Chris Li <chrisl@kernel.org>
Cc: Chris Mason <clm@fb.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: David Sterba <dsterba@suse.com>
Cc: "Huang, Ying" <ying.huang@linux.alibaba.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Joanne Koong <joannelkoong@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Qu Wenruo <wqu@suse.com>
Cc: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/pagemap.h
mm/gup.c
mm/memfd.c
mm/migrate.c
mm/page-writeback.c
mm/swap.h
mm/swapfile.c

index b2c2ff8de04667bf3b9f27b074c698a0e73b73c2..5d66786867ebfd05810c654f32b9de852dd22081 100644 (file)
@@ -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.
index f3216833939017da5488f79abde0b8518d8623c0..91bbf57579f0cffdc0bf407b6f3930cfee9a6b05 100644 (file)
--- 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;
index c64df1343059b2e66ec539bc3e8aade8a6fa417b..ab367e61553d177d37c33b629f0083c49dea0b1a 100644 (file)
@@ -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,
index 273d46771a6cab428e20adce122cb913a9c03e2d..784ac2256d0844fc72337aec251d6f20561be8b0 100644 (file)
@@ -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)
 {
index 20e1d76f1eba3f0e5ab4454b414b61d4366c8703..9ff44b64d3d6e673ee1559f8936bbd0c5c5c182b 100644 (file)
@@ -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().
index 6f4a3f927edb2d4adb298b92fb220f687b67a87a..521bf510ec75315bd7f77bf11f2c6ff6ca1dd3a8 100644 (file)
--- 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 */
index b86637cfb17a8923288a3f0801aca0e8f3c596c9..9fe58284079d476a6596dc9096a24b11f6995c27 100644 (file)
@@ -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