public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Pavel Begunkov <asml.silence@gmail.com>, io-uring@vger.kernel.org
Subject: Re: [PATCH 4/4] io_uring: reuse buffer updates for registration
Date: Fri, 4 Apr 2025 16:00:59 -0600	[thread overview]
Message-ID: <3783abbf-2585-48fb-b04b-9206ade7f22d@kernel.dk> (raw)
In-Reply-To: <609ff085-34a2-4b3d-a984-57ab2f9fcad6@gmail.com>

On 4/4/25 3:38 PM, Pavel Begunkov wrote:
> On 4/4/25 17:38, Jens Axboe wrote:
>> On 4/4/25 10:22 AM, Pavel Begunkov wrote:
>>> @@ -316,17 +318,26 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,
>>>               err = PTR_ERR(node);
>>>               break;
>>>           }
>>> -        i = array_index_nospec(up->offset + done, ctx->buf_table.nr);
>>> -        io_reset_rsrc_node(ctx, &ctx->buf_table, i);
>>> -        ctx->buf_table.nodes[i] = node;
>>> +        i = array_index_nospec(up->offset + done, buf_table->nr);
>>> +        io_reset_rsrc_node(ctx, buf_table, i);
>>> +        buf_table->nodes[i] = node;
>>>           if (ctx->compat)
>>>               user_data += sizeof(struct compat_iovec);
>>>           else
>>>               user_data += sizeof(struct iovec);
>>>       }
>>> +    if (last_error)
>>> +        *last_error = err;
>>>       return done ? done : err;
>>>   }
>>>   +static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,
>>> +                   struct io_uring_rsrc_update2 *up,
>>> +                   unsigned int nr_args)
>>> +{
>>> +    return io_buffer_table_update(ctx, &ctx->buf_table, up, nr_args, NULL);
>>> +}
>>
>> Minor style preference, but just do:
>>
>>     unsigned last_err;
>>     return io_buffer_table_update(ctx, &ctx->buf_table, up, nr_args, &last_err);
>>
>> and skip that last_error could be conditionally set?
> 
> I can't say I see how that's better though

I think so though, it makes the store unconditional and there's no risk
of anything forgetting that last_error is sometimes valid, sometimes
not. The last part is the most annoying to me, it's just more fragile
imho.

-- 
Jens Axboe

      reply	other threads:[~2025-04-04 22:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-04 16:22 [PATCH 0/4] buffer table registration cleanup Pavel Begunkov
2025-04-04 16:22 ` [PATCH 1/4] io_uring/rsrc: avoid assigning buf table on failure Pavel Begunkov
2025-04-04 16:22 ` [PATCH 2/4] io_uring: deduplicate node tagging Pavel Begunkov
2025-04-04 16:22 ` [PATCH 3/4] io_uring: early return for sparse buf table registration Pavel Begunkov
2025-04-04 16:22 ` [PATCH 4/4] io_uring: reuse buffer updates for registration Pavel Begunkov
2025-04-04 16:38   ` Jens Axboe
2025-04-04 21:38     ` Pavel Begunkov
2025-04-04 22:00       ` Jens Axboe [this message]

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=3783abbf-2585-48fb-b04b-9206ade7f22d@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=asml.silence@gmail.com \
    --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