Linux cgroups development
 help / color / mirror / Atom feed
From: Xueyuan Chen <xueyuan.chen21@gmail.com>
To: baolin.wang@linux.alibaba.com
Cc: xueyuan.chen21@gmail.com, akpm@linux-foundation.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	cgroups@vger.kernel.org, baohua@kernel.org,
	zhaonanzhe@xiaomi.com, hannes@cmpxchg.org, mhocko@kernel.org,
	roman.gushchin@linux.dev, shakeel.butt@linux.dev,
	muchun.song@linux.dev, chrisl@kernel.org, kasong@tencent.com,
	shikemeng@huaweicloud.com, nphamcs@gmail.com, bhe@redhat.com,
	youngjun.park@lge.com, david@kernel.org, ljs@kernel.org,
	liam@infradead.org, vbabka@kernel.org, rppt@kernel.org,
	surenb@google.com, qi.zheng@linux.dev, axelrasmussen@google.com,
	yuanchu@google.com, weixugc@google.com
Subject: Re: [RFC PATCH v2 3/3] mm/vmscan: avoid pointless large folio splits without swap
Date: Sun, 12 Jul 2026 10:03:03 +0800	[thread overview]
Message-ID: <20260712020303.326384-1-xueyuan.chen21@gmail.com> (raw)
In-Reply-To: <7ec7533f-e1dc-4236-99cc-6848d651976e@linux.alibaba.com>


On Fri, Jul 10, 2026 at 03:21:44PM +0800, Baolin Wang wrote:
>
>
>On 7/9/26 10:51 PM, Xueyuan Chen wrote:
>> From: "Barry Song (Xiaomi)" <baohua@kernel.org>
>> 
>> 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 <zhaonanzhe@xiaomi.com>
>> Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
>> ---
>>   mm/vmscan.c | 7 +++++--
>>   1 file changed, 5 insertions(+), 2 deletions(-)
>> 
>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>> index bd1b1aa12581..40340a88f78e 100644
>> --- a/mm/vmscan.c
>> +++ b/mm/vmscan.c
>> @@ -1260,6 +1260,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))
>> @@ -1278,10 +1280,11 @@ 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))
>> +				if (!folio_test_large(folio) || ret != -E2BIG)
>>   					goto activate_locked_split;
>
>Like I said in v1 [1], please apply the same change to shmem swap as well.
>
>[1] 
>https://lore.kernel.org/all/6e89f868-ca7a-484f-aeea-5d8d029714f2@linux.alibaba.com/
>

Hi Baolin,

Thanks for pointing this out, and sorry for missing your v1 comment.

I'll apply the same folio_alloc_swap() error handling to the shmem swap
path in the next version.

Thanks,
Xueyuan


      reply	other threads:[~2026-07-12  2:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 14:51 [RFC PATCH v2 0/3] mm: avoid large folio splits when swap is unavailable Xueyuan Chen
2026-07-09 14:51 ` [RFC PATCH v2 1/3] mm: add page_counter_margin() Xueyuan Chen
2026-07-09 14:51 ` [RFC PATCH v2 2/3] mm: distinguish large folio swap allocation failures Xueyuan Chen
2026-07-09 15:01   ` Johannes Weiner
2026-07-09 15:04     ` Johannes Weiner
2026-07-09 15:39       ` Xueyuan Chen
2026-07-09 14:51 ` [RFC PATCH v2 3/3] mm/vmscan: avoid pointless large folio splits without swap Xueyuan Chen
2026-07-10  7:21   ` Baolin Wang
2026-07-12  2:03     ` Xueyuan Chen [this message]

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=20260712020303.326384-1-xueyuan.chen21@gmail.com \
    --to=xueyuan.chen21@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=bhe@redhat.com \
    --cc=cgroups@vger.kernel.org \
    --cc=chrisl@kernel.org \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kasong@tencent.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=nphamcs@gmail.com \
    --cc=qi.zheng@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=rppt@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=shikemeng@huaweicloud.com \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=weixugc@google.com \
    --cc=youngjun.park@lge.com \
    --cc=yuanchu@google.com \
    --cc=zhaonanzhe@xiaomi.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox