Messages in this thread | | | From | Vincent Guittot <> | Date | Thu, 31 Mar 2022 14:15:38 +0200 | Subject | Re: [PATCH 2/2] sched/fair: Simple runqueue order on migrate |
| |
On Thu, 31 Mar 2022 at 13:47, Peter Zijlstra <peterz@infradead.org> wrote: > > > It's been 3 months since I wrote these patches, so memory is vague at > best :/ > > On Tue, Mar 29, 2022 at 11:03:44AM +0200, Vincent Guittot wrote: > > > > +static void place_entity_migrate(struct cfs_rq *cfs_rq, struct sched_entity *se) > > > +{ > > > + if (!sched_feat(PLACE_MIGRATE)) > > > + return; > > > + > > > + if (cfs_rq->nr_running < se->migrated) { > > > + /* > > > + * Migrated to a shorter runqueue, go first because > > > + * we were under-served on the old runqueue. > > > + */ > > > + se->vruntime = cfs_rq->min_vruntime; > > > + return; > > > + } > > > + > > > + /* > > > + * Migrated to a longer runqueue, go last because > > > + * we got over-served on the old runqueue. > > > + */ > > > + se->vruntime = cfs_rq->min_vruntime + sched_vslice(cfs_rq, se); > > > +} > > > + > > > static void check_enqueue_throttle(struct cfs_rq *cfs_rq); > > > > > > static inline bool cfs_bandwidth_used(void); > > > @@ -4296,6 +4317,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) > > > > > > if (flags & ENQUEUE_WAKEUP) > > > place_entity(cfs_rq, se, 0); > > > + else if (se->migrated) > > > + place_entity_migrate(cfs_rq, se); > > > > > > check_schedstat_required(); > > > update_stats_enqueue_fair(cfs_rq, se, flags); > > > > @@ -6973,14 +6997,15 @@ static void migrate_task_rq_fair(struct task_struct *p, int new_cpu) > > > * wakee task is less decayed, but giving the wakee more load > > > * sounds not bad. > > > */ > > > - remove_entity_load_avg(&p->se); > > > + remove_entity_load_avg(se); > > > } > > > > > > /* Tell new CPU we are migrated */ > > > - p->se.avg.last_update_time = 0; > > > + se->avg.last_update_time = 0; > > > > > > /* We have migrated, no longer consider this task hot */ > > > - p->se.migrated = 1; > > > + for_each_sched_entity(se) > > > + se->migrated = READ_ONCE(cfs_rq_of(se)->nr_running) + !se->on_rq; > > > > Why do we need to loop on se ? Isn't p->se enough ? > > Yeah; I really don't recall why I did that. And looking at it now, it > doesn't really make much sense. I suppose it will trigger > place_entity_migrate() for the group entries, but on the old CPU.
Yes, that is the reason for my question. task is still connected to prev cfs so you trigger place_entity_migrate() on the sched_entity of previous hierarchy. Also this will only happen during enqueue if the se has not run in the meantime. So it 's probably to be a nop most of the time as the parent cfs is already enqueued when we migrate a runnable task and in the other case it will break sched_group vruntime and fairness
> >
| |