From: Baoquan He <baoquan.he@linux.dev>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, chrisl@kernel.org, kasong@tencent.com,
nphamcs@gmail.com, baohua@kernel.org, youngjun.park@lge.com,
hannes@cmpxchg.org, yosry@kernel.org, shikemeng@huaweicloud.com,
chengming.zhou@linux.dev, david@kernel.org,
linux-kernel@vger.kernel.org, Baoquan He <hebaoquan@kylinos.cn>,
kunwu.chan@gmail.com
Subject: Re: [PATCH v3 00/14] mm, swap: extendable swap devices (xswap)
Date: Thu, 17 Sep 2026 18:04:57 +0800 [thread overview]
Message-ID: <aqu7Sep9nHUS2DmR@fedora> (raw)
In-Reply-To: <20260916101929.149106-1-hebaoquan@kylinos.cn>
On 09/16/26 at 06:19pm, Baoquan He wrote:
For Sashiko complaints:
============================================================
Subject: Re: [PATCH v3 01/14] mm: xswap support for zswap
│ xswap entries are added to the zswap writeback LRU but
│ zswap_writeback_entry() rejects them with -EINVAL, so shrink_memcg_cb()
│ retries and zswap_reject_reclaim_fail keeps climbing.
Right. An xswap entry has no backing store, so it should not be a
writeback candidate. v4 no longer adds it to the zswap writeback LRU;
zswap_lru_del() tolerates that (__list_lru_del() checks list_empty()
first, and entry->lru is initialized before free). The shrinker then
neither scans nor counts these entries.
│ swap_vma_readahead() does not skip xswap, unlike swap_cluster_readahead().
Right, I only added the check to the cluster path. v4 adds the same
SWP_XSWAP check to swap_vma_readahead().
============================================================
Subject: Re: [PATCH v3 04/14] mm, swap: add xswap cluster grow via VM_SPARSE vmalloc
│ Returning -EBUSY from vm_area_map_pages() skips vm_area_unmap_pages(),
│ then the pages are freed while their PTEs are still populated.
This path is unreachable. vmap_pages_pte_range() does return -EBUSY, but
vmap_pages_pmd_range() and vmap_pages_pud_range() normalize the return to
-ENOMEM, so vm_area_map_pages() never returns -EBUSY. A collision takes
the -ENOMEM path, which calls vm_area_unmap_pages() before freeing the
pages, so no freed page is left mapped.
============================================================
Subject: Re: [PATCH v3 05/14] mm, swap: add sysfs create interface for xswap
│ maxpages smaller than SWAPFILE_CLUSTER skips the rounddown(), leaving
│ si->max unaligned.
That needs 2 * RAM < SWAPFILE_CLUSTER, i.e. RAM below about 1MB. Not
reachable in practice.
│ sysfs_create_group() failure leaks xswap_kobj.
Fixed in v4: kobject_put(xswap_kobj) and clear the pointer on that path.
│ pr_info() after enable_swap_info() races with swapoff reading si.
Fixed in v4: the message is printed while swapon_mutex is still held.
============================================================
Subject: Re: [PATCH v3 06/14] mm, swap: add xswap grow trigger on cluster allocation
│ free_clusters can be populated concurrently after the scans, so the grow
│ block is skipped and the allocation fails.
│ -EAGAIN from xswap_map_clusters() (another grower won) is not retried.
Fixed in v4: retry alloc_swap_scan_list(free_clusters) once after the grow
attempt, which covers both cases.
│ backing pages are leaked on swapoff.
That is fixed by the patch that follows ("mm, swap: free backing pages in
xswap_unmap_clusters"); patch 06 has no unmap path yet.
============================================================
Subject: Re: [PATCH v3 08/14] mm, swap: free backing pages in xswap_unmap_clusters
│ The teardown callers retry the unmap in an unbounded while loop.
│ kmalloc_array() under memalloc_noreclaim_save() is a high-order,
│ non-reclaimable allocation that can fail under fragmentation.
Both fixed in v4. The array is now allocated with kvmalloc_array() and
GFP_KERNEL. It can fall back to vmalloc and it can reclaim, and the
unmap always runs in process context, so this is fine. If it still
fails, we unmap in small batches using a stack array. So teardown
always makes progress, and no page is lost. The function cannot fail
now, so we removed the while() loops and the shrink rollback. The
counters are unsigned long now, and an overflow gives a warning.
============================================================
Subject: Re: [PATCH v3 10/14] mm, swap: refactor swapoff and add xswap_destroy
│ sysfs_create_group() failure leaks xswap_kobj.
Same as patch 05; fixed in v4 in xswap_sysfs_init().
│ sys_swapoff() mixes goto-based cleanup with scope-based cleanup.
This is pre-existing upstream style in sys_swapoff(): CLASS(filename,
pathname) and out_dput/filp_close(victim) are already there before this
series; the patch only moved them while extracting __swapoff(). Both
pathname and victim are released on every path. I left it unchanged to
avoid unrelated churn, and there is no standard CLASS for a struct file *
from file_open_name() anyway.
============================================================
Subject: Re: [PATCH v3 11/14] mm, swap: require zswap for xswap devices
│ The fix only checks zswap at create time; runtime disabling of zswap and
│ runtime zswap_store() failures are not handled.
Yes, this is a known issue. The create-time check cannot cover (a) zswap
being disabled after creation, or (b) zswap_store() failing at runtime
(pool full, allocation failure). In both cases swap_writeout() cannot
write the folio out, so it stays in the swap cache until it is faulted
back in.
So this is a temporary state. The writeback series on top adds the
fallback (write to disk when zswap refuses an xswap page), and then this
case becomes the normal swap IO error path that every swap device has.
============================================================
Subject: Re: [PATCH v3 13/14] mm, swap: add sysfs per-device size limit for xswap
│ del_from_avail_list()/add_to_avail_list() use try_cmpxchg() without a
│ retry loop.
That is the pre-existing pattern in these functions (they already used
atomic_long_try_cmpxchg() and skipped on failure before this series); this
patch does not change it.
│ DIV_ROUND_UP(val, SWAPFILE_CLUSTER) overflows for a huge val.
Fixed in v4: clamp against (unsigned long)nr_clusters_max * SWAPFILE_CLUSTER
before dividing.
│ a limit write that makes the device full leaves it on swap_avail_head.
Fixed in v4: after updating si->pages, call del_from_avail_list() when the
device is full, add_to_avail_list() otherwise.
============================================================
Subject: Re: [PATCH v3 14/14] mm, swap: shrink xswap to the ceiling when it drops
│ the hardcoded excess can include an in-use cluster, and the whole shrink
│ aborts.
The limit write clamps the new ceiling up to the clusters covering the
pages in use, so [ceiling, mapped) is free and the validation loop passes.
The only remaining window is an allocation racing the shrink, which just
defers the shrink to the next trigger.
============================================================
prev parent reply other threads:[~2026-09-17 10:05 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 10:19 Baoquan He
2026-09-16 10:19 ` [PATCH v3 01/14] mm: xswap support for zswap Baoquan He
2026-09-16 10:19 ` [PATCH v3 02/14] mm, swap: add CONFIG_XSWAP and xswap fields to swap_info_struct Baoquan He
2026-09-16 10:19 ` [PATCH v3 03/14] mm, swap: refactor free_swap_cluster_info to take swap_info_struct Baoquan He
2026-09-16 10:19 ` [PATCH v3 04/14] mm, swap: add xswap cluster grow via VM_SPARSE vmalloc Baoquan He
2026-09-16 10:19 ` [PATCH v3 05/14] mm, swap: add sysfs create interface for xswap Baoquan He
2026-09-16 10:19 ` [PATCH v3 06/14] mm, swap: add xswap grow trigger on cluster allocation Baoquan He
2026-09-16 10:19 ` [PATCH v3 07/14] mm, swap: add xswap_try_shrink and shrink trigger on cluster free Baoquan He
2026-09-16 10:19 ` [PATCH v3 08/14] mm, swap: free backing pages in xswap_unmap_clusters Baoquan He
2026-09-16 10:19 ` [PATCH v3 09/14] mm, swap: defer xswap shrink to workqueue to avoid lock recursion Baoquan He
2026-09-16 10:19 ` [PATCH v3 10/14] mm, swap: refactor swapoff and add xswap_destroy Baoquan He
2026-09-16 10:19 ` [PATCH v3 11/14] mm, swap: require zswap for xswap devices Baoquan He
2026-09-16 10:19 ` [PATCH v3 12/14] mm, swap: cap xswap growth at nr_clusters Baoquan He
2026-09-16 10:19 ` [PATCH v3 13/14] mm, swap: add sysfs per-device size limit for xswap Baoquan He
2026-09-16 10:19 ` [PATCH v3 14/14] mm, swap: shrink xswap to the ceiling when it drops Baoquan He
2026-09-16 16:45 ` [PATCH v3 00/14] mm, swap: extendable swap devices (xswap) Johannes Weiner
2026-09-17 7:31 ` Baoquan He
2026-09-17 10:04 ` Baoquan He [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=aqu7Sep9nHUS2DmR@fedora \
--to=baoquan.he@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=chengming.zhou@linux.dev \
--cc=chrisl@kernel.org \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=hebaoquan@kylinos.cn \
--cc=kasong@tencent.com \
--cc=kunwu.chan@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=shikemeng@huaweicloud.com \
--cc=yosry@kernel.org \
--cc=youngjun.park@lge.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®