LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Zhang Qiao <zhangqiao22@huawei.com>
To: Tejun Heo <tj@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <juri.lelli@redhat.com>,
	<mingo@redhat.com>, <peterz@infradead.org>,
	<vincent.guittot@linaro.org>
Subject: Re: [PATCH] kernel/sched: Fix sched_fork() access an invalid sched_task_group
Date: Wed, 8 Sep 2021 19:32:06 +0800	[thread overview]
Message-ID: <be0bdf5a-479c-51bb-6d51-42739c11710d@huawei.com> (raw)
In-Reply-To: <YTea0kK9yL5+GoKt@slm.duckdns.org>



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.
> 

  reply	other threads:[~2021-09-08 11:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26 11:26 Zhang Qiao
2021-08-30 11:49 ` Zhang Qiao
2021-08-30 14:39 ` Peter Zijlstra
2021-08-30 17:32   ` Tejun Heo
2021-08-31  7:58     ` Zhang Qiao
2021-08-31 22:59       ` Tejun Heo
2021-09-01  7:43         ` Zhang Qiao
2021-09-01 16:45           ` Tejun Heo
2021-09-02  7:42             ` Zhang Qiao
2021-09-07 17:01               ` Tejun Heo
2021-09-08 11:32                 ` Zhang Qiao [this message]
2021-09-08 16:29                   ` Tejun Heo
2021-09-09  9:45                     ` Zhang Qiao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=be0bdf5a-479c-51bb-6d51-42739c11710d@huawei.com \
    --to=zhangqiao22@huawei.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --subject='Re: [PATCH] kernel/sched: Fix sched_fork() access an invalid sched_task_group' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).