[PATCH v3 11/14] mm, swap: require zswap for xswap devices
From: Baoquan He
Date: Wed Sep 16 2026 - 06:21:46 EST
xswap pages live only in zswap. Without zswap, swapout cannot free the page,
but still takes a swap entry. So the device consumes swap entries without
freeing memory. Fail to create a device when zswap is unavailable.
Signed-off-by: Baoquan He <hebaoquan@xxxxxxxxxx>
---
mm/swapfile.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index cdcbcbaa6d87..cac084bc72d6 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -4439,6 +4439,10 @@ static int xswap_create(int prio)
if (prio != DEF_SWAP_PRIO && (prio < 0 || prio > SWAP_FLAG_PRIO_MASK))
return -EINVAL;
+ /* xswap has no backing store, it relies on zswap. */
+ if (!zswap_is_enabled())
+ return -EOPNOTSUPP;
+
si = alloc_swap_info();
if (IS_ERR(si))
return PTR_ERR(si);
--
2.54.0