Skip to content

Commit

Permalink
cgroups: make procs file writable
Browse files Browse the repository at this point in the history
Make procs file writable to move all threads by tgid at once.

Add functionality that enables users to move all threads in a threadgroup
at once to a cgroup by writing the tgid to the 'cgroup.procs' file.  This
current implementation makes use of a per-threadgroup rwsem that's taken
for reading in the fork() path to prevent newly forking threads within the
threadgroup from "escaping" while the move is in progress.

Signed-off-by: Ben Blum <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Li Zefan <[email protected]>
Cc: Matt Helsley <[email protected]>
Reviewed-by: Paul Menage <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Miao Xie <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
bblum authored and torvalds committed May 27, 2011
1 parent f780bdb commit 74a1166
Show file tree
Hide file tree
Showing 2 changed files with 401 additions and 47 deletions.
9 changes: 8 additions & 1 deletion Documentation/cgroups/cgroups.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ containing the following files describing that cgroup:
- cgroup.procs: list of tgids in the cgroup. This list is not
guaranteed to be sorted or free of duplicate tgids, and userspace
should sort/uniquify the list if this property is required.
This is a read-only file, for now.
Writing a thread group id into this file moves all threads in that
group into this cgroup.
- notify_on_release flag: run the release agent on exit?
- release_agent: the path to use for release notifications (this file
exists in the top cgroup only)
Expand Down Expand Up @@ -430,6 +431,12 @@ You can attach the current shell task by echoing 0:

# echo 0 > tasks

You can use the cgroup.procs file instead of the tasks file to move all
threads in a threadgroup at once. Echoing the pid of any task in a
threadgroup to cgroup.procs causes all tasks in that threadgroup to be
be attached to the cgroup. Writing 0 to cgroup.procs moves all tasks
in the writing task's threadgroup.

Note: Since every task is always a member of exactly one cgroup in each
mounted hierarchy, to remove a task from its current cgroup you must
move it into a new cgroup (possibly the root cgroup) by writing to the
Expand Down
Loading

0 comments on commit 74a1166

Please sign in to comment.