Re: [PATCH v2 2/3] sched/fair: Skip detach and attach new group task

From: Vincent Guittot
Date: Tue May 31 2016 - 09:21:00 EST


On 31 May 2016 at 14:39, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> On Tue, May 31, 2016 at 02:33:45PM +0200, Vincent Guittot wrote:
>
>> The sched_avg of a task is not used anymore in copy_process with
>> yuyang's patchset. To be fully correct, we still have a
>> p->se.avg.last_update_time = 0 in cpu_cgroup_fork but this is just the
>> side effect of factoring cpu_group_fork and cpu_group_move in
>> sched_move_task and it will be overwritten by
>> init_entity_runnable_average before being used.
>
> Yeah, but why? Why does init_entity_runnable_average() live in
> wake_up_new_task()? That doesn't seem to make sense.

I don't really know.
I would say that it can make sense now that the init of sched_avg is
split it in 2 parts: post_init_entity_util_avg has to be done after
set_task_cpu in wake_up_new_task

>
> Also note that vruntime_normalized() (ab)uses !se->sum_exec_runtime to
> detect the new task state.
>
>> Now, cpu_cgroup_fork() only sets task group and cfs_rq of the forked task
>>
>> copy_process
>> sched_fork
>> ...
>> cgroup_post_fork
>> ss->fork() := cpu_cgroup_fork() which only set task group and
>> cfs_rq of the sched_entity of the task
>>
>> wake_up_new_task
>> init_entity_runnable_average
>> activate_task
>> enqueue_task
>> attach_task
>
>