Re: [RFC PATCH v5 3/4] mm/vmscan: avoid pointless large folio splits without swap

"David Hildenbrand (Arm)" <[email protected]>
Newsgroups gmane.linux.kernel.cgroups,gmane.linux.kernel.mm,gmane.linux.kernel
Message-ID <[email protected]>
On 7/30/26 14:23, Xueyuan Chen wrote:
> From: "Barry Song (Xiaomi)" <[email protected]>
> 
> When swap is disabled, exhausted, or unavailable due to memcg swap
> limits, splitting a large anonymous folio cannot make swapout progress.
> The fallback only destroys the large folio and inflates split statistics.
> 
> Use -E2BIG from folio_alloc_swap() as the explicit signal that splitting
> the folio might allow swapout of smaller pieces. For other allocation
> failures, keep the existing activation path and avoid the split.
> 
> This preserves the split fallback for fragmented or partially available
> swap, while avoiding it when there is no backing space for any part of the
> folio.
> 
> Reported-by: Nanzhe Zhao <[email protected]>

Do you have a link to the report?

I assume this is not Fixes-worthy.

> Signed-off-by: Barry Song (Xiaomi) <[email protected]>
> Signed-off-by: Xueyuan Chen <[email protected]>
> ---
>  mm/vmscan.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 26df81e773ff..457049e130df 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1263,6 +1263,8 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
>  		 */
>  		if (folio_test_anon(folio) && folio_test_swapbacked(folio) &&
>  				!folio_test_swapcache(folio)) {
> +			int ret;
> +
>  			if (!(sc->gfp_mask & __GFP_IO))
>  				goto keep_locked;
>  			if (folio_maybe_dma_pinned(folio))
> @@ -1281,11 +1283,14 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
>  				    split_folio_to_list(folio, folio_list))
>  					goto activate_locked;
>  			}
> -			if (folio_alloc_swap(folio)) {
> +			ret = folio_alloc_swap(folio);
> +			if (ret) {
>  				int __maybe_unused order = folio_order(folio);
>  
>  				if (!folio_test_large(folio))
>  					goto activate_locked_split;
> +				if (ret != -E2BIG)
> +					goto activate_locked;
>  				/* Fallback to swap normal pages */
>  				if (split_folio_to_list(folio, folio_list))
>  					goto activate_locked;

Acked-by: David Hildenbrand (Arm) <[email protected]>

-- 
Cheers,

David
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.