public inbox for [email protected]
 help / color / mirror / Atom feed
From: Hao Xu <[email protected]>
To: Pavel Begunkov <[email protected]>, Jens Axboe <[email protected]>
Cc: [email protected], Joseph Qi <[email protected]>
Subject: Re: [PATCH 1/2] io_uring: split logic of force_nonblock
Date: Mon, 18 Oct 2021 21:00:54 +0800	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

在 2021/10/18 下午8:27, Pavel Begunkov 写道:
> On 10/18/21 11:29, Hao Xu wrote:
>> Currently force_nonblock stands for three meanings:
>>   - nowait or not
>>   - in an io-worker or not(hold uring_lock or not)
>>
>> Let's split the logic to two flags, IO_URING_F_NONBLOCK and
>> IO_URING_F_UNLOCKED for convenience of the next patch.
>>
>> Signed-off-by: Hao Xu <[email protected]>
>> ---
>>   fs/io_uring.c | 50 ++++++++++++++++++++++++++++----------------------
>>   1 file changed, 28 insertions(+), 22 deletions(-)
>>
>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>> index b6da03c26122..727cad6c36fc 100644
>> --- a/fs/io_uring.c
>> +++ b/fs/io_uring.c
>> @@ -199,6 +199,7 @@ struct io_rings {
>>   enum io_uring_cmd_flags {
>>       IO_URING_F_COMPLETE_DEFER    = 1,
>> +    IO_URING_F_UNLOCKED        = 2,
>>       /* int's last bit, sign checks are usually faster than a bit 
>> test */
>>       IO_URING_F_NONBLOCK        = INT_MIN,
>>   };
>> @@ -2926,7 +2927,7 @@ static void kiocb_done(struct kiocb *kiocb, 
>> ssize_t ret,
>>               struct io_ring_ctx *ctx = req->ctx;
>>               req_set_fail(req);
>> -            if (!(issue_flags & IO_URING_F_NONBLOCK)) {
>> +            if (issue_flags & IO_URING_F_UNLOCKED) {
>>                   mutex_lock(&ctx->uring_lock);
>>                   __io_req_complete(req, issue_flags, ret, cflags);
>>                   mutex_unlock(&ctx->uring_lock);
>> @@ -3036,7 +3037,7 @@ static struct io_buffer *io_buffer_select(struct 
>> io_kiocb *req, size_t *len,
>>   {
>>       struct io_buffer *kbuf = req->kbuf;
>>       struct io_buffer *head;
>> -    bool needs_lock = !(issue_flags & IO_URING_F_NONBLOCK);
>> +    bool needs_lock = issue_flags & IO_URING_F_UNLOCKED;
>>       if (req->flags & REQ_F_BUFFER_SELECTED)
>>           return kbuf;
>> @@ -3341,7 +3342,7 @@ static inline int io_rw_prep_async(struct 
>> io_kiocb *req, int rw)
>>       int ret;
>>       /* submission path, ->uring_lock should already be taken */
>> -    ret = io_import_iovec(rw, req, &iov, &iorw->s, IO_URING_F_NONBLOCK);
>> +    ret = io_import_iovec(rw, req, &iov, &iorw->s, 0);
>>       if (unlikely(ret < 0))
>>           return ret;
>> @@ -3452,6 +3453,7 @@ static int io_read(struct io_kiocb *req, 
>> unsigned int issue_flags)
>>       struct iovec *iovec;
>>       struct kiocb *kiocb = &req->rw.kiocb;
>>       bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
>> +    bool in_worker = issue_flags & IO_URING_F_UNLOCKED;
> 
> io_read shouldn't have notion of worker or whatever. I'd say let's
> leave only force_nonblock here.
> 
> I assume 2/2 relies ot it, but if so you can make sure it ends up
> in sync (!force_nonblock) at some point if all other ways fail.
I re-read the code, found you're right, will send v3.

  reply	other threads:[~2021-10-18 13:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 11:29 [PATCH v2 0/2] async hybrid for pollable requests Hao Xu
2021-10-18 11:29 ` [PATCH 1/2] io_uring: split logic of force_nonblock Hao Xu
2021-10-18 12:13   ` Pavel Begunkov
2021-10-18 12:27   ` Pavel Begunkov
2021-10-18 13:00     ` Hao Xu [this message]
2021-10-18 11:29 ` [PATCH 2/2] io_uring: implement async hybrid mode for pollable requests Hao Xu
2021-10-18 11:34   ` Hao Xu
2021-10-18 12:10     ` Pavel Begunkov
2021-10-18 12:20       ` Hao Xu
2021-10-18 12:31 ` [PATCH v2 0/2] async hybrid " Pavel Begunkov
2021-10-18 12:35   ` Hao Xu
2021-10-18 13:17   ` 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 \
    --in-reply-to=230fed47-9552-36d7-447f-a1ac5a0a0481@linux.alibaba.com \
    [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