Re: [PATCH] kernel/sched: Fix sched_fork() access an invalid sched_task_group

From: Zhang Qiao
Date: Thu Sep 09 2021 - 05:45:22 EST




在 2021/9/9 0:29, Tejun Heo 写道:
> Hello,
>
> On Wed, Sep 08, 2021 at 07:32:06PM +0800, Zhang Qiao wrote:
>> I will update this patch by following the steps below:
>> 1)rename cgroup_subsys->fork() to cgroup_subsys->post_fork();
>> 2)add cgroup_subsys->fork() and the cpu_cgroup_fork() callback like this:
>>
>> void cpu_cgroup_fork(struct task_struct *task) {
>> ....
>> p->sched_task_group = task_group(current);
>> __set_task_cpu(p, smp_processor_id());
>> if (p->sched_class->task_fork)
>> p->sched_class->task_fork(p);
>> ....
>>
>>
>> 3)call cgroup_subsys->fork() after cgroup_can_fork().
>>
>> Do you have any suggestion?
>
> I'm not following why it needs to shuffle the callbacks. Can't you just
Just to provide a placeholder to call task_fork(). But thought about it,
there are indeed some problems with this modification.

Thanks.

Zhang Qiao

> relocate the fectching of task_group after can_fork?>
> Thanks.
>