Re: [PATCH v2 1/2] cgroups: allow a cgroup subsystem to reject a fork

Tejun Heo
2015-03-09T03:06:36Z

On Fri, Feb 27, 2015 at 03:17:18PM +1100, Aleksa Sarai wrote:
...
> In order for can_fork to deal with a task that has an accurate css_set,
> move the css_set updating to cgroup_fork (where it belongs).

Hmmm? So, now the task is visible on cgroup side before the point of
no return? What happens if fork fails afterwards? Also, why is this
non-trivial change happening in tandem in this patch?

> @@ -946,6 +950,11 @@ struct cgroup_subsys_state *css_tryget_online_from_dir(struct dentry *dentry,
> static inline int cgroup_init_early(void) { return 0; }
> static inline int cgroup_init(void) { return 0; }
> static inline void cgroup_fork(struct task_struct *p) {}
> +static inline int cgroup_can_fork(struct task_struct *p)
> +{
> + return 0;
> +}

Please follow the surrounding style.

> @@ -4928,7 +4928,7 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss, bool early)
> * init_css_set is in the subsystem's root cgroup. */
> init_css_set.subsys[ss->id] = css;
>
> - need_forkexit_callback |= ss->fork || ss->exit;
> + need_forkexit_callback |= ss->can_fork || ss->cancel_fork || ss->fork || ss->exit;

Your patch isn't the culprit but this is silly given that this flag is
set pretty much whenever cgroups are enabled. Per-callback subsys
mask would make far more sense.

Thanks.

--
tejun