Re: [PATCH] blk-wbt: get back the missed wakeup from __wbt_done

From: jianchao.wang
Date: Thu Aug 23 2018 - 22:06:30 EST


Hi Jens

On 08/23/2018 11:42 PM, Jens Axboe wrote:
>> -
>> - __set_current_state(TASK_RUNNING);
>> - remove_wait_queue(&rqw->wait, &wait);
>> + wbt_init_wait(&wait, &data);
>> + prepare_to_wait_exclusive(&rqw->wait, &wait,
>> + TASK_UNINTERRUPTIBLE);
>> + if (lock) {
>> + spin_unlock_irq(lock);
>> + io_schedule();
>> + spin_lock_irq(lock);
>> + } else
>> + io_schedule();
> Aren't we still missing a get-token attempt after adding to the
> waitqueue? For the case where someone frees the token after your initial
> check, but before you add yourself to the waitqueue.

I used to think about this.
However, there is a very tricky scenario here:
We will try get the wbt budget in wbt_wake_function.
After add a task into the wait queue, wbt_wake_function has been able to
be invoked for this task. If we get the wbt budget after prepare_to_wait_exclusive,
we may get wbt budget twice.

Thanks
Jianchao