1. 13 Dec, 2011 4 commits
    • 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 18 commits