[PATCH OLK-6.6 V1] sched/fair: Only increment deadline once on yield

From: Fernand Sieber <sieberf@amazon.com> maillist inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ICITVN Reference: https://lore.kernel.org/all/20250401123622.584018-1-sieberf@amazon.com/ -------------------------------- If a task yields, the scheduler may decide to pick it again. The task in turn may decide to yield immediately or shortly after, leading to a tight loop of yields. If there's another runnable task as this point, the deadline will be increased by the slice at each loop. This can cause the deadline to runaway pretty quickly, and subsequent elevated run delays later on as the task doesn't get picked again. The reason the scheduler can pick the same task again and again despite its deadline increasing is because it may be the only eligible task at that point. Fix this by updating the deadline only to one slice ahead. Note, we might want to consider iterating on the implementation of yield as follow up: * the yielding task could be forfeiting its remaining slice by incrementing its vruntime correspondingly * in case of yield_to the yielding task could be donating its remaining slice to the target task Fixes: 147f3efaa241 ("sched/fair: Implement an EEVDF-like scheduling policy") Signed-off-by: Fernand Sieber <sieberf@amazon.com> Signed-off-by: Wang Tao <wangtao554@huawei.com> --- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index c4c3afa6e7b4..e61edd3472b4 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -10336,7 +10336,7 @@ static void yield_task_fair(struct rq *rq) */ rq_clock_skip_update(rq); - se->deadline += calc_delta_fair(se->slice, se); + se->deadline = se->vruntime + calc_delta_fair(se->slice, se); } static bool yield_to_task_fair(struct rq *rq, struct task_struct *p) -- 2.34.1

反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/17303 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/PHB... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/17303 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/PHB...
participants (2)
-
patchwork bot
-
Wang Tao