Re: [PATCH v3 5/6] mm: move folio_index to mm/swap.h and remove no longer needed helper

From: Kairui Song
Date: Thu May 01 2025 - 06:08:48 EST


On Thu, May 1, 2025 at 5:11 AM David Hildenbrand <david@xxxxxxxxxx> wrote:
>
> On 30.04.25 20:10, Kairui Song wrote:
> > From: Kairui Song <kasong@xxxxxxxxxxx>
> >
> > 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@xxxxxxxxxxx>
> > ---
> > 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@xxxxxxxxxx>

Thanks!

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