Messages in this thread | | | Date | Mon, 27 Oct 2014 09:47:35 -0400 | From | Tejun Heo <> | Subject | Re: [PATCH] sched: reset sched_entity depth on changing parent |
| |
Hello, Peter, Kirill.
On Mon, Oct 27, 2014 at 02:28:12PM +0100, Peter Zijlstra wrote: ... > So Kirill is saying that there is a race between fork and attach such > that a child can end up in a different cgroup than the parent and we > need to use the cgroup_subsys::fork call to fix that up. > > I was always under the impression that fork was an 'atomic' operation > from the point of cgroups, an attach (or move) would happen either > before the fork or after, not during. But I appear to be mistaken in > that assumption, going by the comments around cgroup_post_fork().
cgroup migration is atomic against threadgroup changes - tasks joining or leaving the threadgroup. If a process is forking a child, the child inherits the parent's cgroup at one point while forking and the parent may have changed its cgroup while fork was in progress. So, yeah, it can't depend on the dup'd result to be correct.
Thanks.
-- tejun
| |