From: Aswin Kumar <aswinkumar3301@gmail.com>
To: linux-mm@kvack.org
Cc: andrew.morton@linux-foundation.org, linux-kernel@vger.kernel.org,
Aswin Kumar <aswinkumar3301@gmail.com>
Subject: [PATCH] mm/userfaultfd: fix likely/unlikely annotation in move_pages()
Date: Wed, 4 Feb 2026 14:23:50 +0000 [thread overview]
Message-ID: <20260204142350.1642-1-aswinkumar3301@gmail.com> (raw)
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@gmail.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
next reply other threads:[~2026-02-04 14:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-04 14:23 Aswin Kumar [this message]
2026-02-04 14:58 ` Matthew Wilcox
2026-02-12 12:47 ` David Hildenbrand (Arm)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260204142350.1642-1-aswinkumar3301@gmail.com \
--to=aswinkumar3301@gmail.com \
--cc=andrew.morton@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox