• T
    cgroup: split process / task migration into four steps · 1958d2d5
    Tejun Heo 提交于
    Currently, process / task migration is a single operation which may
    fail depending on memory pressure or the involved controllers'
    ->can_attach() callbacks.  One problem with this approach is migration
    of multiple targets.  It's impossible to tell whether a given target
    will be successfully migrated beforehand and cgroup core can't keep
    track of enough states to roll back after intermediate failure.
    
    This is already an issue with cgroup_transfer_tasks().  Also, we're
    gonna need multiple target migration for unified hierarchy.
    
    This patch splits migration into four stages -
    cgroup_migrate_add_src(), cgroup_migrate_prepare_dst(),
    cgroup_migrate() and cgroup_migrate_finish(), where
    cgroup_migrate_prepare_dst() performs all the operations which may
    fail due to allocation failure without actually migrating the target.
    
    The four separate stages mean that, disregarding ->can_attach()
    failures, the success or failure of multi target migration can be
    determined before performing any actual migration.  If preparations of
    all targets succeed, the whole thing will succeed.  If not, the whole
    operation can fail without any side-effect.
    
    Since the previous patch to use css_set->mg_tasks to keep track of
    migration targets, the only thing which may need memory allocation
    during migration is the target css_sets.  cgroup_migrate_prepare()
    pins all source and target css_sets and link them up.  Note that this
    can be performed without holding threadgroup_lock even if the target
    is a process.  As long as cgroup_mutex is held, no new css_set can be
    put into play.
    Signed-off-by: NTejun Heo <tj@kernel.org>
    Acked-by: NLi Zefan <lizefan@huawei.com>
    1958d2d5
cgroup.c 128.6 KB