From: sashiko-bot@kernel.org
To: "Baoquan He" <baoquan.he@linux.dev>, linux-mm@kvack.org
Cc: akpm@linux-foundation.org, david@kernel.org, corbet@lwn.net,
chrisl@kernel.org, kasong@tencent.com, urezki@gmail.com,
hannes@cmpxchg.org, yosry@kernel.org, nphamcs@gmail.com,
baohua@kernel.org, youngjun.park@lge.com, kunwu.chan@gmail.com,
klarasmodin@gmail.com, "Baoquan He" <hebaoquan@kylinos.cn>
Subject: Re: [PATCH v8 08/14] mm, swap: require zswap for xswap devices
Date: Fri, 04 Dec 2026 16:48:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-250226@kernel.org> (raw)
In-Reply-To: <20261203164336.864691-9-baoquan.he@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mm: xswap_create() zswap check races and allows runtime zswap
disablement
--
commit 23d5b372a16f8090564baf7fd99d6589959b354c
Author: Baoquan He <hebaoquan@kylinos.cn>
mm, swap: require zswap for xswap devices
This commit checks zswap_is_enabled() in xswap_create() and returns
-EOPNOTSUPP when zswap is not enabled.
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 1f319e365b68e..ba899e349e992 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -4089,6 +4089,10 @@ static int xswap_create(int prio)
> unsigned int type;
> int error;
>
> + /* xswap has no backing store, it relies on zswap. */
> + if (!zswap_is_enabled())
> + return -EOPNOTSUPP;
> +
> mutex_lock(&xswap_ctl_lock);
>
> spin_lock(&swap_lock);
[Severity: Medium]
Can zswap still be disabled via /sys/module/zswap/parameters/enabled
either concurrently with xswap_create() or after the xswap device is
active?
zswap_is_enabled() performs a plain unlocked read of zswap_enabled and
shares no lock with zswap_enabled_param_set(), which updates
zswap_enabled under zswap_init_lock and does not check for active xswap
devices:
CPU0 CPU1
xswap_create()
zswap_is_enabled() -> true
zswap_enabled_param_set()
zswap_enabled = false
enable_swap_info(si) <-- active xswap with zswap disabled
Once zswap_enabled is false with an active xswap device,
folio_alloc_swap() keeps allocating xswap slots, zswap_store() rejects
them, and swap_writeout() returns AOP_WRITEPAGE_ACTIVATE, keeping dirty
folios in memory while consuming xswap slots and starving backing swap.
Also, because this check runs before xswap_ctl_lock and the existing
xswap device scan, a duplicate swapon of xswap after zswap is disabled
returns -EOPNOTSUPP instead of -EBUSY.
Should xswap creation and teardown synchronize with
zswap_enabled_param_set() to reject disabling zswap with -EBUSY while an
xswap device is active, or should swap allocation skip xswap devices when
zswap is disabled?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203164336.864691-1-baoquan.he@linux.dev?part=8
next prev parent reply other threads:[~2026-12-04 16:48 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 16:43 [PATCH v8 00/14] mm, swap: extendable swap devices (xswap phase I) Baoquan He
2026-12-03 16:43 ` [PATCH v8 01/14] mm/vmalloc: support vmalloc-backed VM_SPARSE areas Baoquan He
2026-12-04 16:48 ` sashiko-bot
2026-12-03 16:43 ` [PATCH v8 02/14] mm: xswap support for zswap Baoquan He
2026-12-04 16:48 ` sashiko-bot
2026-12-03 16:43 ` [PATCH v8 03/14] mm, swap: refactor free_swap_cluster_info to take swap_info_struct Baoquan He
2026-12-04 16:48 ` sashiko-bot
2026-12-03 16:43 ` [PATCH v8 04/14] mm, swap: use a VM_SPARSE cluster array for xswap devices Baoquan He
2026-12-04 16:48 ` sashiko-bot
2026-12-03 16:43 ` [PATCH v8 05/14] mm, swap: widen swap_info_struct max/pages to unsigned long Baoquan He
2026-12-03 16:43 ` [PATCH v8 06/14] mm, swap: create the xswap device from swapon(2) Baoquan He
2026-12-04 16:48 ` sashiko-bot
2026-12-03 16:43 ` [PATCH v8 07/14] mm, swap: refactor swapoff and add xswap_destroy Baoquan He
2026-12-04 16:48 ` sashiko-bot
2026-12-03 16:43 ` [PATCH v8 08/14] mm, swap: require zswap for xswap devices Baoquan He
2026-12-04 16:48 ` sashiko-bot [this message]
2026-12-03 16:43 ` [PATCH v8 09/14] mm, swap: let the command line set the xswap device size Baoquan He
2026-12-04 16:48 ` sashiko-bot
2026-12-03 16:43 ` [PATCH v8 10/14] mm, swap: add CONFIG_XSWAP_DEFAULT_MAX Baoquan He
2026-12-03 16:43 ` [PATCH v8 11/14] mm, swap: add xswap grow trigger on cluster allocation Baoquan He
2026-12-04 16:48 ` sashiko-bot
2026-12-03 16:43 ` [PATCH v8 12/14] mm, swap: add debugfs counters for xswap Baoquan He
2026-12-04 16:48 ` sashiko-bot
2026-12-03 16:43 ` [PATCH v8 13/14] mm, swap: do not give an xswap slot to a cgroup that cannot zswap Baoquan He
2026-12-04 16:48 ` sashiko-bot
2026-12-03 16:43 ` [PATCH v8 14/14] mm, swap: skip the overcommit probe when removing xswap Baoquan He
2026-12-04 16:48 ` sashiko-bot
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=sashiko-outbox-250226@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baoquan.he@linux.dev \
--cc=chrisl@kernel.org \
--cc=corbet@lwn.net \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=hebaoquan@kylinos.cn \
--cc=kasong@tencent.com \
--cc=klarasmodin@gmail.com \
--cc=kunwu.chan@gmail.com \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=urezki@gmail.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