Re: [PATCH v2] sched: fair: Prevent negative lag increase during delayed dequeue

From: Peter Zijlstra

Date: Thu Apr 02 2026 - 09:53:14 EST


On Tue, Mar 31, 2026 at 06:23:52PM +0200, Vincent Guittot wrote:
> Delayed dequeue feature aims to reduce the negative lag of a dequeued task
> while sleeping but it can happens that newly enqueued tasks will move
> backward the avg vruntime and increase its negative lag.
> When the delayed dequeued task wakes up, it has more neg lag compared to
> being dequeued immediately or to other tasks that have been dequeued just
> before theses new enqueues.
>
> Ensure that the negative lag of a delayed dequeued task doesn't increase
> during its delayed dequeued phase while waiting for its neg lag to
> diseappear. Similarly, we remove any positive lag that the delayed
> dequeued task could have gain during thsi period.
>
> Short slice tasks are particularly impacted in overloaded system.
>
> Test on snapdragon rb5:
>
> hackbench -T -p -l 16000000 -g 2 1> /dev/null &
> cyclictest -t 1 -i 2777 -D 333 --policy=fair --mlock -h 20000 -q
>
> The scheduling latency of cyclictest is:
>
> tip/sched/core tip/sched/core +this patch
> cyclictest slice (ms) (default)2.8 8 8
> hackbench slice (ms) (default)2.8 20 20
> Total Samples | 115632 119733 119806
> Average (us) | 364 64(-82%) 61(- 5%)
> Median (P50) (us) | 60 56(- 7%) 56( 0%)
> 90th Percentile (us) | 1166 62(-95%) 62( 0%)
> 99th Percentile (us) | 4192 73(-98%) 72(- 1%)
> 99.9th Percentile (us) | 8528 2707(-68%) 1300(-52%)
> Maximum (us) | 17735 14273(-20%) 13525(- 5%)
>

Anyway, I can confirm this works quite well. The latency-slice numbers
are far more stable now.

Thanks for digging into that!