[PATCH 2/2] mm/userfaultfd: fix wrong likely() hint on mmap_changing check in move_pages()
From: David Carlier
Date: Sat Mar 28 2026 - 13:02:44 EST
The mmap_changing check in move_pages() uses likely() but the condition
being true (concurrent mapping changes during UFFDIO_MOVE) is the
exceptional case, not the common one. All other mmap_changing checks in
the same file correctly use no branch hint or use unlikely().
Replace likely() with unlikely() to match the expected branch behavior.
Signed-off-by: David Carlier <devnexen@xxxxxxxxx>
---
mm/userfaultfd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
index 2a6e034b15aa..dc1b3dd1aece 100644
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -1872,7 +1872,7 @@ ssize_t move_pages(struct userfaultfd_ctx *ctx, unsigned long dst_start,
/* Re-check after taking map_changing_lock */
err = -EAGAIN;
down_read(&ctx->map_changing_lock);
- if (likely(atomic_read(&ctx->mmap_changing)))
+ if (unlikely(atomic_read(&ctx->mmap_changing)))
goto out_unlock;
/*
* Make sure the vma is not shared, that the src and dst remap
--
2.53.0