Re: [PATCH V6 1/6] sched/fair: Add trivial fair server
From: Peter Zijlstra
Date: Wed Apr 10 2024 - 13:25:33 EST
On Fri, Apr 05, 2024 at 07:28:00PM +0200, Daniel Bristot de Oliveira wrote:
> From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
>
> Use deadline servers to service fair tasks.
>
> This patch adds a fair_server deadline entity which acts as a container
> for fair entities and can be used to fix starvation when higher priority
> (wrt fair) tasks are monopolizing CPU(s).
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> Signed-off-by: Daniel Bristot de Oliveira <bristot@xxxxxxxxxx>
> ---
> kernel/sched/core.c | 24 ++++++++++++++++--------
> kernel/sched/deadline.c | 23 +++++++++++++++++++++++
> kernel/sched/fair.c | 25 +++++++++++++++++++++++++
> kernel/sched/sched.h | 4 ++++
> 4 files changed, 68 insertions(+), 8 deletions(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 7019a40457a6..04e2270487b7 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -6007,6 +6007,14 @@ static void put_prev_task_balance(struct rq *rq, struct task_struct *prev,
> #endif
>
> put_prev_task(rq, prev);
> +
> + /*
> + * We've updated @prev and no longer need the server link, clear it.
> + * Must be done before ->pick_next_task() because that can (re)set
> + * ->dl_server.
> + */
> + if (prev->dl_server)
> + prev->dl_server = NULL;
> }
>
> /*
> @@ -6037,6 +6045,13 @@ __pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
> p = pick_next_task_idle(rq);
> }
>
> + /*
> + * This is a normal CFS pick, but the previous could be a DL pick.
> + * Clear it as previous is no longer picked.
> + */
> + if (prev->dl_server)
> + prev->dl_server = NULL;
> +
> /*
> * This is the fast path; it cannot be a DL server pick;
> * therefore even if @p == @prev, ->dl_server must be NULL.
> @@ -6050,14 +6065,6 @@ __pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
> restart:
> put_prev_task_balance(rq, prev, rf);
>
> - /*
> - * We've updated @prev and no longer need the server link, clear it.
> - * Must be done before ->pick_next_task() because that can (re)set
> - * ->dl_server.
> - */
> - if (prev->dl_server)
> - prev->dl_server = NULL;
> -
> for_each_class(class) {
> p = class->pick_next_task(rq);
> if (p)
This bit seems like a fix for 63ba8422f876 ("sched/deadline: Introduce
deadline servers"), should it be a separate patch?