[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e28db863-3547-4a20-83da-26d8f7be2b03@linux.ibm.com>
Date: Sun, 13 Apr 2025 09:30:07 +0530
From: Madadi Vineeth Reddy <vineethr@...ux.ibm.com>
To: Fernand Sieber <sieberf@...zon.com>
Cc: Ingo Molnar <mingo@...hat.com>, Peter Zijlstra <peterz@...radead.org>,
Vincent Guittot <vincent.guittot@...aro.org>,
linux-kernel@...r.kernel.org, nh-open-source@...zon.com,
Madadi Vineeth Reddy <vineethr@...ux.ibm.com>
Subject: Re: [PATCH] sched/fair: Only increment deadline once on yield
Hi Fernand,
On 01/04/25 18:06, Fernand Sieber wrote:
> 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
>
> Signed-off-by: Fernand Sieber <sieberf@...zon.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 e43993a4e580..c1eff68d8ffc 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9024,7 +9024,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);
> }
Makes sense. Deadline would be rapidly incremented in the scenario of
having other tasks not eligible and the current task calls yield
repeatedly for a very short run time.
Reviewed-by: Madadi Vineeth Reddy <vineethr@...ux.ibm.com>
Thanks,
Madadi Vineeth Reddy
>
> static bool yield_to_task_fair(struct rq *rq, struct task_struct *p)
> --
> 2.47.1
>
>
>
>
> Amazon Development Centre (South Africa) (Proprietary) Limited
> 29 Gogosoa Street, Observatory, Cape Town, Western Cape, 7925, South Africa
> Registration Number: 2004 / 034463 / 07
>
Powered by blists - more mailing lists