[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKfTPtB02uJK6+e8UXiC=9RyRa3RA=LQ6Y3aqa7+PTX=BVPUcg@mail.gmail.com>
Date: Wed, 15 Jan 2025 10:28:07 +0100
From: Vincent Guittot <vincent.guittot@...aro.org>
To: Hao Jia <jiahao.kernel@...il.com>
Cc: mingo@...hat.com, peterz@...radead.org, mingo@...nel.org,
juri.lelli@...hat.com, dietmar.eggemann@....com, rostedt@...dmis.org,
bsegall@...gle.com, mgorman@...e.de, vschneid@...hat.com,
linux-kernel@...r.kernel.org, Hao Jia <jiahao1@...iang.com>
Subject: Re: [PATCH v2] sched/core: Prioritize migrating eligible tasks in sched_balance_rq()
On Wed, 15 Jan 2025 at 09:55, Hao Jia <jiahao.kernel@...il.com> wrote:
>
>
>
> On 2025/1/14 16:07, Vincent Guittot wrote:
> > On Tue, 14 Jan 2025 at 04:18, Hao Jia <jiahao.kernel@...il.com> wrote:
> >>
> >>
> >>
> >> On 2025/1/14 00:40, Vincent Guittot wrote:
> >>> On Mon, 13 Jan 2025 at 10:21, Hao Jia <jiahao.kernel@...il.com> wrote:
> >>>>
> >>>> Friendly ping...
> >>>>
> >>>>
> >>>> On 2024/12/23 17:14, Hao Jia wrote:
> >>>>> From: Hao Jia <jiahao1@...iang.com>
> >>>>>
> >>>>> When the PLACE_LAG scheduling feature is enabled and
> >>>>> dst_cfs_rq->nr_queued is greater than 1, if a task is
> >>>>> ineligible (lag < 0) on the source cpu runqueue, it will
> >>>>> also be ineligible when it is migrated to the destination
> >>>>> cpu runqueue. Because we will keep the original equivalent
> >>>>> lag of the task in place_entity(). So if the task was
> >>>>> ineligible before, it will still be ineligible after
> >>>>> migration.
> >>>>>
> >>>>> So in sched_balance_rq(), we prioritize migrating eligible
> >>>>> tasks, and we soft-limit ineligible tasks, allowing them
> >>>>> to migrate only when nr_balance_failed is non-zero to
> >>>>> avoid load-balancing trying very hard to balance the load.
> >>>
> >>> Could you explain why you think it's better to balance eligible tasks
> >>> in priority and potentially skip a load balance ?
> >>
> >> In place_entity(), we maintain the task's original equivalent lag, even
> >> if we migrate the task to dst_rq, this does not change its eligibility
> >> attribute.
> >
> > Yes, but you don't answer the question why it's better to select an
> > eligible task vs a non eligible task.
> >
> >>
> >> When there are multiple tasks on src_rq, and the dst_cpu has some
> >> runnable tasks, migrating ineligible tasks to dst_rq will not allow them
> >> to run. Therefore, such task migration is inefficient. We should
> >
> > Why is it inefficient ? load balance is about evenly balancing the
> > number of tasks or the load between CPUs, it never says that the newly
> > migrated task should run immediately
>
>
> My initial thought is that when we need to migrate some tasks during
> load balancing, at the current point in time, migrating ineligible tasks
> to dst_cpu means they definitely cannot run there. Therefore, I prefer
> to keep them on src_cpu to reduce the overhead of dequeueing and
> enqueueing ineligible tasks.
Sorry but I still don't get why it's important and would make a
difference. They are all runnable but ineligible tasks got more
runtime than other at that point in time so there is no real
difference
>
> Migrating eligible tasks to dst_cpu does not guarantee that they will
> run earlier than on src_cpu. it depends on too many factors.
>
>
>
> >
> >> prioritize migrating tasks that can run on dst_rq.
> >>
> >> In other words, migrating ineligible tasks is merely moving them to
> >> another runqueue to wait until they become eligible.
> >
> > But I don't get why it's a problem. Migrating an eligible task might
> > delay its scheduling because of its deadline vs other tasks already
> > eligible on the dst_rq. Eligible and non eligible tasks are all
> > runnable, it's just how much they have already run. In addition,
> > migrating an eligible task will clear its positive vlag with
> > DELAY_ZERO which is unfair IMO
>
>
> Sorry, I'd like to ask you a question that confuses me: Why does
> migrating eligible task will clear the positive vlag?
sorry I mess up everything that only for delayed dequeue task
>
> In detach_task(), the ENQUEUE_DELAYED and DEQUEUE_SLEEP flags are not
> set, and in dequeue_entity(), eligible tasks will not set sched_delayed,
> so they will be dequeued normally with se->on_rq being 0.
>
> Similarly, attach_task() does not set the ENQUEUE_DELAYED and
> DEQUEUE_SLEEP flags, and since se->on_rq is 0, it will not call
> requeue_delayed_entity().
>
>
> Thanks,
> Hao
>
> >
> >>
> >>
> >>>
> >>> I can see an interest for idle and newly_idle load balance in order to
> >>> favor fairness as tasks will become eligible but I don't see why it
> >>> would be helpful if dst already has some runnable tasks. Furthermore,
> >>> when a cpu is idle or newly idle, we really want to migrate a task
> >>> even an non eligible one instead of possibly skipping this load
> >>> balance round. With your patch, we might end up not pulling any task,
> >>> increasing the nr_balance_failed and waiting next load balance
> >>>
> >>
> >> If I understand correctly, when the destination CPU is idle, my patch
> >> does not change the original behavior. it only prevents the migration of
> >> ineligible tasks when dst_cfs_rq->nr_queued is greater than 1.
> >
> > It changes the behavior. My concern is that migrating an eligible task
> > when dst rq already has runnable tasks, doesn't assure you that it
> > will give any advantage to this eligible task.
> >
> > On an idle or newly idle cpu, any runnable tasks that will be pulled
> > will immediately start to run whatever it was eligible or not on src
> > cpu. In such a situation, we could consider that selecting an eligible
> > task which has less running time (positive lag) than others could be
> > more fair because the eligible task will immediately run. But this is
> > true as long as we migrate only 1 task. If you migrate several tasks,
> > an eligible task on src rq could even become ineligible quicker on dst
> > cpu than on src cpu has it lost its lag
> >
Powered by blists - more mailing lists