1. 13 Dec, 2011 7 commits
    • Tejun Heo's avatar
      cgroup: don't use subsys->can_attach_task() or ->attach_task() · bb9d97b6
      Tejun Heo authored
      Now that subsys->can_attach() and attach() take @tset instead of
      @task, they can handle per-task operations.  Convert
      ->can_attach_task() and ->attach_task() users to use ->can_attach()
      and attach() instead.  Most converions are straight-forward.
      Noteworthy changes are,
      
      * In cgroup_freezer, remove unnecessary NULL assignments to unused
        methods.  It's useless and very prone to get out of sync, which
        already happened.
      
      * In cpuset, PF_THREAD_BOUND test is checked for each task.  This
        doesn't make any practical difference but is conceptually cleaner.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reviewed-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Reviewed-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Acked-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      Cc: Paul Menage <paul@paulmenage.org>
      Cc: Balbir Singh <bsingharora@gmail.com>
      Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
      Cc: James Morris <jmorris@namei.org>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Peter Zijlstra <peterz@infradead.org>
      bb9d97b6
    • Tejun Heo's avatar
      cgroup: introduce cgroup_taskset and use it in subsys->can_attach(), cancel_attach() and attach() · 2f7ee569
      Tejun Heo authored
      Currently, there's no way to pass multiple tasks to cgroup_subsys
      methods necessitating the need for separate per-process and per-task
      methods.  This patch introduces cgroup_taskset which can be used to
      pass multiple tasks and their associated cgroups to cgroup_subsys
      methods.
      
      Three methods - can_attach(), cancel_attach() and attach() - are
      converted to use cgroup_taskset.  This unifies passed parameters so
      that all methods have access to all information.  Conversions in this
      patchset are identical and don't introduce any behavior change.
      
      -v2: documentation updated as per Paul Menage's suggestion.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reviewed-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Reviewed-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Acked-by: default avatarPaul Menage <paul@paulmenage.org>
      Acked-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      Cc: Balbir Singh <bsingharora@gmail.com>
      Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
      Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: James Morris <jmorris@namei.org>
      2f7ee569
    • Tejun Heo's avatar
      cgroup: improve old cgroup handling in cgroup_attach_proc() · 134d3373
      Tejun Heo authored
      cgroup_attach_proc() behaves differently from cgroup_attach_task() in
      the following aspects.
      
      * All hooks are invoked even if no task is actually being moved.
      
      * ->can_attach_task() is called for all tasks in the group whether the
        new cgrp is different from the current cgrp or not; however,
        ->attach_task() is skipped if new equals new.  This makes the calls
        asymmetric.
      
      This patch improves old cgroup handling in cgroup_attach_proc() by
      looking up the current cgroup at the head, recording it in the flex
      array along with the task itself, and using it to remove the above two
      differences.  This will also ease further changes.
      
      -v2: nr_todo renamed to nr_migrating_tasks as per Paul Menage's
           suggestion.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reviewed-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Reviewed-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Acked-by: default avatarPaul Menage <paul@paulmenage.org>
      Acked-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      134d3373
    • Tejun Heo's avatar
      cgroup: always lock threadgroup during migration · cd3d0952
      Tejun Heo authored
      Update cgroup to take advantage of the fack that threadgroup_lock()
      guarantees stable threadgroup.
      
      * Lock threadgroup even if the target is a single task.  This
        guarantees that when the target tasks stay stable during migration
        regardless of the target type.
      
      * Remove PF_EXITING early exit optimization from attach_task_by_pid()
        and check it in cgroup_task_migrate() instead.  The optimization was
        for rather cold path to begin with and PF_EXITING state can be
        trusted throughout migration by checking it after locking
        threadgroup.
      
      * Don't add PF_EXITING tasks to target task array in
        cgroup_attach_proc().  This ensures that task migration is performed
        only for live tasks.
      
      * Remove -ESRCH failure path from cgroup_task_migrate().  With the
        above changes, it's guaranteed to be called only for live tasks.
      
      After the changes, only live tasks are migrated and they're guaranteed
      to stay alive until migration is complete.  This removes problems
      caused by exec and exit racing against cgroup migration including
      symmetry among cgroup attach methods and different cgroup methods
      racing each other.
      
      v2: Oleg pointed out that one more PF_EXITING check can be removed
          from cgroup_attach_proc().  Removed.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reviewed-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Reviewed-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Acked-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Paul Menage <paul@paulmenage.org>
      cd3d0952
    • Tejun Heo's avatar
      threadgroup: extend threadgroup_lock() to cover exit and exec · 77e4ef99
      Tejun Heo authored
      threadgroup_lock() protected only protected against new addition to
      the threadgroup, which was inherently somewhat incomplete and
      problematic for its only user cgroup.  On-going migration could race
      against exec and exit leading to interesting problems - the symmetry
      between various attach methods, task exiting during method execution,
      ->exit() racing against attach methods, migrating task switching basic
      properties during exec and so on.
      
      This patch extends threadgroup_lock() such that it protects against
      all three threadgroup altering operations - fork, exit and exec.  For
      exit, threadgroup_change_begin/end() calls are added to exit_signals
      around assertion of PF_EXITING.  For exec, threadgroup_[un]lock() are
      updated to also grab and release cred_guard_mutex.
      
      With this change, threadgroup_lock() guarantees that the target
      threadgroup will remain stable - no new task will be added, no new
      PF_EXITING will be set and exec won't happen.
      
      The next patch will update cgroup so that it can take full advantage
      of this change.
      
      -v2: beefed up comment as suggested by Frederic.
      
      -v3: narrowed scope of protection in exit path as suggested by
           Frederic.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reviewed-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Acked-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      Acked-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Paul Menage <paul@paulmenage.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      77e4ef99
    • Tejun Heo's avatar
      threadgroup: rename signal->threadgroup_fork_lock to ->group_rwsem · 257058ae
      Tejun Heo authored
      Make the following renames to prepare for extension of threadgroup
      locking.
      
      * s/signal->threadgroup_fork_lock/signal->group_rwsem/
      * s/threadgroup_fork_read_lock()/threadgroup_change_begin()/
      * s/threadgroup_fork_read_unlock()/threadgroup_change_end()/
      * s/threadgroup_fork_write_lock()/threadgroup_lock()/
      * s/threadgroup_fork_write_unlock()/threadgroup_unlock()/
      
      This patch doesn't cause any behavior change.
      
      -v2: Rename threadgroup_change_done() to threadgroup_change_end() per
           KAMEZAWA's suggestion.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reviewed-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Acked-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Paul Menage <paul@paulmenage.org>
      257058ae
    • Tejun Heo's avatar
      cgroup: add cgroup_root_mutex · e25e2cbb
      Tejun Heo authored
      cgroup wants to make threadgroup stable while modifying cgroup
      hierarchies which will introduce locking dependency on
      cred_guard_mutex from cgroup_mutex.  This unfortunately completes
      circular dependency.
      
       A. cgroup_mutex -> cred_guard_mutex -> s_type->i_mutex_key -> namespace_sem
       B. namespace_sem -> cgroup_mutex
      
      B is from cgroup_show_options() and this patch breaks it by
      introducing another mutex cgroup_root_mutex which nests inside
      cgroup_mutex and protects cgroupfs_root.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reviewed-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Acked-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      e25e2cbb
  2. 08 Dec, 2011 1 commit
  3. 06 Dec, 2011 1 commit
  4. 24 Nov, 2011 1 commit
  5. 23 Nov, 2011 15 commits
  6. 22 Nov, 2011 15 commits