xswap has no backing storage: swapped-out pages live only in zswap. Without zswap, swapout always bounces back, so the device would consume swap entry space without ever freeing memory. Refuse to create a device when zswap is unavailable. Runtime disabling of zswap after creation is safe: existing entries stay loadable (zswap_load() gates on zswap_never_enabled(), not the runtime zswap_enabled flag) and new swapouts merely bounce back to memory without freeing it. Signed-off-by: Baoquan He --- mm/swapfile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/swapfile.c b/mm/swapfile.c index 0321b6b0da56..c2ca0a9ac625 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -4305,6 +4305,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