aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/cgroup.h3
-rw-r--r--include/linux/cgroup_subsys.h45
-rw-r--r--kernel/cgroup.c31
3 files changed, 27 insertions, 52 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 297462b9f41a..e9ac882868c0 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -542,8 +542,7 @@ int cgroup_rm_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
542bool cgroup_is_descendant(struct cgroup *cgrp, struct cgroup *ancestor); 542bool cgroup_is_descendant(struct cgroup *cgrp, struct cgroup *ancestor);
543 543
544int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen); 544int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen);
545int task_cgroup_path_from_hierarchy(struct task_struct *task, int hierarchy_id, 545int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen);
546 char *buf, size_t buflen);
547 546
548int cgroup_task_count(const struct cgroup *cgrp); 547int cgroup_task_count(const struct cgroup *cgrp);
549 548
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)
11SUBSYS(cpuset) 7SUBSYS(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)
17SUBSYS(debug) 11SUBSYS(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)
23SUBSYS(cpu_cgroup) 15SUBSYS(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)
29SUBSYS(cpuacct) 19SUBSYS(cpuacct)
30#endif 20#endif
31 21
32/* */
33
34#if IS_SUBSYS_ENABLED(CONFIG_MEMCG) 22#if IS_SUBSYS_ENABLED(CONFIG_MEMCG)
35SUBSYS(mem_cgroup) 23SUBSYS(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)
41SUBSYS(devices) 27SUBSYS(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)
47SUBSYS(freezer) 31SUBSYS(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)
53SUBSYS(net_cls) 35SUBSYS(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)
59SUBSYS(blkio) 39SUBSYS(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)
65SUBSYS(perf) 43SUBSYS(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)
71SUBSYS(net_prio) 47SUBSYS(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)
77SUBSYS(hugetlb) 51SUBSYS(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
83SUBSYS(bcache)
84#endif
85
86/* */
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 0e0b20b8c5db..789ec4683db3 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1845,36 +1845,43 @@ out:
1845EXPORT_SYMBOL_GPL(cgroup_path); 1845EXPORT_SYMBOL_GPL(cgroup_path);
1846 1846
1847/** 1847/**
1848 * task_cgroup_path_from_hierarchy - cgroup path of a task on a hierarchy 1848 * task_cgroup_path - cgroup path of a task in the first cgroup hierarchy
1849 * @task: target task 1849 * @task: target task
1850 * @hierarchy_id: the hierarchy to look up @task's cgroup from
1851 * @buf: the buffer to write the path into 1850 * @buf: the buffer to write the path into
1852 * @buflen: the length of the buffer 1851 * @buflen: the length of the buffer
1853 * 1852 *
1854 * Determine @task's cgroup on the hierarchy specified by @hierarchy_id and 1853 * Determine @task's cgroup on the first (the one with the lowest non-zero
1855 * copy its path into @buf. This function grabs cgroup_mutex and shouldn't 1854 * hierarchy_id) cgroup hierarchy and copy its path into @buf. This
1856 * be used inside locks used by cgroup controller callbacks. 1855 * function grabs cgroup_mutex and shouldn't be used inside locks used by
1856 * cgroup controller callbacks.
1857 *
1858 * Returns 0 on success, fails with -%ENAMETOOLONG if @buflen is too short.
1857 */ 1859 */
1858int task_cgroup_path_from_hierarchy(struct task_struct *task, int hierarchy_id, 1860int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen)
1859 char *buf, size_t buflen)
1860{ 1861{
1861 struct cgroupfs_root *root; 1862 struct cgroupfs_root *root;
1862 struct cgroup *cgrp = NULL; 1863 struct cgroup *cgrp;
1863 int ret = -ENOENT; 1864 int hierarchy_id = 1, ret = 0;
1865
1866 if (buflen < 2)
1867 return -ENAMETOOLONG;
1864 1868
1865 mutex_lock(&cgroup_mutex); 1869 mutex_lock(&cgroup_mutex);
1866 1870
1867 root = idr_find(&cgroup_hierarchy_idr, hierarchy_id); 1871 root = idr_get_next(&cgroup_hierarchy_idr, &hierarchy_id);
1872
1868 if (root) { 1873 if (root) {
1869 cgrp = task_cgroup_from_root(task, root); 1874 cgrp = task_cgroup_from_root(task, root);
1870 ret = cgroup_path(cgrp, buf, buflen); 1875 ret = cgroup_path(cgrp, buf, buflen);
1876 } else {
1877 /* if no hierarchy exists, everyone is in "/" */
1878 memcpy(buf, "/", 2);
1871 } 1879 }
1872 1880
1873 mutex_unlock(&cgroup_mutex); 1881 mutex_unlock(&cgroup_mutex);
1874
1875 return ret; 1882 return ret;
1876} 1883}
1877EXPORT_SYMBOL_GPL(task_cgroup_path_from_hierarchy); 1884EXPORT_SYMBOL_GPL(task_cgroup_path);
1878 1885
1879/* 1886/*
1880 * Control Group taskset 1887 * Control Group taskset