Thread (14 messages) flat view 14 messages, 4 authors, 8d ago
COOLING8d

[PATCH v2 2/4] mm: zswap: reuse zswap_invalidate() in zswap_store() check_old path

From: Kefeng Wang <hidden>
Date: 2026-09-10 09:55:07
Subsystem: memory management, the rest, zswap compressed swap caching · Maintainers: Andrew Morton, Linus Torvalds, Johannes Weiner, Yosry Ahmed, Nhat Pham

The check_old path in zswap_store() open-codes the same per-slot
xarray lookup and entry free that zswap_invalidate() already does.
Reuse zswap_invalidate() whose xa_empty() check skips empty per-area
trees to avoid unnecessary xarray lookup and code duplication.

Signed-off-by: Kefeng Wang <redacted>
---
 mm/zswap.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/mm/zswap.c b/mm/zswap.c
index 420c405d0402..2c06e4e0e130 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -1549,15 +1549,9 @@ bool zswap_store(struct folio *folio)
 	if (!ret) {
 		unsigned type = swp_type(swp);
 		pgoff_t offset = swp_offset(swp);
-		struct zswap_entry *entry;
-		struct xarray *tree;
-
-		for (index = 0; index < nr_pages; ++index) {
-			tree = swap_zswap_tree(swp_entry(type, offset + index));
-			entry = xa_erase(tree, offset + index);
-			if (entry)
-				zswap_entry_free(entry);
-		}
+
+		for (index = 0; index < nr_pages; ++index)
+			zswap_invalidate(type, offset + index);
 	}
 
 	return ret;
-- 
2.55.0

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help