]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commit
zsmalloc: return -EBUSY for zspage migration lock contention
authorteawater <zhuhui@kylinos.cn>
Thu, 19 Mar 2026 06:59:24 +0000 (14:59 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 5 Apr 2026 20:53:33 +0000 (13:53 -0700)
commitdc711106a0bc76a30e0fbd16ed4d348171547d9a
tree76c6825e3f4b3d590148797c0dfd53567da3642c
parent6ebf98d71f9b509e833e0af00795ad3723d2f410
zsmalloc: return -EBUSY for zspage migration lock contention

movable_operations::migrate_page() should return an appropriate error code
for temporary migration failures so the migration core can handle them
correctly.

zs_page_migrate() currently returns -EINVAL when zspage_write_trylock()
fails.  That path reflects transient lock contention, not invalid input,
so -EINVAL is clearly wrong.

However, -EAGAIN is also inappropriate here: the zspage's reader-lock
owner may hold the lock for an unbounded duration due to slow
decompression or reader-lock owner preemption.  Since migration retries
are bounded by NR_MAX_MIGRATE_PAGES_RETRY and performed with virtually no
delay between attempts, there is no guarantee the lock will be released in
time for a retry to succeed.  -EAGAIN implies "try again soon", which does
not hold in this case.

Return -EBUSY instead, which more accurately conveys that the resource is
occupied and migration cannot proceed at this time.

Link: https://lkml.kernel.org/r/20260319065924.69337-1-hui.zhu@linux.dev
Signed-off-by: teawater <zhuhui@kylinos.cn>
Acked-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/zsmalloc.c