archive mirror
 help / color / mirror / Atom feed
From: Pavel Begunkov <>
To: Jens Axboe <>, Victor Stewart <>,
	io-uring <>
Subject: Re: io_uring_prep_timeout_update on linked timeouts
Date: Tue, 31 Aug 2021 17:07:32 +0100	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On 8/29/21 3:40 AM, Jens Axboe wrote:
> On 8/28/21 3:38 PM, Pavel Begunkov wrote:
>> On 8/28/21 2:43 PM, Jens Axboe wrote:
>>> On 8/28/21 7:39 AM, Pavel Begunkov wrote:
>>>> On 8/28/21 4:22 AM, Jens Axboe wrote:
>>>>> On 8/26/21 7:40 PM, Victor Stewart wrote:
>>>>>> On Wed, Aug 25, 2021 at 2:27 AM Victor Stewart <> wrote:
>>>>>>> On Tue, Aug 24, 2021 at 11:43 PM Victor Stewart <> wrote:
>>>>>>>> we're able to update timeouts with io_uring_prep_timeout_update
>>>>>>>> without having to cancel
>>>>>>>> and resubmit, has it ever been considered adding this ability to
>>>>>>>> linked timeouts?
>>>>>>> whoops turns out this does work. just tested it.
>>>>>> doesn't work actually. missed that because of a bit of misdirection.
>>>>>> returns -ENOENT.
>>>>>> the problem with the current way of cancelling then resubmitting
>>>>>> a new a timeout linked op (let's use poll here) is you have 3 situations:
>>>>>> 1) the poll triggers and you get some positive value. all good.
>>>>>> 2) the linked timeout triggers and cancels the poll, so the poll
>>>>>> operation returns -ECANCELED.
>>>>>> 3) you cancel the existing poll op, and submit a new one with
>>>>>> the updated linked timeout. now the original poll op returns
>>>>>> -ECANCELED.
>>>>>> so solely from looking at the return value of the poll op in 2) and 3)
>>>>>> there is no way to disambiguate them. of course the linked timeout
>>>>>> operation result will allow you to do so, but you'd have to persist state
>>>>>> across cqe processings. you can also track the cancellations and know
>>>>>> to skip the explicitly cancelled ops' cqes (which is what i chose).
>>>>>> there's also the problem of efficiency. you can imagine in a QUIC
>>>>>> server where you're constantly updating that poll timeout in response
>>>>>> to idle timeout and ACK scheduling, this extra work mounts.
>>>>>> so i think the ability to update linked timeouts via
>>>>>> io_uring_prep_timeout_update would be fantastic.
>>>>> Hmm, I'll need to dig a bit, but whether it's a linked timeout or not
>>>>> should not matter. It's a timeout, it's queued and updated the same way.
>>>>> And we even check this in some of the liburing tests.
>>>> We don't keep linked timeouts in ->timeout_list, so it's not
>>>> supported and has never been. Should be doable, but we need
>>>> to be careful synchronising with the link's head.
>>> Yeah shoot you are right, I guess that explains the ENOENT. Would be
>>> nice to add, though. Synchronization should not be that different from
>>> dealing with regular timeouts.
>> _Not tested_, but something like below should do. will get it
>> done properly later, but even better if we already have a test
>> case. Victor?
> FWIW, I wrote a simple test case for it, and it seemed to work fine.
> Nothing fancy, just a piped read that would never finish with a linked
> timeout (1s), submit, then submit a ltimeout update that changes it to
> 2s instead. Test runs and update completes first with res == 0 as
> expected, and 2s later the ltimeout completes with -EALREADY (because
> the piped read went async) and the piped read gets canceled.
> That seems to be as expected, and didn't trigger anything odd.

Perfect. Thanks, Jens

Pavel Begunkov

      parent reply	other threads:[~2021-08-31 16:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24 22:43 io_uring_prep_timeout_update on linked timeouts Victor Stewart
2021-08-25  1:27 ` Victor Stewart
2021-08-27  1:40   ` Victor Stewart
2021-08-28  3:22     ` Jens Axboe
2021-08-28 13:39       ` Pavel Begunkov
2021-08-28 13:43         ` Jens Axboe
2021-08-28 21:38           ` Pavel Begunkov
2021-08-29  2:40             ` Jens Axboe
2021-08-31 11:36               ` Victor Stewart
2021-08-31 16:09                 ` Pavel Begunkov
2021-08-31 16:07               ` 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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \

* 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;
as well as URLs for NNTP newsgroup(s).