Re: [PATCH v2 1/3] mm/swap: colocate page-cluster sysctl with swap readahead

From: Jianyue Wu

Date: Sun May 31 2026 - 20:59:39 EST


On 6/1/2026 6:06 AM, Barry Song wrote:
> On Sun, May 31, 2026 at 5:50 PM Jianyue Wu <wujianyue000@xxxxxxxxx> wrote:
>>
>> page_cluster and the vm.page-cluster sysctl are only used by swap-in
>> readahead in swap_state.c. Move them out of swap.c together with
>> swap_readahead_setup(), and make page_cluster static to that file.
>>
>> Rename swap_setup() while moving it as well. The helper is internal to
>> MM and now only sets up swap readahead defaults and its sysctl hook, so
>> the more specific name matches its reduced scope.
>>
>> Signed-off-by: Jianyue Wu <wujianyue000@xxxxxxxxx>
>> ---
>> include/linux/swap.h | 2 +-
>> mm/swap.c | 36 ------------------------------------
>> mm/swap.h | 2 --
>> mm/swap_state.c | 37 +++++++++++++++++++++++++++++++++++++
>> mm/vmscan.c | 2 +-
>> 5 files changed, 39 insertions(+), 40 deletions(-)
>>
>> diff --git a/include/linux/swap.h b/include/linux/swap.h
>> index 636d94108166..c36f72877e8b 100644
>> --- a/include/linux/swap.h
>> +++ b/include/linux/swap.h
>> @@ -345,7 +345,7 @@ extern void lru_add_drain_cpu_zone(struct zone *zone);
>> extern void lru_add_drain_all(void);
>> void folio_deactivate(struct folio *folio);
>> void folio_mark_lazyfree(struct folio *folio);
>> -extern void swap_setup(void);
>> +extern void swap_readahead_setup(void);
>
> Can we move this to mm/swap.h?

Yes, that makes sense. swap_readahead_setup() is only used inside
mm/, and mm/vmscan.c already includes mm/swap.h, so it does not need to
stay in include/linux/swap.h.

I will move the prototype to mm/swap.h in v3. While doing that, I will
also add a CONFIG_SWAP=n stub, because swap_state.o is only built when
CONFIG_SWAP is enabled, while kswapd_init() is built unconditionally.

Thanks,
Best regards,
Jianyue