diff options
author | Serge E. Hallyn <serue@us.ibm.com> | 2007-10-19 02:39:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-19 14:53:37 -0400 |
commit | 858d72ead4864da0fb0b89b919524125ce998e27 (patch) | |
tree | 19ea321ca3b505efecb2053a829daf89a6a22529 /include | |
parent | 846c7bb055747989891f5cd2bb6e8d56243ba1e7 (diff) |
cgroups: implement namespace tracking subsystem
When a task enters a new namespace via a clone() or unshare(), a new cgroup
is created and the task moves into it.
This version names cgroups which are automatically created using
cgroup_clone() as "node_<pid>" where pid is the pid of the unsharing or
cloned process. (Thanks Pavel for the idea) This is safe because if the
process unshares again, it will create
/cgroups/(...)/node_<pid>/node_<pid>
The only possibilities (AFAICT) for a -EEXIST on unshare are
1. pid wraparound
2. a process fails an unshare, then tries again.
Case 1 is unlikely enough that I ignore it (at least for now). In case 2, the
node_<pid> will be empty and can be rmdir'ed to make the subsequent unshare()
succeed.
Changelog:
Name cloned cgroups as "node_<pid>".
[clg@fr.ibm.com: fix order of cgroup subsystems in init/Kconfig]
Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
Cc: Paul Menage <menage@google.com>
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/cgroup_subsys.h | 6 | ||||
-rw-r--r-- | include/linux/nsproxy.h | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h index cbadc3b5dbc0..651ff0869b2d 100644 --- a/include/linux/cgroup_subsys.h +++ b/include/linux/cgroup_subsys.h | |||
@@ -24,3 +24,9 @@ SUBSYS(debug) | |||
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | /* */ | 26 | /* */ |
27 | |||
28 | #ifdef CONFIG_CGROUP_NS | ||
29 | SUBSYS(ns) | ||
30 | #endif | ||
31 | |||
32 | /* */ | ||
diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h index 033a648709b6..f1eca68751a9 100644 --- a/include/linux/nsproxy.h +++ b/include/linux/nsproxy.h | |||
@@ -55,4 +55,11 @@ static inline void exit_task_namespaces(struct task_struct *p) | |||
55 | put_nsproxy(ns); | 55 | put_nsproxy(ns); |
56 | } | 56 | } |
57 | } | 57 | } |
58 | |||
59 | #ifdef CONFIG_CGROUP_NS | ||
60 | int ns_cgroup_clone(struct task_struct *tsk); | ||
61 | #else | ||
62 | static inline int ns_cgroup_clone(struct task_struct *tsk) { return 0; } | ||
63 | #endif | ||
64 | |||
58 | #endif | 65 | #endif |