So after a task eats up its time slice, it would be re-inserted into the red-black tree. If the task has slept for a long time previously , leading to a very small vruntime compared to other tasks in the runqueue, then it will be repetitively re-inserted as the left-most node in the red-black tree, right? Consequently it will always be picked up as the next task to run? I have checked the source code in core.c and fair.c, I didn't see any place where this task should yield to other tasks. Though in the funciton pick_next_entity(), I do see some tasks such cfs_rq->next,cfs_rq->last or etc.. which might have higher running priority,I do not think this is the correct place to prevent a task with very small vruntime from taking a processor for a too long time,right? Does anyone have a clue? Thanks,
I found the answer. When task is dequeue from the runqueue, this will be called: se->vruntime -= cfs_rq->min_vruntime When task is again enqueued to the runqueue, this will be called: se->vruntime += cfs_rq->min_vruntime So actually only the offset of the vruntime will be stored when the task is sleeping and the offset will be added again when it wakes up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With