public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Caleb Sander Mateos <csander@purestorage.com>
To: Alok Tiwari <alok.a.tiwari@oracle.com>
Cc: axboe@kernel.dk, io-uring@vger.kernel.org
Subject: Re: [PATCH] io_uring: fix incorrect unlikely() usage in io_waitid_prep()
Date: Fri, 17 Oct 2025 08:22:22 -0700	[thread overview]
Message-ID: <CADUfDZruQ7baruoBhSMBt6HcP-E-KiM1MHV=L9hn6OxFgEaXcw@mail.gmail.com> (raw)
In-Reply-To: <20251017124117.1435973-1-alok.a.tiwari@oracle.com>

On Fri, Oct 17, 2025 at 5:41 AM Alok Tiwari <alok.a.tiwari@oracle.com> wrote:
>
> The negation operator incorrectly places outside the unlikely() macro:
>
>     if (!unlikely(iwa))
>
> This caused the compiler hint to be applied to the constant result
> of the negation rather than the pointer check itself.

Not sure what you mean by "constant". But yes, applying !unlikely(iwa)
inverts the hint, saying iwa is unlikely to be non-NULL and therefore
the if branch is likely. It certainly seems more likely that the whole
if condition was meant to me marked unlikely.

Best,
Caleb

>
> Fix it by moving the negation inside unlikely(), matching the usual
> kernel pattern:
>
>     if (unlikely(!iwa))
>
> Fixes: 2b4fc4cd43f2 ("io_uring/waitid: setup async data in the prep handler")
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
> ---
>  io_uring/waitid.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/io_uring/waitid.c b/io_uring/waitid.c
> index f25110fb1b12..53532ae6256c 100644
> --- a/io_uring/waitid.c
> +++ b/io_uring/waitid.c
> @@ -250,7 +250,7 @@ int io_waitid_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
>                 return -EINVAL;
>
>         iwa = io_uring_alloc_async_data(NULL, req);
> -       if (!unlikely(iwa))
> +       if (unlikely(!iwa))
>                 return -ENOMEM;
>         iwa->req = req;
>
> --
> 2.50.1
>
>

  reply	other threads:[~2025-10-17 15:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-17 12:41 [PATCH] io_uring: fix incorrect unlikely() usage in io_waitid_prep() Alok Tiwari
2025-10-17 15:22 ` Caleb Sander Mateos [this message]
2025-10-17 18:36   ` [External] : " ALOK TIWARI

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='CADUfDZruQ7baruoBhSMBt6HcP-E-KiM1MHV=L9hn6OxFgEaXcw@mail.gmail.com' \
    --to=csander@purestorage.com \
    --cc=alok.a.tiwari@oracle.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.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