diff options
author | Tejun Heo <tj@kernel.org> | 2013-08-02 16:12:13 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-08-02 16:12:13 -0400 |
commit | 61584e3f4964995e575618f76ff7197123796e75 (patch) | |
tree | c43a31c30b23d5e576f2f52983cda804036ed389 | |
parent | b395890a092d8ecbe54f005179e3dec4b6bf752a (diff) | |
parent | da0a12caffad2eeadea429f83818408e7b77379a (diff) |
cgroup: Merge branch 'for-3.11-fixes' into for-3.12
for-3.12 branch is about to receive invasive updates which are
dependent on da0a12caff ("cgroup: fix a leak when percpu_ref_init()
fails"). Given the amount of scheduled changes, I think it'd less
painful to pull in for-3.11-fixes as preparation. Pull in
for-3.11-fixes into for-3.12.
Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r-- | include/linux/cgroup.h | 3 | ||||
-rw-r--r-- | include/linux/cgroup_subsys.h | 45 | ||||
-rw-r--r-- | kernel/cgroup.c | 35 |
3 files changed, 30 insertions, 53 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index bbf4d89b56a8..44dd422d7e9b 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -548,8 +548,7 @@ int cgroup_rm_cftypes(struct cgroup_subsys *ss, struct cftype *cfts); | |||
548 | bool cgroup_is_descendant(struct cgroup *cgrp, struct cgroup *ancestor); | 548 | bool cgroup_is_descendant(struct cgroup *cgrp, struct cgroup *ancestor); |
549 | 549 | ||
550 | int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen); | 550 | int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen); |
551 | int task_cgroup_path_from_hierarchy(struct task_struct *task, int hierarchy_id, | 551 | int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen); |
552 | char *buf, size_t buflen); | ||
553 | 552 | ||
554 | int cgroup_task_count(const struct cgroup *cgrp); | 553 | int cgroup_task_count(const struct cgroup *cgrp); |
555 | 554 | ||
diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h index 6e7ec64b69ab..b613ffd402d1 100644 --- a/include/linux/cgroup_subsys.h +++ b/include/linux/cgroup_subsys.h | |||
@@ -1,86 +1,55 @@ | |||
1 | /* Add subsystem definitions of the form SUBSYS(<name>) in this | 1 | /* |
2 | * file. Surround each one by a line of comment markers so that | 2 | * List of cgroup subsystems. |
3 | * patches don't collide | 3 | * |
4 | * DO NOT ADD ANY SUBSYSTEM WITHOUT EXPLICIT ACKS FROM CGROUP MAINTAINERS. | ||
4 | */ | 5 | */ |
5 | |||
6 | /* */ | ||
7 | |||
8 | /* */ | ||
9 | |||
10 | #if IS_SUBSYS_ENABLED(CONFIG_CPUSETS) | 6 | #if IS_SUBSYS_ENABLED(CONFIG_CPUSETS) |
11 | SUBSYS(cpuset) | 7 | SUBSYS(cpuset) |
12 | #endif | 8 | #endif |
13 | 9 | ||
14 | /* */ | ||
15 | |||
16 | #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEBUG) | 10 | #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEBUG) |
17 | SUBSYS(debug) | 11 | SUBSYS(debug) |
18 | #endif | 12 | #endif |
19 | 13 | ||
20 | /* */ | ||
21 | |||
22 | #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_SCHED) | 14 | #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_SCHED) |
23 | SUBSYS(cpu_cgroup) | 15 | SUBSYS(cpu_cgroup) |
24 | #endif | 16 | #endif |
25 | 17 | ||
26 | /* */ | ||
27 | |||
28 | #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_CPUACCT) | 18 | #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_CPUACCT) |
29 | SUBSYS(cpuacct) | 19 | SUBSYS(cpuacct) |
30 | #endif | 20 | #endif |
31 | 21 | ||
32 | /* */ | ||
33 | |||
34 | #if IS_SUBSYS_ENABLED(CONFIG_MEMCG) | 22 | #if IS_SUBSYS_ENABLED(CONFIG_MEMCG) |
35 | SUBSYS(mem_cgroup) | 23 | SUBSYS(mem_cgroup) |
36 | #endif | 24 | #endif |
37 | 25 | ||
38 | /* */ | ||
39 | |||
40 | #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEVICE) | 26 | #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEVICE) |
41 | SUBSYS(devices) | 27 | SUBSYS(devices) |
42 | #endif | 28 | #endif |
43 | 29 | ||
44 | /* */ | ||
45 | |||
46 | #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_FREEZER) | 30 | #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_FREEZER) |
47 | SUBSYS(freezer) | 31 | SUBSYS(freezer) |
48 | #endif | 32 | #endif |
49 | 33 | ||
50 | /* */ | ||
51 | |||
52 | #if IS_SUBSYS_ENABLED(CONFIG_NET_CLS_CGROUP) | 34 | #if IS_SUBSYS_ENABLED(CONFIG_NET_CLS_CGROUP) |
53 | SUBSYS(net_cls) | 35 | SUBSYS(net_cls) |
54 | #endif | 36 | #endif |
55 | 37 | ||
56 | /* */ | ||
57 | |||
58 | #if IS_SUBSYS_ENABLED(CONFIG_BLK_CGROUP) | 38 | #if IS_SUBSYS_ENABLED(CONFIG_BLK_CGROUP) |
59 | SUBSYS(blkio) | 39 | SUBSYS(blkio) |
60 | #endif | 40 | #endif |
61 | 41 | ||
62 | /* */ | ||
63 | |||
64 | #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_PERF) | 42 | #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_PERF) |
65 | SUBSYS(perf) | 43 | SUBSYS(perf) |
66 | #endif | 44 | #endif |
67 | 45 | ||
68 | /* */ | ||
69 | |||
70 | #if IS_SUBSYS_ENABLED(CONFIG_NETPRIO_CGROUP) | 46 | #if IS_SUBSYS_ENABLED(CONFIG_NETPRIO_CGROUP) |
71 | SUBSYS(net_prio) | 47 | SUBSYS(net_prio) |
72 | #endif | 48 | #endif |
73 | 49 | ||
74 | /* */ | ||
75 | |||
76 | #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_HUGETLB) | 50 | #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_HUGETLB) |
77 | SUBSYS(hugetlb) | 51 | SUBSYS(hugetlb) |
78 | #endif | 52 | #endif |
79 | 53 | /* | |
80 | /* */ | 54 | * DO NOT ADD ANY SUBSYSTEM WITHOUT EXPLICIT ACKS FROM CGROUP MAINTAINERS. |
81 | 55 | */ | |
82 | #ifdef CONFIG_CGROUP_BCACHE | ||
83 | SUBSYS(bcache) | ||
84 | #endif | ||
85 | |||
86 | /* */ | ||
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 9420662df87e..ae4c46834633 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -1805,36 +1805,43 @@ out: | |||
1805 | EXPORT_SYMBOL_GPL(cgroup_path); | 1805 | EXPORT_SYMBOL_GPL(cgroup_path); |
1806 | 1806 | ||
1807 | /** | 1807 | /** |
1808 | * task_cgroup_path_from_hierarchy - cgroup path of a task on a hierarchy | 1808 | * task_cgroup_path - cgroup path of a task in the first cgroup hierarchy |
1809 | * @task: target task | 1809 | * @task: target task |
1810 | * @hierarchy_id: the hierarchy to look up @task's cgroup from | ||
1811 | * @buf: the buffer to write the path into | 1810 | * @buf: the buffer to write the path into |
1812 | * @buflen: the length of the buffer | 1811 | * @buflen: the length of the buffer |
1813 | * | 1812 | * |
1814 | * Determine @task's cgroup on the hierarchy specified by @hierarchy_id and | 1813 | * Determine @task's cgroup on the first (the one with the lowest non-zero |
1815 | * copy its path into @buf. This function grabs cgroup_mutex and shouldn't | 1814 | * hierarchy_id) cgroup hierarchy and copy its path into @buf. This |
1816 | * be used inside locks used by cgroup controller callbacks. | 1815 | * function grabs cgroup_mutex and shouldn't be used inside locks used by |
1816 | * cgroup controller callbacks. | ||
1817 | * | ||
1818 | * Returns 0 on success, fails with -%ENAMETOOLONG if @buflen is too short. | ||
1817 | */ | 1819 | */ |
1818 | int task_cgroup_path_from_hierarchy(struct task_struct *task, int hierarchy_id, | 1820 | int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen) |
1819 | char *buf, size_t buflen) | ||
1820 | { | 1821 | { |
1821 | struct cgroupfs_root *root; | 1822 | struct cgroupfs_root *root; |
1822 | struct cgroup *cgrp = NULL; | 1823 | struct cgroup *cgrp; |
1823 | int ret = -ENOENT; | 1824 | int hierarchy_id = 1, ret = 0; |
1825 | |||
1826 | if (buflen < 2) | ||
1827 | return -ENAMETOOLONG; | ||
1824 | 1828 | ||
1825 | mutex_lock(&cgroup_mutex); | 1829 | mutex_lock(&cgroup_mutex); |
1826 | 1830 | ||
1827 | root = idr_find(&cgroup_hierarchy_idr, hierarchy_id); | 1831 | root = idr_get_next(&cgroup_hierarchy_idr, &hierarchy_id); |
1832 | |||
1828 | if (root) { | 1833 | if (root) { |
1829 | cgrp = task_cgroup_from_root(task, root); | 1834 | cgrp = task_cgroup_from_root(task, root); |
1830 | ret = cgroup_path(cgrp, buf, buflen); | 1835 | ret = cgroup_path(cgrp, buf, buflen); |
1836 | } else { | ||
1837 | /* if no hierarchy exists, everyone is in "/" */ | ||
1838 | memcpy(buf, "/", 2); | ||
1831 | } | 1839 | } |
1832 | 1840 | ||
1833 | mutex_unlock(&cgroup_mutex); | 1841 | mutex_unlock(&cgroup_mutex); |
1834 | |||
1835 | return ret; | 1842 | return ret; |
1836 | } | 1843 | } |
1837 | EXPORT_SYMBOL_GPL(task_cgroup_path_from_hierarchy); | 1844 | EXPORT_SYMBOL_GPL(task_cgroup_path); |
1838 | 1845 | ||
1839 | /* | 1846 | /* |
1840 | * Control Group taskset | 1847 | * Control Group taskset |
@@ -4304,8 +4311,10 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
4304 | } | 4311 | } |
4305 | 4312 | ||
4306 | err = percpu_ref_init(&css->refcnt, css_release); | 4313 | err = percpu_ref_init(&css->refcnt, css_release); |
4307 | if (err) | 4314 | if (err) { |
4315 | ss->css_free(cgrp); | ||
4308 | goto err_free_all; | 4316 | goto err_free_all; |
4317 | } | ||
4309 | 4318 | ||
4310 | init_cgroup_css(css, ss, cgrp); | 4319 | init_cgroup_css(css, ss, cgrp); |
4311 | 4320 | ||