linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Aswin Kumar <aswinkumar3301@gmail.com>
Cc: linux-mm@kvack.org, andrew.morton@linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/userfaultfd: fix likely/unlikely annotation in move_pages()
Date: Wed, 4 Feb 2026 14:58:34 +0000	[thread overview]
Message-ID: <aYNemlPABKnQkf-x@casper.infradead.org> (raw)
In-Reply-To: <20260204142350.1642-1-aswinkumar3301@gmail.com>

On Wed, Feb 04, 2026 at 02:23:50PM +0000, Aswin Kumar wrote:
> All other userfaultfd paths use unlikely() for the mmap_changing check,

No they don't?

$ git grep mmap_changing mm
mm/userfaultfd.c:               if (atomic_read(&ctx->mmap_changing))
mm/userfaultfd.c:       if (atomic_read(&ctx->mmap_changing))
mm/userfaultfd.c:       if (atomic_read(&ctx->mmap_changing))
mm/userfaultfd.c:       if (likely(atomic_read(&ctx->mmap_changing)))

> 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.

Can you measure it?  Bet you can't.

Honestly, I'd just remove the likely() annotation, not change it to
unlikely().


  reply	other threads:[~2026-02-04 14:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-04 14:23 Aswin Kumar
2026-02-04 14:58 ` Matthew Wilcox [this message]
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=aYNemlPABKnQkf-x@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=andrew.morton@linux-foundation.org \
    --cc=aswinkumar3301@gmail.com \
    --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