[PATCH] zsmalloc: return -EAGAIN for zspage migration lock contention
From: Hui Zhu
Date: Wed Mar 18 2026 - 03:33:25 EST
From: teawater <zhuhui@xxxxxxxxxx>
movable_operations::migrate_page() should return -EAGAIN for temporary
migration failures so the migration core can retry. Other negative
errors are treated as permanent failures.
zs_page_migrate() currently returns -EINVAL when zspage_write_trylock()
fails. That path reflects transient lock contention, not invalid input.
Returning -EINVAL misclassifies the failure and can reduce migration
success under contention.
Return -EAGAIN in this path.
Fixes: e27af3f9360e ("zsmalloc: sleepable zspage reader-lock")
Signed-off-by: teawater <zhuhui@xxxxxxxxxx>
---
mm/zsmalloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 2c1430bf8d57..1d26eda7f50c 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1727,7 +1727,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page,
if (!zspage_write_trylock(zspage)) {
spin_unlock(&class->lock);
write_unlock(&pool->lock);
- return -EINVAL;
+ return -EAGAIN;
}
/* We're committed, tell the world that this is a Zsmalloc page. */
--
2.43.0