Re: [RFC PATCH v4 4/4] mm: swap: allow direct reclaim for synchronous multi-page swapin
From: Nanzhe Zhao
Date: Fri Nov 27 2026 - 03:29:17 EST
> [Severity: High]
> Can setting __GFP_RECLAIM without __GFP_NORETRY or __GFP_RETRY_MAYFAIL
> trigger premature OOM kills on order-2 swapin faults instead of falling
> back to order 0?
Agreed.
> [Severity: Medium]
> Should __swap_cache_alloc() unconditionally override the GFP mask for
> order 2 here?
>
> __swap_cache_alloc() is shared by all swap devices even when zram or
> CONFIG_ZRAM_MULTI_PAGES is not used, and when multi-page compression is
> enabled its order is configured via CONFIG_ZSMALLOC_MULTI_PAGES_ORDER
> (1..9) rather than hardcoded to 2. Or'ing __GFP_RECLAIM after
> thp_shmem_limit_gfp_mask(vma_thp_gfp_mask(vma), gfp) also overrides
> defrag=never/defer and caller GFP restrictions, and placing it only in the
> else branch leaves out the mpol path while causing shmem_fault() swapins
> to behave differently between CONFIG_NUMA=y (where
> shmem_get_pgoff_policy() returns a non-NULL policy) and CONFIG_NUMA=n
> (where it returns NULL).
This patch was an RFC-stage exploration specifically targeting synchronous
in-memory swap devices (zram) at order 2 (16 KiB mTHP, the primary
compression granularity), to evaluate whether allowing direct reclaim could
avoid the partial read caused by order-0 fallback.
I wanted to raise this point for discussion first in the RFC, and will explore
more generic approaches going forward.