Re: [RFC PATCH v7] sched: Fix performance regression introduced by mm_cid
From: Aaron Lu
Date: Mon Apr 17 2023 - 06:23:53 EST
On Sun, Apr 16, 2023 at 06:32:17PM -0400, Mathieu Desnoyers wrote:
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 0d18c3969f90..9532cf1a2a44 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2084,8 +2084,10 @@ static inline void dequeue_task(struct rq *rq, struct task_struct *p, int flags)
>
> void activate_task(struct rq *rq, struct task_struct *p, int flags)
> {
> - if (task_on_rq_migrating(p))
> + if (task_on_rq_migrating(p)) {
> flags |= ENQUEUE_MIGRATED;
> + sched_mm_cid_migrate_to(rq, p);
I noticed you did this in previous version too but forgot to ask:
is it your intention to only invoke sched_mm_cid_migrate_to() for queued
tasks, i.e. tasks that are being migrated due to load/idle balance etc,
but not those tasks that migrated on wakeup?
I saw you did the corresonding sched_mm_cid_migrate_from() in
set_task_cpu(), which on the other hand includes tasks that migrated due
to wakeup, so it kind of feel weird.
> + }
>
> enqueue_task(rq, p, flags);
>
> @@ -3195,6 +3197,7 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
> p->sched_class->migrate_task_rq(p, new_cpu);
> p->se.nr_migrations++;
> rseq_migrate(p);
> + sched_mm_cid_migrate_from(p);
> perf_event_task_migrate(p);
> }
Thanks,
Aaron