[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <be0bdf5a-479c-51bb-6d51-42739c11710d@huawei.com>
Date: Wed, 8 Sep 2021 19:32:06 +0800
From: Zhang Qiao <zhangqiao22@...wei.com>
To: Tejun Heo <tj@...nel.org>
CC: <linux-kernel@...r.kernel.org>, <juri.lelli@...hat.com>,
<mingo@...hat.com>, <peterz@...radead.org>,
<vincent.guittot@...aro.org>
Subject: Re: [PATCH] kernel/sched: Fix sched_fork() access an invalid
sched_task_group
On 2021/9/8 1:01, Tejun Heo wrote:
> Hello,
>
> On Thu, Sep 02, 2021 at 03:42:15PM +0800, Zhang Qiao wrote:
>> I checked the code again.
>> I don't quite understand what you said, if the child be moved between
>> cgroup_post_fork() and sched_post_sched(), what problems might it cause?
>
> cgroup_post_fork() is where the child's creation is committed from cgroup's
> POV, so it'd be migrating cgroups before the initial creation is finished.
>>>From glancing, looks like it'll break css_set task counts to begin with.
> This violates the basic assumptions and can cause critical failures in
> subtle ways. The would replace one subtle race with a possibly worse one.
Hello,
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?
thanks.
Zhang Qiao
>
> Thanks.
>
Powered by blists - more mailing lists