Hello Tejun, On Wed, Mar 11, 2015 at 2:17 AM, Tejun Heo <tj@xxxxxxxxxx> wrote: > On Wed, Mar 11, 2015 at 01:51:06AM +1100, Aleksa Sarai wrote: >> Actually, I'm fairly sure we can do it all inside cgroup_post_fork() because >> inside cgroup_post_fork() we have access to both the old css_set and the new >> one. Then it's just a matter of reverting and re-applying the charge to the >> hierarchies. > > But the problem isn't whether we know both the old and new ones. The > problem is that we can only abort before the fork commit point and the > "old" one may change between the abort point and post-commit point so > we need to trycharge the old one at the possible abort point, remember > to which css it got charged and then check whether the association has > changed inbetween at the post commit point and readjust if so. Actually, it appears I was wrong. Until we hit cgroup_post_fork()'s setting up of the task's css_set, cgroup_can_fork() ends up charging init_css_set *every time*. Which means a check to see if it changed will always show that it had changed. The issue is that we need to access the css_set which is going to be saved as the task's css_set in order to decide if the task should fork. We know that the task will have its css_set set to task_css_set(current), and we could just use that in cgroup_can_fork(). The only question is, can task_css_set(current) change between cgroup_can_fork() and cgroup_post_fork()? If it can change between the two calls, then we're in trouble -- there'd be no reliable way of checking that the future css_set allows for the fork without going through the registration of the css_set *proper* in cgroup_post_fork() unless we hold css_set_rwsem for the entirety of the can_fork() to post_fork() segment (which I can't imagine is a good idea). -- Aleksa Sarai (cyphar) www.cyphar.com -- To unsubscribe from this list: send the line "unsubscribe cgroups" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html