Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1277754

Re: [PATCH?] race between cgroup_subsys->fork() and cgroup_migrate()

From Tejun Heo <tj@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH?] race between cgroup_subsys->fork() and cgroup_migrate()
Date 2015-11-25 21:00 +0100
Message-ID <qyOoq-2en-11@gated-at.bofh.it> (permalink)
References <qyLgR-jU-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hello, Oleg.

On Wed, Nov 25, 2015 at 05:34:27PM +0100, Oleg Nesterov wrote:
> IOW. Suppose that the new child is moved right before cgroup_post_fork() does
> 
> 	for_each_subsys_which(...)
> 		ss->fork(child);
> 
> doesn't this mean that after ss->fork() we do the same sequence
> 
> 		pids_uncharge(old_pids, 1);
> 		pids_charge(pids, 1);

You're absolutely right.

> twice? Note that threadgroup_change_begin/end depends on CLONE_THREAD.
> So we can actually hit WARN_ON() in pids_cancel().
> 
> However, we can't simply remove this uncharge/charge afaics. We need this in
> case when the parent was moved to another cgroup before cgroup_post_fork(),
> and then css_set_move_task() moves the child.
> 
> I know almost nothing about cgroups, perhaps I missed something, please
> correct me.

I can't think of anything better than what you're proposing.  Thanks a
lot for tracking it down and fixing it.

> If am right. How about the patch below? percpu_down_read() is cheap. And
> we can simplify cgroup_pids after this change.
> 
> And. We can probably unify cgroup_threadgroup_rwsem and dup_mmap_sem.
> Note that if we take cgroup_threadgroup_rwsem for reading if CLONE_THREAD,
> otherwise we take another percpu-rwsem in dup_mmap(), dup_mmap_sem.

Sounds perfect.  As this needs to go through -stable, can you please
resend the patch with proper description and SOB?  Please also update
the now incorrect comment in can_attach.

Thanks a lot!

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH?] race between cgroup_subsys->fork() and cgroup_migrate() Oleg Nesterov <oleg@redhat.com> - 2015-11-25 17:40 +0100
  Re: [PATCH?] race between cgroup_subsys->fork() and cgroup_migrate() Tejun Heo <tj@kernel.org> - 2015-11-25 21:00 +0100
    Re: [PATCH?] race between cgroup_subsys->fork() and cgroup_migrate() Tejun Heo <tj@kernel.org> - 2015-11-25 21:00 +0100
      Re: [PATCH?] race between cgroup_subsys->fork() and cgroup_migrate() Tejun Heo <tj@kernel.org> - 2015-11-25 21:50 +0100
        Re: [PATCH?] race between cgroup_subsys->fork() and  cgroup_migrate() Oleg Nesterov <oleg@redhat.com> - 2015-11-26 17:10 +0100
      Re: [PATCH?] race between cgroup_subsys->fork() and  cgroup_migrate() Oleg Nesterov <oleg@redhat.com> - 2015-11-26 16:40 +0100
        Re: [PATCH?] race between cgroup_subsys->fork() and cgroup_migrate() Aleksa Sarai <cyphar@cyphar.com> - 2015-11-27 00:40 +0100

csiph-web