public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, Keith Busch <[email protected]>,
	[email protected]
Cc: Keith Busch <[email protected]>
Subject: Re: [PATCH] io_uring: save repeated issue_flags
Date: Wed, 6 Dec 2023 01:51:38 +0000	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 12/6/23 01:41, Jens Axboe wrote:
> On 12/5/23 6:26 PM, Pavel Begunkov wrote:
>> On 12/5/23 22:00, Jens Axboe wrote:
>>> On 12/5/23 2:55 PM, Keith Busch wrote:
>>>> From: Keith Busch <[email protected]>
>>>>
>>>> No need to rebuild the issue_flags on every IO: they're always the same.
>>>>
>>>> Suggested-by: Jens Axboe <[email protected]>
>>>> Signed-off-by: Keith Busch <[email protected]>
>>>> ---
>> [...]
>>>> diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c
>>>> index 8a38b9f75d841..dbc0bfbfd0f05 100644
>>>> --- a/io_uring/uring_cmd.c
>>>> +++ b/io_uring/uring_cmd.c
>>>> @@ -158,19 +158,13 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
>>>>        if (ret)
>>>>            return ret;
>>>>    -    if (ctx->flags & IORING_SETUP_SQE128)
>>>> -        issue_flags |= IO_URING_F_SQE128;
>>>> -    if (ctx->flags & IORING_SETUP_CQE32)
>>>> -        issue_flags |= IO_URING_F_CQE32;
>>>> -    if (ctx->compat)
>>>> -        issue_flags |= IO_URING_F_COMPAT;
>>>>        if (ctx->flags & IORING_SETUP_IOPOLL) {
>>>>            if (!file->f_op->uring_cmd_iopoll)
>>>>                return -EOPNOTSUPP;
>>>> -        issue_flags |= IO_URING_F_IOPOLL;
>>>>            req->iopoll_completed = 0;
>>>>        }
>>>>    +    issue_flags |= ctx->issue_flags;
>>>>        ret = file->f_op->uring_cmd(ioucmd, issue_flags);
>>>>        if (ret == -EAGAIN) {
>>>>            if (!req_has_async_data(req)) {
>>>
>>> I obviously like this idea, but it should be accompanied by getting rid
>>> of ->compat and ->syscall_iopoll in the ctx as well?
>>
>> This all piggy backing cmd specific bits onto core io_uring issue_flags
>> business is pretty nasty. Apart from that, it mixes constant io_uring
>> flags and "execution context" issue_flags. And we're dancing around it
>> not really addressing the problem.
>>
>> IMHO, cmds should be testing for IORING_SETUP flags directly via
>> helpers, not renaming them and abusing core io_uring flags. E.g. I had
>> a patch like below but didn't care enough to send:
>>
>>
>> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
>> index 909377068a87..1a82a0633f16 100644
>> --- a/drivers/block/ublk_drv.c
>> +++ b/drivers/block/ublk_drv.c
>> @@ -2874,7 +2874,7 @@ static int ublk_ctrl_uring_cmd(struct io_uring_cmd *cmd,
>>   
>>       ublk_ctrl_cmd_dump(cmd);
>>   
>> -    if (!(issue_flags & IO_URING_F_SQE128))
>> +    if (!(io_uring_cmd_get_ctx_flags(cmd) & IORING_SETUP_SQE128))
>>           goto out;
>>   
>>       ret = ublk_check_cmd_op(cmd_op);
>> diff --git a/include/linux/io_uring/cmd.h b/include/linux/io_uring/cmd.h
>> index d69b4038aa3e..8a18a705ff31 100644
>> --- a/include/linux/io_uring/cmd.h
>> +++ b/include/linux/io_uring/cmd.h
>> @@ -79,4 +79,11 @@ static inline struct task_struct *io_uring_cmd_get_task(struct io_uring_cmd *cmd
>>       return cmd_to_io_kiocb(cmd)->task;
>>   }
>>   
>> +static inline unsigned io_uring_cmd_get_ctx_flags(struct io_uring_cmd *cmd)
>> +{
>> +    struct io_ring_ctx *ctx = cmd_to_io_kiocb(cmd)->ctx;
>> +
>> +    return ctx->flags;
>> +}
>> +
>>   #endif /* _LINUX_IO_URING_CMD_H */
> 
> Yeah this is fine too, I just don't like our current scheme of having to
> mirror state in issue flags. Consolidating one way or another would be
> really nice.

Just hiding ->compat into the cache won't help it, most of the cmd
flags mirror IORING_SETUP_*, so unless it checks IORING_SETUP_* directly
there will be this duplication.

-- 
Pavel Begunkov

      reply	other threads:[~2023-12-06  1:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-05 21:55 [PATCH] io_uring: save repeated issue_flags Keith Busch
2023-12-05 22:00 ` Jens Axboe
2023-12-05 23:02   ` Keith Busch
2023-12-05 23:11     ` Jens Axboe
2023-12-06  1:31       ` Pavel Begunkov
2023-12-06  1:26   ` Pavel Begunkov
2023-12-06  1:41     ` Jens Axboe
2023-12-06  1:51       ` Pavel Begunkov [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 \
    [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