* [PATCH v2] io_uring: fix incorrect unlikely() usage in io_waitid_prep()
@ 2025-10-18 19:32 Alok Tiwari
2025-10-19 16:27 ` Caleb Sander Mateos
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Alok Tiwari @ 2025-10-18 19:32 UTC (permalink / raw)
To: csander, axboe, io-uring, alok.a.tiwari; +Cc: alok.a.tiwarilinux
The negation operator incorrectly places outside the unlikely() macro:
if (!unlikely(iwa))
This inverted the compiler branch prediction hint, marking the NULL
case as likely instead of unlikely. The intent is to indicate that
allocation failures are rare, consistent with common kernel patterns.
Moving the negation inside unlikely():
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>
---
v1 -> v2
Remove misleading "constant result" wording and
rephrase commit message
--
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
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v2] io_uring: fix incorrect unlikely() usage in io_waitid_prep()
2025-10-18 19:32 [PATCH v2] io_uring: fix incorrect unlikely() usage in io_waitid_prep() Alok Tiwari
@ 2025-10-19 16:27 ` Caleb Sander Mateos
2025-10-20 15:23 ` Jens Axboe
2025-10-20 15:00 ` Gabriel Krisman Bertazi
2025-10-20 15:22 ` Jens Axboe
2 siblings, 1 reply; 5+ messages in thread
From: Caleb Sander Mateos @ 2025-10-19 16:27 UTC (permalink / raw)
To: Alok Tiwari; +Cc: axboe, io-uring, alok.a.tiwarilinux
On Sat, Oct 18, 2025 at 12:33 PM Alok Tiwari <alok.a.tiwari@oracle.com> wrote:
>
> The negation operator incorrectly places outside the unlikely() macro:
"incorrectly places" -> "is incorrectly placed"?
>
> if (!unlikely(iwa))
>
> This inverted the compiler branch prediction hint, marking the NULL
> case as likely instead of unlikely. The intent is to indicate that
> allocation failures are rare, consistent with common kernel patterns.
>
> Moving the negation inside unlikely():
>
> 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>
Other than that,
Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
> ---
> v1 -> v2
> Remove misleading "constant result" wording and
> rephrase commit message
> --
> 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
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] io_uring: fix incorrect unlikely() usage in io_waitid_prep()
2025-10-19 16:27 ` Caleb Sander Mateos
@ 2025-10-20 15:23 ` Jens Axboe
0 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2025-10-20 15:23 UTC (permalink / raw)
To: Caleb Sander Mateos, Alok Tiwari; +Cc: io-uring, alok.a.tiwarilinux
On 10/19/25 10:27 AM, Caleb Sander Mateos wrote:
> On Sat, Oct 18, 2025 at 12:33 PM Alok Tiwari <alok.a.tiwari@oracle.com> wrote:
>>
>> The negation operator incorrectly places outside the unlikely() macro:
>
> "incorrectly places" -> "is incorrectly placed"?
Indeed, I did some slight commit message massaging while applying.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] io_uring: fix incorrect unlikely() usage in io_waitid_prep()
2025-10-18 19:32 [PATCH v2] io_uring: fix incorrect unlikely() usage in io_waitid_prep() Alok Tiwari
2025-10-19 16:27 ` Caleb Sander Mateos
@ 2025-10-20 15:00 ` Gabriel Krisman Bertazi
2025-10-20 15:22 ` Jens Axboe
2 siblings, 0 replies; 5+ messages in thread
From: Gabriel Krisman Bertazi @ 2025-10-20 15:00 UTC (permalink / raw)
To: Alok Tiwari; +Cc: csander, axboe, io-uring, alok.a.tiwarilinux
Alok Tiwari <alok.a.tiwari@oracle.com> writes:
> The negation operator incorrectly places outside the unlikely() macro:
>
> if (!unlikely(iwa))
>
> This inverted the compiler branch prediction hint, marking the NULL
> case as likely instead of unlikely. The intent is to indicate that
> allocation failures are rare, consistent with common kernel patterns.
>
> Moving the negation inside unlikely():
>
> 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>
Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de>
--
Gabriel Krisman Bertazi
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] io_uring: fix incorrect unlikely() usage in io_waitid_prep()
2025-10-18 19:32 [PATCH v2] io_uring: fix incorrect unlikely() usage in io_waitid_prep() Alok Tiwari
2025-10-19 16:27 ` Caleb Sander Mateos
2025-10-20 15:00 ` Gabriel Krisman Bertazi
@ 2025-10-20 15:22 ` Jens Axboe
2 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2025-10-20 15:22 UTC (permalink / raw)
To: csander, io-uring, Alok Tiwari; +Cc: alok.a.tiwarilinux
On Sat, 18 Oct 2025 12:32:54 -0700, Alok Tiwari wrote:
> The negation operator incorrectly places outside the unlikely() macro:
>
> if (!unlikely(iwa))
>
> This inverted the compiler branch prediction hint, marking the NULL
> case as likely instead of unlikely. The intent is to indicate that
> allocation failures are rare, consistent with common kernel patterns.
>
> [...]
Applied, thanks!
[1/1] io_uring: fix incorrect unlikely() usage in io_waitid_prep()
commit: 4ec703ec0c384a2199808c4eb2e9037236285a8d
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-20 15:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-18 19:32 [PATCH v2] io_uring: fix incorrect unlikely() usage in io_waitid_prep() Alok Tiwari
2025-10-19 16:27 ` Caleb Sander Mateos
2025-10-20 15:23 ` Jens Axboe
2025-10-20 15:00 ` Gabriel Krisman Bertazi
2025-10-20 15:22 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox