From: Pavel Begunkov <[email protected]>
To: Hao Xu <[email protected]>, Jens Axboe <[email protected]>
Cc: [email protected], Joseph Qi <[email protected]>
Subject: Re: [PATCH 2/3] io_uring: fix failed linkchain code logic
Date: Wed, 18 Aug 2021 15:40:44 +0100 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
On 8/18/21 1:22 PM, Hao Xu wrote:
> 在 2021/8/18 下午6:20, Pavel Begunkov 写道:
>> On 8/18/21 8:43 AM, Hao Xu wrote:
>>> Given a linkchain like this:
>>> req0(link_flag)-->req1(link_flag)-->...-->reqn(no link_flag)
>>>
[...]
>>> struct io_submit_link *link = &ctx->submit_state.link;
>>> + bool is_link = sqe->flags & (IOSQE_IO_LINK | IOSQE_IO_HARDLINK);
>>> + struct io_kiocb *head;
>>> int ret;
>>> + /*
>>> + * we don't update link->last until we've done io_req_prep()
>>> + * since linked timeout uses old link->last
>>> + */
>>> + if (link->head)
>>> + link->last->link = req;
>>> + else if (is_link)
>>> + link->head = req;
>>> + head = link->head;
>>
>> It's a horrorsome amount of overhead. How about to set the fail flag
>> if failed early and actually fail on io_queue_sqe(), as below. It's
>> not tested and a couple more bits added, but hopefully gives the idea.
> I get the idea, it's truely with less change. But why do you think the
> above code bring in more overhead, since anyway we have to link the req
> to the linkchain. I tested it with fio-direct-4k-read-with/without-sqpoll, didn't see performance regression.
Well, it's an exaggeration :) However, we were cutting the overhead,
and there is no atomics or other heavy operations left in the hot path,
just pure number of instructions a request should go through. That's
just to clear the reason why I don't want extras on the path.
For the non-linked path, first it adds 2 ifs in front and removes one
at the end. Then there is is_link, which is most likely to be saved
on stack. And same with @head which I'd expect to be saved on stack.
If we have a way to avoid it, that's great, and it looks we can.
[...]
>> - ret = io_req_prep(req, sqe);
>> - if (unlikely(ret))
>> - goto fail_req;
>> /* don't need @sqe from now on */
>> trace_io_uring_submit_sqe(ctx, req, req->opcode, req->user_data,
>> @@ -6670,8 +6670,10 @@ static int io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req,
>> struct io_kiocb *head = link->head;
>>
> maybe better to add an if(head & FAIL) here, since we don't need to
> prep_async if we know it will be cancelled.
Such an early fail is marginal enough to not care about performance,
but I agree that the check is needed as io_req_prep_async() won't be
able to handle it. E.g. if it failed to grab a file.
--
Pavel Begunkov
next prev parent reply other threads:[~2021-08-18 14:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-18 7:43 [PATCH for-5.15 0/3] fix failed linkchain code logic Hao Xu
2021-08-18 7:43 ` [PATCH 1/3] io_uring: remove redundant req_set_fail() Hao Xu
2021-08-18 7:43 ` [PATCH 2/3] io_uring: fix failed linkchain code logic Hao Xu
2021-08-18 10:20 ` Pavel Begunkov
2021-08-18 12:22 ` Hao Xu
2021-08-18 14:40 ` Pavel Begunkov [this message]
2021-08-19 10:30 ` Hao Xu
2021-08-18 7:43 ` [PATCH 3/3] io_uring: move fail path of request submittion to the end Hao Xu
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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