From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Xueyuan Chen <xueyuan.chen21@gmail.com>,
akpm@linux-foundation.org, linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
zhaonanzhe@xiaomi.com, baohua@kernel.org, hannes@cmpxchg.org,
youngjun.park@lge.com, hughd@google.com, chrisl@kernel.org,
kasong@tencent.com, shikemeng@huaweicloud.com, nphamcs@gmail.com,
baoquan.he@linux.dev, mhocko@kernel.org,
roman.gushchin@linux.dev, shakeel.butt@linux.dev,
muchun.song@linux.dev, 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 v4 4/4] mm/shmem: split large folios only on -E2BIG
Date: Thu, 30 Jul 2026 10:52:59 +0800 [thread overview]
Message-ID: <f0bde6a0-d4be-48b3-abe2-28127a82a139@linux.alibaba.com> (raw)
In-Reply-To: <20260730021630.2235914-5-xueyuan.chen21@gmail.com>
On 7/30/26 10:16 AM, Xueyuan Chen wrote:
> shmem_writeout() currently splits a large folio on every
> folio_alloc_swap() failure. With the refined return-value contract, only
> -E2BIG indicates that splitting might allow smaller folios to be swapped
> out.
>
> Enter the split fallback only for -E2BIG. For -ENOSPC and -ENOMEM,
> redirty and reactivate the folio as before.
>
> Suggested-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> Signed-off-by: Xueyuan Chen <xueyuan.chen21@gmail.com>
> ---
LGTM. Thanks.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> mm/shmem.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 6641823bed16..6f959191ef70 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -1609,6 +1609,7 @@ int shmem_writeout(struct swap_io_ctx *ctx, struct folio *folio,
> struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
> pgoff_t index;
> int nr_pages;
> + int ret;
Nit: can be in one line:
int nr_pages, ret;
> bool split = false;
>
> if ((info->flags & SHMEM_F_LOCKED) || sbinfo->noswap)
> @@ -1689,7 +1690,8 @@ int shmem_writeout(struct swap_io_ctx *ctx, struct folio *folio,
> folio_mark_uptodate(folio);
> }
>
> - if (!folio_alloc_swap(folio)) {
> + ret = folio_alloc_swap(folio);
> + if (!ret) {
> bool first_swapped = shmem_recalc_inode(inode, 0, nr_pages);
> int error;
>
> @@ -1742,7 +1744,7 @@ int shmem_writeout(struct swap_io_ctx *ctx, struct folio *folio,
> swap_cache_del_folio(folio);
> goto redirty;
> }
> - if (nr_pages > 1)
> + if (nr_pages > 1 && ret == -E2BIG)
> goto try_split;
> redirty:
> folio_mark_dirty(folio);
prev parent reply other threads:[~2026-07-30 2:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 2:16 [RFC PATCH v4 0/4] mm: avoid large folio splits when swap is unavailable Xueyuan Chen
2026-07-30 2:16 ` [RFC PATCH v4 1/4] mm: add page_counter_margin() Xueyuan Chen
2026-07-30 2:16 ` [RFC PATCH v4 2/4] mm: distinguish large folio swap allocation failures Xueyuan Chen
2026-07-30 2:16 ` [RFC PATCH v4 3/4] mm/vmscan: avoid pointless large folio splits without swap Xueyuan Chen
2026-07-30 2:16 ` [RFC PATCH v4 4/4] mm/shmem: split large folios only on -E2BIG Xueyuan Chen
2026-07-30 2:52 ` Baolin Wang [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=f0bde6a0-d4be-48b3-abe2-28127a82a139@linux.alibaba.com \
--to=baolin.wang@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baoquan.he@linux.dev \
--cc=cgroups@vger.kernel.org \
--cc=chrisl@kernel.org \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--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=xueyuan.chen21@gmail.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
all inboxes | Powered by JetHome®