Re: [PATCH 2/2] kthread, cgroup: close race window where new kthreads can be migrated to non-root cgroups

From: Tejun Heo
Date: Thu Mar 16 2017 - 13:42:26 EST


Hello,

On Thu, Mar 16, 2017 at 05:31:59PM +0100, Oleg Nesterov wrote:
> Or we can add another "unsigned no_cgroups:1" bit into task_struct,
> not sure.

To synchronize around initialization, a PF flag would be easier as we
can use wait_on_bit().

> Anyway, I do not understand the PF_NO_SETAFFINITY check in
> __cgroup_procs_write(). task_can_attach() checks it too, so cgroups
> can't change the affinity. Imo something explicit like no_cgroups
> makes more sense.

task_can_attach() predates the __cgroup_procs_write() and currently
doesn't do anything. We can split the flag or rename it so that it's
more generic. The reasons for disallowing cgroup migration have a lot
of crosssection with affinity, so it's not a complete misnomer.
Either way is fine by me.

Thanks.

--
tejun