[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260204142350.1642-1-aswinkumar3301@gmail.com>
Date: Wed, 4 Feb 2026 14:23:50 +0000
From: Aswin Kumar <aswinkumar3301@...il.com>
To: linux-mm@...ck.org
Cc: andrew.morton@...ux-foundation.org,
linux-kernel@...r.kernel.org,
Aswin Kumar <aswinkumar3301@...il.com>
Subject: [PATCH] mm/userfaultfd: fix likely/unlikely annotation in move_pages()
All other userfaultfd paths use unlikely() for the mmap_changing check,
since normally mmap is not changing. The move_pages() path incorrectly
uses likely(), which is the opposite of the intended branch prediction
hint.
This is a performance-only fix - the logic is correct but the branch
prediction annotation is wrong, potentially causing a minor performance
penalty on the fast path.
Fixes: e0a58ef0faa7 ("userfaultfd: UFFDIO_MOVE uABI")
Signed-off-by: Aswin Kumar <aswinkumar3301@...il.com>
---
mm/userfaultfd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
index e6dfd5f28..d27080348 100644
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -1793,7 +1793,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.43.0
Powered by blists - more mailing lists