Commit 7d0f0f06 authored by Kairui Song's avatar Kairui Song Committed by Andrew Morton
Browse files

mm: move folio_index to mm/swap.h and remove no longer needed helper

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: default avatarKairui Song <kasong@tencent.com>
Acked-by: default avatarDavid 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: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 2b80f633
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
@@ -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.
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <asm/tlbflush.h>

#include "internal.h"
#include "swap.h"

struct follow_page_context {
	struct dev_pagemap *pgmap;
+1 −0
Original line number Diff line number Diff line
@@ -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,
+1 −0
Original line number Diff line number Diff line
@@ -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)
{
+1 −0
Original line number Diff line number Diff line
@@ -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().
Loading