[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKfTPtBbaw5Ny_qmdhwiQyErfpE+GehY3wTMUxNVtfBjnAVC5w@mail.gmail.com>
Date: Thu, 1 Oct 2020 09:17:43 +0200
From: Vincent Guittot <vincent.guittot@...aro.org>
To: Peter Oskolkov <posk@...gle.com>
Cc: Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
linux-kernel <linux-kernel@...r.kernel.org>,
Peter Oskolkov <posk@...k.io>
Subject: Re: [PATCH] sched/fair: tweak pick_next_entity
On Wed, 30 Sep 2020 at 19:35, Peter Oskolkov <posk@...gle.com> wrote:
>
> Currently, pick_next_entity(...) has the following structure
> (simplified):
>
> [...]
> if (last_buddy_ok())
> result = last_buddy;
> if (next_buddy_ok())
> result = next_buddy;
> [...]
>
> The intended behavior is to prefer next buddy over last buddy;
> the current code somewhat obfuscates this, and also wastes
> cycles checking the last buddy when eventually the next buddy is
> picked up.
>
> So this patch refactors two 'ifs' above into
>
> [...]
> if (next_buddy_ok())
> result = next_buddy;
> else if (last_buddy_ok())
> result = last_buddy;
> [...]
>
> Signed-off-by: Peter Oskolkov <posk@...gle.com>
Reviewed-by: Vincent Guittot <vincent.guitttot@...aro.org>
> ---
> kernel/sched/fair.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index fc3410b8b990..cec6cf9b2bb3 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -4465,17 +4465,17 @@ pick_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *curr)
> se = second;
> }
>
> - /*
> - * Prefer last buddy, try to return the CPU to a preempted task.
> - */
> - if (cfs_rq->last && wakeup_preempt_entity(cfs_rq->last, left) < 1)
> - se = cfs_rq->last;
> -
> - /*
> - * Someone really wants this to run. If it's not unfair, run it.
> - */
> - if (cfs_rq->next && wakeup_preempt_entity(cfs_rq->next, left) < 1)
> + if (cfs_rq->next && wakeup_preempt_entity(cfs_rq->next, left) < 1) {
> + /*
> + * Someone really wants this to run. If it's not unfair, run it.
> + */
> se = cfs_rq->next;
> + } else if (cfs_rq->last && wakeup_preempt_entity(cfs_rq->last, left) < 1) {
> + /*
> + * Prefer last buddy, try to return the CPU to a preempted task.
> + */
> + se = cfs_rq->last;
> + }
>
> clear_buddies(cfs_rq, se);
>
> --
> 2.28.0.709.gb0816b6eb0-goog
>
Powered by blists - more mailing lists