Re: io_uring_prep_timeout_update on linked timeouts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <v@nametag.social> wrote:
>>>>>>
>>>>>> On Tue, Aug 24, 2021 at 11:43 PM Victor Stewart <v@nametag.social> 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.

-- 
Jens Axboe




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux