[PATCH v6 08/14] mm, swap: require zswap for xswap devices
From: Baoquan He
Date: Sun Nov 22 2026 - 07:40:52 EST
From: Baoquan He <hebaoquan@xxxxxxxxxx>
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.
Acked-by: Chris Li <chrisl@xxxxxxxxxx>
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 1f319e365b68..ba899e349e99 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);
--
2.54.0