From: Baoquan He <bhe@redhat.com>
To: Barry Song <baohua@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
Jianyue Wu <wujianyue000@gmail.com>,
linux-mm@kvack.org, akpm@linux-foundation.org, david@kernel.org,
mhocko@suse.com, zhengqi.arch@bytedance.com,
shakeel.butt@linux.dev, lorenzo.stoakes@oracle.com,
chrisl@kernel.org, kasong@tencent.com, shikemeng@huaweicloud.com,
nphamcs@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: move folio LRU helpers out of swap
Date: Wed, 8 Apr 2026 10:49:12 +0800 [thread overview]
Message-ID: <adXCKGN_9jFgLqI6@MiWiFi-R3L-srv> (raw)
In-Reply-To: <CAGsJ_4yNZiRpgyTbooJEkkefVxgWOywkcVd2BeY5Dq2wuicNNA@mail.gmail.com>
On 04/08/26 at 10:20am, Barry Song wrote:
> On Wed, Apr 8, 2026 at 9:39 AM Baoquan He <bhe@redhat.com> wrote:
> >
> > On 04/07/26 at 10:22am, Johannes Weiner wrote:
> > > On Tue, Apr 07, 2026 at 07:00:02PM +0800, Jianyue Wu wrote:
> > > > All allocated folios are added into lru lists for later reclaim whether
> > > > they are file or anonymous folios. However those folio lru operation codes
> > > > are put in mm/swap.c which is not so appropriate. Because swap code is
> > > > only for anonymous folios.
> > >
> > > Ironically, the only thing that doesn't fit in this file is the swap
> > > stuff. The page_cluster & sysctl should be static in swap_state.c.
> > >
> > > The rest seems thematically relatively clean - infrastructure for
> > > managing folio lifetime. swap.c is not the best name for it, but short
> > > of finding a very clear improvement I'd just leave it alone.
> >
> > Can't agree more. We should move page_cluster & sysctl and swap_setup()
> > to mm/swap_state.c, and rename mm/swap.c to mm/folio_lru.c or something
> > like that.
>
> Another issue is that many MM-internal items are placed in the
> top-level include/linux/swap.h, which is supposed to be used by
> code outside the MM subsystem as well.
>
> For example, the following are actually MM-internal:
>
> extern int vm_swappiness;
> swap_setup();
> workingset_*();
> try_to_free_pages();
> zone_reclaimable_pages();
> lruvec_lru_size();
> try_to_free_mem_cgroup_pages();
> ...
Ah, indeed. Seems we have been putting generic code related to reclaim into
swap.h|.c due to historic reason. From discussion, I think the below
three things are doable.
1) move page_cluster & sysctl and swap_setup() into mm/swap_state.c
because page_cluster is only used in mm/swap_state.c as Johannes
suggestd. And swap_setup() may need be renamed too?
2) rename mm/swap.c to mm/folio_lru.c or something like that to reflect
its real content;
3) Just Barry pointed out, move generic code related to reclaim out of
include/linux/swap.h e.g move into mm/internal.h if they are only
called inside mm/ folder,
Thanks
Baoquan
next prev parent reply other threads:[~2026-04-08 2:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 11:00 [PATCH] mm: move folio LRU helpers out of swap Jianyue Wu
2026-04-07 11:20 ` Michal Hocko
2026-04-07 12:31 ` Jianyue Wu
2026-04-07 12:46 ` Michal Hocko
2026-04-07 11:42 ` David Hildenbrand (Arm)
2026-04-07 12:33 ` Jianyue Wu
2026-04-07 13:40 ` Matthew Wilcox
2026-04-08 1:09 ` Barry Song
2026-04-07 14:22 ` Johannes Weiner
2026-04-08 0:41 ` Jianyue Wu
2026-04-08 2:27 ` Barry Song
2026-04-08 1:38 ` Baoquan He
2026-04-08 2:20 ` Barry Song
2026-04-08 2:49 ` Baoquan He [this message]
2026-04-08 14:50 ` Jianyue Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=adXCKGN_9jFgLqI6@MiWiFi-R3L-srv \
--to=bhe@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=chrisl@kernel.org \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=nphamcs@gmail.com \
--cc=shakeel.butt@linux.dev \
--cc=shikemeng@huaweicloud.com \
--cc=wujianyue000@gmail.com \
--cc=zhengqi.arch@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.