Re: [PATCH] mm: move folio LRU helpers out of swap

From: Barry Song

Date: Tue Apr 07 2026 - 21:09:31 EST


On Tue, Apr 7, 2026 at 9:40 PM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:
>
> On Tue, Apr 07, 2026 at 07:00:02PM +0800, Jianyue Wu wrote:
> > +++ b/include/linux/mm.h
> > @@ -39,6 +39,8 @@
> > #include <linux/bitops.h>
> > #include <linux/iommu-debug-pagealloc.h>
> >
> > +#include "../../mm/folio_lru.h"
>
> This is enough to reject this patch.

It’s really odd for a top-level include to pull in a low-level header file.

it seems we do have some code outside mm who needs
lru APIs:

1 1036 fs/fuse/dev.c <<fuse_try_move_folio>>
folio_add_lru(newfolio);

1 868 arch/x86/kvm/svm/sev.c <<sev_launch_update_data>>
mark_page_accessed(inpages[i]);
2 1440 arch/x86/kvm/svm/sev.c <<sev_launch_secret>>
mark_page_accessed(pages[i]);
3 123 drivers/gpu/drm/i915/gem/i915_gem_phys.c
<<i915_gem_object_put_pages_phys>>
mark_page_accessed(page);
4 203 drivers/gpu/drm/i915/gem/i915_gem_userptr.c
<<i915_gem_userptr_put_pages>>
mark_page_accessed(page);
5 119 drivers/gpu/drm/i915/gt/shmem_utils.c <<__shmem_rw>>
mark_page_accessed(page);
6 150 drivers/gpu/drm/i915/gt/shmem_utils.c <<shmem_read_to_iosys_map>>
mark_page_accessed(page);
7 406 drivers/gpu/drm/radeon/radeon_ttm.c <<radeon_ttm_tt_unpin_userptr>>
mark_page_accessed(page);
8 353 drivers/gpu/drm/ttm/ttm_tt.c <<ttm_tt_swapout>>
mark_page_accessed(to_page);
9 571 fs/hfs/bnode.c <<hfs_bnode_put>>
mark_page_accessed(node->page[i]);
10 682 fs/hfsplus/bnode.c <<hfs_bnode_put>>
mark_page_accessed(node->page[i]);
11 2801 virt/kvm/kvm_main.c <<kvm_set_page_accessed>>
mark_page_accessed(page);

but for the belows, it seems they are safe to be not in the top-level
include - I mean include/linux/swap.h:

workingset_age_nonresident();
workingset_test_recent();
workingset_refault();
workingset_eviction();
workingset_activation();
lru_note_cost_unlock_irq();
void folio_add_lru_vma();
void lru_note_cost_refault();
void folio_add_lru_vma();
...

Many of them are essentially MM-specific.

>
> I don't think the patch is a good idea either. Yes, the current
> situation is messy, but you're not improving things by moving it to its
> own file.

Thanks
Barry