From: Jens Axboe <axboe@kernel.dk>
To: Pavel Begunkov <asml.silence@gmail.com>,
io-uring@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] io_uring: move *queue_link_head() from common path
Date: Tue, 17 Dec 2019 09:45:08 -0700 [thread overview]
Message-ID: <76917820-052d-9597-133d-424fee3edade@kernel.dk> (raw)
In-Reply-To: <17f7900c-385f-0dfa-11bf-af99d080f894@gmail.com>
On 12/16/19 4:38 PM, Pavel Begunkov wrote:
> On 17/12/2019 02:22, Pavel Begunkov wrote:
>> Move io_queue_link_head() to links handling code in io_submit_sqe(),
>> so it wouldn't need extra checks and would have better data locality.
>>
>> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
>> ---
>> fs/io_uring.c | 32 ++++++++++++++------------------
>> 1 file changed, 14 insertions(+), 18 deletions(-)
>>
>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>> index bac9e711e38d..a880ed1409cb 100644
>> --- a/fs/io_uring.c
>> +++ b/fs/io_uring.c
>> @@ -3373,13 +3373,15 @@ static bool io_submit_sqe(struct io_kiocb *req, struct io_submit_state *state,
>> struct io_kiocb **link)
>> {
>> struct io_ring_ctx *ctx = req->ctx;
>> + unsigned int sqe_flags;
>> int ret;
>>
>> + sqe_flags = READ_ONCE(req->sqe->flags);
>> req->user_data = READ_ONCE(req->sqe->user_data);
>> trace_io_uring_submit_sqe(ctx, req->user_data, true, req->in_async);
>>
>> /* enforce forwards compatibility on users */
>> - if (unlikely(req->sqe->flags & ~SQE_VALID_FLAGS)) {
>> + if (unlikely(sqe_flags & ~SQE_VALID_FLAGS)) {
>> ret = -EINVAL;
>> goto err_req;
>> }
>> @@ -3402,10 +3404,10 @@ static bool io_submit_sqe(struct io_kiocb *req, struct io_submit_state *state,
>> if (*link) {
>> struct io_kiocb *head = *link;
>>
>> - if (req->sqe->flags & IOSQE_IO_DRAIN)
>> + if (sqe_flags & IOSQE_IO_DRAIN)
>> head->flags |= REQ_F_DRAIN_LINK | REQ_F_IO_DRAIN;
>>
>> - if (req->sqe->flags & IOSQE_IO_HARDLINK)
>> + if (sqe_flags & IOSQE_IO_HARDLINK)
>> req->flags |= REQ_F_HARDLINK;
>>
>> if (io_alloc_async_ctx(req)) {
>> @@ -3421,9 +3423,15 @@ static bool io_submit_sqe(struct io_kiocb *req, struct io_submit_state *state,
>> }
>> trace_io_uring_link(ctx, req, head);
>> list_add_tail(&req->link_list, &head->link_list);
>> - } else if (req->sqe->flags & (IOSQE_IO_LINK|IOSQE_IO_HARDLINK)) {
>> +
>> + /* last request of a link, enqueue the link */
>> + if (!(sqe_flags & IOSQE_IO_LINK)) {
>
> This looks suspicious (as well as in the current revision). Returning back
> to my questions a few days ago can sqe->flags have IOSQE_IO_HARDLINK, but not
> IOSQE_IO_LINK? I don't find any check.
>
> In other words, should it be as follows?
> !(sqe_flags & (IOSQE_IO_LINK|IOSQE_IO_HARDLINK))
Yeah, I think that should check for both. I'm fine with either approach
in general:
- IOSQE_IO_HARDLINK must have IOSQE_IO_LINK set
or
- IOSQE_IO_HARDLINK implies IOSQE_IO_LINK
Seems like the former is easier to verify in terms of functionality,
since we can rest easy if we check this early and -EINVAL if that isn't
the case.
What do you think?
--
Jens Axboe
next prev parent reply other threads:[~2019-12-17 16:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-16 23:22 [PATCH 0/3] io_uring: submission path cleanup Pavel Begunkov
2019-12-16 23:22 ` [PATCH 1/3] io_uring: rename prev to head Pavel Begunkov
2019-12-16 23:22 ` [PATCH 2/3] io_uring: move trace_submit_sqe into submit_sqe Pavel Begunkov
2019-12-16 23:22 ` [PATCH 3/3] io_uring: move *queue_link_head() from common path Pavel Begunkov
2019-12-16 23:38 ` Pavel Begunkov
2019-12-17 16:45 ` Jens Axboe [this message]
2019-12-17 17:37 ` Jens Axboe
2019-12-17 17:52 ` Pavel Begunkov
2019-12-17 18:01 ` Jens Axboe
2019-12-17 18:05 ` Pavel Begunkov
2019-12-17 18:07 ` Jens Axboe
2019-12-17 18:12 ` Pavel Begunkov
2019-12-17 18:15 ` Jens Axboe
2019-12-17 14:00 ` Dmitry Dolgov
2019-12-17 14:16 ` Pavel Begunkov
2019-12-17 18:15 ` [PATCH 0/3] io_uring: submission path cleanup Jens Axboe
2019-12-17 19:26 ` [PATCH v2 " Pavel Begunkov
2019-12-17 19:26 ` [PATCH 1/3] io_uring: rename prev to head Pavel Begunkov
2019-12-17 19:26 ` [PATCH 2/3] io_uring: move trace_submit_sqe into submit_sqe Pavel Begunkov
2019-12-17 19:26 ` [PATCH v2 3/3] io_uring: move *queue_link_head() from common path Pavel Begunkov
2019-12-17 21:15 ` [PATCH v2 0/3] io_uring: submission path cleanup 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=76917820-052d-9597-133d-424fee3edade@kernel.dk \
--to=axboe@kernel.dk \
--cc=asml.silence@gmail.com \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@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.