• Tejun Heo's avatar
    cgroup_freezer: allow moving tasks in and out of a frozen cgroup · 8755ade6
    Tejun Heo authored
    cgroup_freezer is one of the few users of cgroup_subsys->can_attach()
    and uses it to prevent tasks from being migrated into or out of a
    frozen cgroup.  This makes cgroup_freezer cumbersome to use especially
    when co-mounted with other controllers.
    
    ->can_attach() is problematic in general as it can make co-mounting
    multiple cgroups difficult - migrating tasks may fail for reasons
    completely irrelevant for other controllers.  freezer_can_attach() in
    particular is more problematic because it messes with cgroup internal
    locking to ensure that the state verification performed at
    freezer_can_attach() stays valid until migration is complete.
    
    This patch replaces freezer_can_attach() with freezer_attach() so that
    tasks are always allowed to migrate - they are nudged into the
    conforming state from freezer_attach().  This means that there can be
    tasks which are being migrated which don't conform to the current
    cgroup_freezer state until freezer_attach() is complete.  Under the
    current locking scheme, the only such place is freezer_fork() which is
    updated to handle such window.
    
    While this patch doesn't remove the use of internal cgroup locking
    from freezer_read/write() paths, it removes the requirement to keep
    the freezer state constant while migrating and enables such change.
    
    Note that this creates a userland visible behavior change - FROZEN
    cgroup can no longer be used to lock migrations in and out of the
    cgroup.  This behavior change is intended.  I don't think the feature
    is necessary - userland should coordinate accesses to cgroup fs anyway
    - and even if the feature is needed cgroup_freezer is the completely
    wrong place to implement it.
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    LKML-Reference: <1350426526-14254-1-git-send-email-tj@kernel.org>
    Cc: Matt Helsley <matthltc@linux.vnet.ibm.com>
    Cc: Oleg Nesterov <oleg@redhat.com>
    Cc: Rafael J. Wysocki <rjw@sisk.pl>
    Cc: Li Zefan <lizefan@huawei.com>
    8755ade6
cgroup_freezer.c 9.38 KB