zswap_store() can refuse a page if the pool may be at its limit, or the page may not compress well enough. For an xswap device there was no way to store it, so swap_writeout() put the page back on the LRU. Under memory pressure that turns into a livelock: reclaim keeps picking the same page and the pool keeps refusing it. Now that xswap slots have a physical backend, write the page out instead. If no backend can be reserved, keep the old behaviour. Signed-off-by: Baoquan He --- mm/page_io.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index 32e426779dce..d521ea335df1 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -253,8 +253,18 @@ int swap_writeout(struct swap_io_ctx *ctx, struct folio *folio) * yet, so look the device up from the entry. */ if (unlikely(__swap_entry_to_info(folio->swap)->flags & SWP_XSWAP)) { - folio_mark_dirty(folio); - return AOP_WRITEPAGE_ACTIVATE; + swp_entry_t entry = folio->swap; + swp_entry_t phys; + + /* The pool refused it: fall back to a real swap device. */ + phys = xswap_backend_alloc(entry); + if (!phys.val) { + folio_mark_dirty(folio); + return AOP_WRITEPAGE_ACTIVATE; + } + + __swap_writeout(ctx, folio, phys); + return 0; } __swap_writeout(ctx, folio, folio->swap); -- 2.54.0