From: Kairui Song <kasong@tencent.com>
This helper was used when swap cache was mixed with swap cache. Now they
are completely separate from each other, access to the swap cache is all
wrapped by the swap_cache_* helpers, which expect the folio's swap entry
as a parameter.
This helper is no longer used, remove the last redundant user and drop it.
Signed-off-by: Kairui Song <kasong@tencent.com>
---
mm/migrate.c | 4 ++--
mm/swap.h | 21 ---------------------
2 files changed, 2 insertions(+), 23 deletions(-)
diff --git a/mm/migrate.c b/mm/migrate.c
index e3065c9edb55..97c931b31940 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -561,7 +561,7 @@ void pmd_migration_entry_wait(struct mm_struct *mm, pmd_t *pmd)
static int __folio_migrate_mapping(struct address_space *mapping,
struct folio *newfolio, struct folio *folio, int expected_count)
{
- XA_STATE(xas, &mapping->i_pages, folio_index(folio));
+ XA_STATE(xas, &mapping->i_pages, folio->index);
struct swap_cluster_info *ci = NULL;
struct zone *oldzone, *newzone;
int dirty;
@@ -714,7 +714,7 @@ EXPORT_SYMBOL(folio_migrate_mapping);
int migrate_huge_page_move_mapping(struct address_space *mapping,
struct folio *dst, struct folio *src)
{
- XA_STATE(xas, &mapping->i_pages, folio_index(src));
+ XA_STATE(xas, &mapping->i_pages, src->index);
int rc, expected_count = folio_expected_ref_count(src) + 1;
if (folio_ref_count(src) != expected_count)
diff --git a/mm/swap.h b/mm/swap.h
index 8d8efdf1297a..d034c13d8dd2 100644
--- a/mm/swap.h
+++ b/mm/swap.h
@@ -445,25 +445,4 @@ static inline int non_swapcache_batch(swp_entry_t entry, int max_nr)
return 0;
}
#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)
-{
-#ifdef CONFIG_SWAP
- if (unlikely(folio_test_swapcache(folio)))
- return swp_offset(folio->swap);
-#endif
- return folio->index;
-}
-
#endif /* _MM_SWAP_H */
--
2.51.0
On 2025/10/7 04:02, Kairui Song wrote: > From: Kairui Song <kasong@tencent.com> > > This helper was used when swap cache was mixed with swap cache. Now they > are completely separate from each other, access to the swap cache is all > wrapped by the swap_cache_* helpers, which expect the folio's swap entry > as a parameter. > > This helper is no longer used, remove the last redundant user and drop it. > > Signed-off-by: Kairui Song <kasong@tencent.com> > --- With the commit message fixed, LGTM. Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Thanks for the cleanup. Agree with the other fix suggested by Nhat regarding swap cache vs page cache. On Mon, Oct 6, 2025 at 1:03 PM Kairui Song <ryncsn@gmail.com> wrote: > > From: Kairui Song <kasong@tencent.com> > > This helper was used when swap cache was mixed with swap cache. Now they > are completely separate from each other, access to the swap cache is all > wrapped by the swap_cache_* helpers, which expect the folio's swap entry > as a parameter. > > This helper is no longer used, remove the last redundant user and drop it. > > Signed-off-by: Kairui Song <kasong@tencent.com> > --- > mm/migrate.c | 4 ++-- > mm/swap.h | 21 --------------------- Nice. Acked-by: Chris Li <chrisl@kernel.org> Chris
On Mon, Oct 6, 2025 at 1:03 PM Kairui Song <ryncsn@gmail.com> wrote: > > From: Kairui Song <kasong@tencent.com> > > This helper was used when swap cache was mixed with swap cache. Now they mixed with page cache? ;) With that nit fixed: Acked-by: Nhat Pham <nphamcs@gmail.com>
On Wed, Oct 8, 2025 at 7:48 AM Nhat Pham <nphamcs@gmail.com> wrote: > > On Mon, Oct 6, 2025 at 1:03 PM Kairui Song <ryncsn@gmail.com> wrote: > > > > From: Kairui Song <kasong@tencent.com> > > > > This helper was used when swap cache was mixed with swap cache. Now they > > mixed with page cache? ;) Yes you're right :), thanks! > > With that nit fixed: > > Acked-by: Nhat Pham <nphamcs@gmail.com>
On Tue, 7 Oct 2025 16:48:40 -0700 Nhat Pham <nphamcs@gmail.com> wrote: > > This helper was used when swap cache was mixed with swap cache. Now they > > mixed with page cache? ;) I locally made that edit, thanks.
© 2016 - 2025 Red Hat, Inc.