* [PATCH] io_uring: fix incorrect unlikely() usage in io_waitid_prep()
@ 2025-10-17 12:41 Alok Tiwari
2025-10-17 15:22 ` Caleb Sander Mateos
0 siblings, 1 reply; 3+ messages in thread
From: Alok Tiwari @ 2025-10-17 12:41 UTC (permalink / raw)
To: axboe, io-uring; +Cc: alok.a.tiwari
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.
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] io_uring: fix incorrect unlikely() usage in io_waitid_prep()
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
2025-10-17 18:36 ` [External] : " ALOK TIWARI
0 siblings, 1 reply; 3+ messages in thread
From: Caleb Sander Mateos @ 2025-10-17 15:22 UTC (permalink / raw)
To: Alok Tiwari; +Cc: axboe, io-uring
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
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [External] : Re: [PATCH] io_uring: fix incorrect unlikely() usage in io_waitid_prep()
2025-10-17 15:22 ` Caleb Sander Mateos
@ 2025-10-17 18:36 ` ALOK TIWARI
0 siblings, 0 replies; 3+ messages in thread
From: ALOK TIWARI @ 2025-10-17 18:36 UTC (permalink / raw)
To: Caleb Sander Mateos; +Cc: axboe, io-uring
On 10/17/2025 8:52 PM, Caleb Sander Mateos wrote:
> 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
>
Thanks Caleb.
you are right, "constant result" was a misleading choice of words.
I will update commit message and send a v2 patch.
>> 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 +-
Thanks,
Alok
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-17 18:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-10-17 18:36 ` [External] : " ALOK TIWARI
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox