public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: Pavel Begunkov <[email protected]>, [email protected]
Subject: Re: [PATCH v4] io_uring: limit inflight IO
Date: Sun, 10 Nov 2019 08:22:17 -0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 11/10/19 6:36 AM, Pavel Begunkov wrote:
>> @@ -2997,6 +2997,31 @@ static bool io_get_sqring(struct io_ring_ctx *ctx, struct sqe_submit *s)
>>   	return false;
>>   }
>>   
>> +static bool io_sq_over_limit(struct io_ring_ctx *ctx, unsigned to_submit)
>> +{
>> +	unsigned inflight;
>> +
>> +	if (!list_empty(&ctx->cq_overflow_list)) {
>> +		io_cqring_overflow_flush(ctx, false);
>> +		return true;
>> +	}
>> +
>> +	/*
>> +	 * This doesn't need to be super precise, so only check every once
>> +	 * in a while.
>> +	 */
>> +	if ((ctx->cached_sq_head & ~ctx->sq_mask) !=
>> +	    ((ctx->cached_sq_head + to_submit) & ~ctx->sq_mask))
>> +		return false;
> 
> Still not quite agree, with "!=" it will check almost every time.
> We want to continue with the checks only when we overrun sq_entries
> (i.e. changed higher bits).
> 
> 
> There is a simplified trace: let
> 1) mask == 3, ~mask == 4
> 2) head == 0,
> 3) submitting by one
> 
> 1: (0 & 4) != (1 & 4): false // do checks
> 2: (1 & 4) != (2 & 4): false // do checks
> 3: (2 & 4) != (3 & 4): false // do checks
> 4: (3 & 4) != (4 & 4): true // skip, return true

Huh yes, it's reversed, isn't it. Should be:

	if ((ctx->cached_sq_head & ~ctx->sq_mask) ==
	    ((ctx->cached_sq_head + to_submit) & ~ctx->sq_mask))
		return false;

> The rest looks good,
> Reviewed-by: Pavel Begunkov <[email protected]>

Thanks, I'll make the above change too.

-- 
Jens Axboe


      reply	other threads:[~2019-11-10 15:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-09 21:01 [PATCH v4] io_uring: limit inflight IO Jens Axboe
2019-11-10 13:36 ` Pavel Begunkov
2019-11-10 15:22   ` Jens Axboe [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] \
    /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