From: Jens Axboe <[email protected]>
To: Pavel Begunkov <[email protected]>, [email protected]
Subject: Re: [PATCH v3] io_uring: limit inflight IO
Date: Sat, 9 Nov 2019 13:59:15 -0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
On 11/9/19 12:16 PM, Pavel Begunkov wrote:
>> @@ -2992,6 +2992,30 @@ 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 ((ctx->flags & IORING_SETUP_CQ_NODROP) &&
>> + !list_empty(&ctx->cq_overflow_list))
>> + 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;
>
> ctx->sq_mask = sq_entries - 1, e.g. 0x0000...ffff.
> Thus the code above is modular arithmetic (% sq_entries) and
> equivalent to:
>
> if (to_submit != sq_entries)
> return false;
>
> I suggest, the intention was:
>
> if ((sq_head & ~mask) == ((sq_head + to_submit) & ~mask))
> return false;
Hah indeed, that was pretty silly. Fixed.
--
Jens Axboe
prev parent reply other threads:[~2019-11-09 21:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-09 15:21 [PATCH v3] io_uring: limit inflight IO Jens Axboe
2019-11-09 19:16 ` Pavel Begunkov
2019-11-09 20:59 ` 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