diff options
author | Tejun Heo <tj@kernel.org> | 2013-04-07 12:29:51 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-04-07 12:29:51 -0400 |
commit | 7ae1bad99e27b8838d480a24edf4646a2fc547df (patch) | |
tree | 1e18e174b1d1de2e11be2734fb2d60f928ad95cc /kernel/cgroup.c | |
parent | 8cc9934520e7f752fe45d5199664d741ba24a932 (diff) |
cgroup: relocate cgroup_lock_live_group() and cgroup_attach_task_all()
cgroup_lock_live_group() and cgroup_attach_task() are scheduled to be
made static. Relocate the former and cgroup_attach_task_all() so that
we don't need forward declarations.
This patch is pure relocation.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 147d7ccb3b0b..ae7617095dec 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -329,6 +329,24 @@ static inline struct cftype *__d_cft(struct dentry *dentry) | |||
329 | return __d_cfe(dentry)->type; | 329 | return __d_cfe(dentry)->type; |
330 | } | 330 | } |
331 | 331 | ||
332 | /** | ||
333 | * cgroup_lock_live_group - take cgroup_mutex and check that cgrp is alive. | ||
334 | * @cgrp: the cgroup to be checked for liveness | ||
335 | * | ||
336 | * On success, returns true; the lock should be later released with | ||
337 | * cgroup_unlock(). On failure returns false with no lock held. | ||
338 | */ | ||
339 | bool cgroup_lock_live_group(struct cgroup *cgrp) | ||
340 | { | ||
341 | mutex_lock(&cgroup_mutex); | ||
342 | if (cgroup_is_removed(cgrp)) { | ||
343 | mutex_unlock(&cgroup_mutex); | ||
344 | return false; | ||
345 | } | ||
346 | return true; | ||
347 | } | ||
348 | EXPORT_SYMBOL_GPL(cgroup_lock_live_group); | ||
349 | |||
332 | /* the list of cgroups eligible for automatic release. Protected by | 350 | /* the list of cgroups eligible for automatic release. Protected by |
333 | * release_list_lock */ | 351 | * release_list_lock */ |
334 | static LIST_HEAD(release_list); | 352 | static LIST_HEAD(release_list); |
@@ -1944,30 +1962,6 @@ static void cgroup_task_migrate(struct cgroup *oldcgrp, | |||
1944 | } | 1962 | } |
1945 | 1963 | ||
1946 | /** | 1964 | /** |
1947 | * cgroup_attach_task_all - attach task 'tsk' to all cgroups of task 'from' | ||
1948 | * @from: attach to all cgroups of a given task | ||
1949 | * @tsk: the task to be attached | ||
1950 | */ | ||
1951 | int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk) | ||
1952 | { | ||
1953 | struct cgroupfs_root *root; | ||
1954 | int retval = 0; | ||
1955 | |||
1956 | cgroup_lock(); | ||
1957 | for_each_active_root(root) { | ||
1958 | struct cgroup *from_cg = task_cgroup_from_root(from, root); | ||
1959 | |||
1960 | retval = cgroup_attach_task(from_cg, tsk, false); | ||
1961 | if (retval) | ||
1962 | break; | ||
1963 | } | ||
1964 | cgroup_unlock(); | ||
1965 | |||
1966 | return retval; | ||
1967 | } | ||
1968 | EXPORT_SYMBOL_GPL(cgroup_attach_task_all); | ||
1969 | |||
1970 | /** | ||
1971 | * cgroup_attach_task - attach a task or a whole threadgroup to a cgroup | 1965 | * cgroup_attach_task - attach a task or a whole threadgroup to a cgroup |
1972 | * @cgrp: the cgroup to attach to | 1966 | * @cgrp: the cgroup to attach to |
1973 | * @tsk: the task or the leader of the threadgroup to be attached | 1967 | * @tsk: the task or the leader of the threadgroup to be attached |
@@ -2204,6 +2198,30 @@ out_unlock_cgroup: | |||
2204 | return ret; | 2198 | return ret; |
2205 | } | 2199 | } |
2206 | 2200 | ||
2201 | /** | ||
2202 | * cgroup_attach_task_all - attach task 'tsk' to all cgroups of task 'from' | ||
2203 | * @from: attach to all cgroups of a given task | ||
2204 | * @tsk: the task to be attached | ||
2205 | */ | ||
2206 | int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk) | ||
2207 | { | ||
2208 | struct cgroupfs_root *root; | ||
2209 | int retval = 0; | ||
2210 | |||
2211 | cgroup_lock(); | ||
2212 | for_each_active_root(root) { | ||
2213 | struct cgroup *from_cg = task_cgroup_from_root(from, root); | ||
2214 | |||
2215 | retval = cgroup_attach_task(from_cg, tsk, false); | ||
2216 | if (retval) | ||
2217 | break; | ||
2218 | } | ||
2219 | cgroup_unlock(); | ||
2220 | |||
2221 | return retval; | ||
2222 | } | ||
2223 | EXPORT_SYMBOL_GPL(cgroup_attach_task_all); | ||
2224 | |||
2207 | static int cgroup_tasks_write(struct cgroup *cgrp, struct cftype *cft, u64 pid) | 2225 | static int cgroup_tasks_write(struct cgroup *cgrp, struct cftype *cft, u64 pid) |
2208 | { | 2226 | { |
2209 | return attach_task_by_pid(cgrp, pid, false); | 2227 | return attach_task_by_pid(cgrp, pid, false); |
@@ -2214,24 +2232,6 @@ static int cgroup_procs_write(struct cgroup *cgrp, struct cftype *cft, u64 tgid) | |||
2214 | return attach_task_by_pid(cgrp, tgid, true); | 2232 | return attach_task_by_pid(cgrp, tgid, true); |
2215 | } | 2233 | } |
2216 | 2234 | ||
2217 | /** | ||
2218 | * cgroup_lock_live_group - take cgroup_mutex and check that cgrp is alive. | ||
2219 | * @cgrp: the cgroup to be checked for liveness | ||
2220 | * | ||
2221 | * On success, returns true; the lock should be later released with | ||
2222 | * cgroup_unlock(). On failure returns false with no lock held. | ||
2223 | */ | ||
2224 | bool cgroup_lock_live_group(struct cgroup *cgrp) | ||
2225 | { | ||
2226 | mutex_lock(&cgroup_mutex); | ||
2227 | if (cgroup_is_removed(cgrp)) { | ||
2228 | mutex_unlock(&cgroup_mutex); | ||
2229 | return false; | ||
2230 | } | ||
2231 | return true; | ||
2232 | } | ||
2233 | EXPORT_SYMBOL_GPL(cgroup_lock_live_group); | ||
2234 | |||
2235 | static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft, | 2235 | static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft, |
2236 | const char *buffer) | 2236 | const char *buffer) |
2237 | { | 2237 | { |