Linux-Block Archive on lore.kernel.org
 help / color / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: yangerkun <yangerkun@huawei.com>, Jackie Liu <liuyun01@kylinos.cn>
Cc: linux-block@vger.kernel.org
Subject: Re: [PATCH 1/2] io_uring: make the logic clearer for io_sequence_defer
Date: Thu, 10 Oct 2019 20:35:15 -0600
Message-ID: <597dc8a4-b9db-f0b7-21b5-12050f07e766@kernel.dk> (raw)
In-Reply-To: <7af32ce6-dc8f-6683-2b99-95eefb598bff@huawei.com>

On 10/10/19 8:24 PM, yangerkun wrote:
> 
> 
> On 2019/10/9 9:19, Jackie Liu wrote:
>> __io_get_deferred_req is used to get all defer lists, including defer_list
>> and timeout_list, but io_sequence_defer should be only cares about the sequence.
>>
>> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
>> ---
>>    fs/io_uring.c | 13 +++++--------
>>    1 file changed, 5 insertions(+), 8 deletions(-)
>>
>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>> index 8a0381f1a43b..8ec2443eb019 100644
>> --- a/fs/io_uring.c
>> +++ b/fs/io_uring.c
>> @@ -418,9 +418,7 @@ static struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p)
>>    static inline bool io_sequence_defer(struct io_ring_ctx *ctx,
>>    				     struct io_kiocb *req)
>>    {
>> -	/* timeout requests always honor sequence */
>> -	if (!(req->flags & REQ_F_TIMEOUT) &&
>> -	    (req->flags & (REQ_F_IO_DRAIN|REQ_F_IO_DRAINED)) != REQ_F_IO_DRAIN)
>> +	if ((req->flags & (REQ_F_IO_DRAIN|REQ_F_IO_DRAINED)) != REQ_F_IO_DRAIN)
>>    		return false;
>>    
>>    	return req->sequence != ctx->cached_cq_tail + ctx->rings->sq_dropped;
>> @@ -435,12 +433,11 @@ static struct io_kiocb *__io_get_deferred_req(struct io_ring_ctx *ctx,
>>    		return NULL;
>>    
>>    	req = list_first_entry(list, struct io_kiocb, list);
>> -	if (!io_sequence_defer(ctx, req)) {
>> -		list_del_init(&req->list);
>> -		return req;
>> -	}
>> +	if (!(req->flags & REQ_F_TIMEOUT) && io_sequence_defer(ctx, req))
>> +		return NULL;
> Hi,
> 
> For timeout req, we should also compare the sequence to determine to
> return NULL or the req. But now we will return req directly. Actually,
> no need to compare req->flags with REQ_F_TIMEOUT.

Yes, not sure how I missed this, the patch is broken as-is. I will kill
it, cleanup can be done differently.

> Another problem, before this change, a timeout req can also drain the
> sqe(io_queue_sqe->io_req_defer and add to refer list), i am not sure is
> it a right or wrong logic, but your patch fix that.

We should factor the cq_timeouts into that.

-- 
Jens Axboe


  reply index

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-09  1:19 Jackie Liu
2019-10-09  1:19 ` [PATCH 2/2] io_uring: replace s->needs_lock with s->in_async Jackie Liu
2019-10-10 16:10   ` Jens Axboe
2019-10-10 16:10 ` [PATCH 1/2] io_uring: make the logic clearer for io_sequence_defer Jens Axboe
2019-10-11  2:24 ` yangerkun
2019-10-11  2:35   ` Jens Axboe [this message]
2019-10-11  3:06     ` Jackie Liu
2019-10-11  3:17       ` Jens Axboe
2019-10-11  3:26         ` Jens Axboe
2019-10-11  3:27         ` Jackie Liu
2019-10-11  3:34           ` Jens Axboe
2019-10-11  3:41             ` Jackie Liu
2019-10-11  3:42               ` Jens Axboe
2019-10-11  3:43                 ` Jackie Liu
2019-10-11  3:47                   ` Jens Axboe

Reply instructions:

You may reply publically 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=597dc8a4-b9db-f0b7-21b5-12050f07e766@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=liuyun01@kylinos.cn \
    --cc=yangerkun@huawei.com \
    /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

Linux-Block Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-block/0 linux-block/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-block linux-block/ https://lore.kernel.org/linux-block \
		linux-block@vger.kernel.org linux-block@archiver.kernel.org
	public-inbox-index linux-block

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-block


AGPL code for this site: git clone https://public-inbox.org/ public-inbox