From: Gabriel Krisman Bertazi <krisman@suse.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Pavel Begunkov <asml.silence@gmail.com>, io-uring@vger.kernel.org
Subject: Re: [PATCH 1/3] io_uring: simplify io_mem_alloc return values
Date: Wed, 13 Mar 2024 19:43:17 -0400 [thread overview]
Message-ID: <87a5n1k8a2.fsf@mailhost.krisman.be> (raw)
In-Reply-To: <4146d3a9-3f88-4ef5-8925-8782ae5aa90e@kernel.dk> (Jens Axboe's message of "Wed, 13 Mar 2024 17:24:40 -0600")
Jens Axboe <axboe@kernel.dk> writes:
> On 3/13/24 4:32 PM, Gabriel Krisman Bertazi wrote:
>> Pavel Begunkov <asml.silence@gmail.com> writes:
>>
>>> io_mem_alloc() returns a pointer on success and a pointer-encoded error
>>> otherwise. However, it can only fail with -ENOMEM, just return NULL on
>>> failure. PTR_ERR is usually pretty error prone.
>>>
>>> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
>>> ---
>>> io_uring/io_uring.c | 14 +++++---------
>>> io_uring/kbuf.c | 4 ++--
>>> 2 files changed, 7 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
>>> index e7d7a456b489..1d0eac0cc8aa 100644
>>> --- a/io_uring/io_uring.c
>>> +++ b/io_uring/io_uring.c
>>> @@ -2802,12 +2802,8 @@ static void io_rings_free(struct io_ring_ctx *ctx)
>>> void *io_mem_alloc(size_t size)
>>> {
>>> gfp_t gfp = GFP_KERNEL_ACCOUNT | __GFP_ZERO | __GFP_NOWARN | __GFP_COMP;
>>> - void *ret;
>>>
>>> - ret = (void *) __get_free_pages(gfp, get_order(size));
>>> - if (ret)
>>> - return ret;
>>> - return ERR_PTR(-ENOMEM);
>>> + return (void *) __get_free_pages(gfp, get_order(size));
>>> }
>>>
>>> static unsigned long rings_size(struct io_ring_ctx *ctx, unsigned int sq_entries,
>>> @@ -3762,8 +3758,8 @@ static __cold int io_allocate_scq_urings(struct io_ring_ctx *ctx,
>>> else
>>> rings = io_rings_map(ctx, p->cq_off.user_addr, size);
>>>
>>> - if (IS_ERR(rings))
>>> - return PTR_ERR(rings);
>>> + if (!rings)
>>> + return -ENOMEM;
>>>
>>
>> Sorry, I started reviewing this, got excited about the error path quick
>> fix, and didn't finish the review before it got it.
>>
>> I think this change is broken for the ctx->flags & IORING_SETUP_NO_MMAP
>> case, because io_rings_map returns ERR_PTR, and not NULL. In addition,
>> io_rings_map might fail for multiple reasons, and we want to propagate
>> the different error codes up here.
>
> Yeah, see my reply from some hours ago. I dropped it back then.
ah, thanks. I've configured lei to fetch the io_uring list every few
hours. This ended up fetching part of the thread at first, and I only saw
it dropped in the next fetch, after I sent the email. sorry for the noise.
--
Gabriel Krisman Bertazi
next prev parent reply other threads:[~2024-03-13 23:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-13 15:52 [PATCH 0/3] small rings clean up Pavel Begunkov
2024-03-13 15:52 ` [PATCH 1/3] io_uring: simplify io_mem_alloc return values Pavel Begunkov
2024-03-13 20:50 ` Jens Axboe
2024-03-13 20:43 ` Pavel Begunkov
2024-03-13 21:02 ` Jens Axboe
2024-03-13 22:32 ` Gabriel Krisman Bertazi
2024-03-13 23:24 ` Jens Axboe
2024-03-13 23:43 ` Gabriel Krisman Bertazi [this message]
2024-03-13 23:44 ` Jens Axboe
2024-03-13 15:52 ` [PATCH 2/3] io_uring: simplify io_pages_free Pavel Begunkov
2024-03-13 15:52 ` [PATCH 3/3] io_uring/kbuf: rename is_mapped Pavel Begunkov
2024-03-13 20:27 ` [PATCH 0/3] small rings clean up Jens Axboe
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=87a5n1k8a2.fsf@mailhost.krisman.be \
--to=krisman@suse.de \
--cc=asml.silence@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.