diff options
author | Tejun Heo <tj@kernel.org> | 2014-02-08 10:36:58 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-02-08 10:36:58 -0500 |
commit | 073219e995b4a3f8cf1ce8228b7ef440b6994ac0 (patch) | |
tree | d140fc2e94bd8fd09270286b7267fb087a79f288 /kernel/cpuset.c | |
parent | 3ed80a62bf959d34ebd4d553b026fbe7e6fbcc54 (diff) |
cgroup: clean up cgroup_subsys names and initialization
cgroup_subsys is a bit messier than it needs to be.
* The name of a subsys can be different from its internal identifier
defined in cgroup_subsys.h. Most subsystems use the matching name
but three - cpu, memory and perf_event - use different ones.
* cgroup_subsys_id enums are postfixed with _subsys_id and each
cgroup_subsys is postfixed with _subsys. cgroup.h is widely
included throughout various subsystems, it doesn't and shouldn't
have claim on such generic names which don't have any qualifier
indicating that they belong to cgroup.
* cgroup_subsys->subsys_id should always equal the matching
cgroup_subsys_id enum; however, we require each controller to
initialize it and then BUG if they don't match, which is a bit
silly.
This patch cleans up cgroup_subsys names and initialization by doing
the followings.
* cgroup_subsys_id enums are now postfixed with _cgrp_id, and each
cgroup_subsys with _cgrp_subsys.
* With the above, renaming subsys identifiers to match the userland
visible names doesn't cause any naming conflicts. All non-matching
identifiers are renamed to match the official names.
cpu_cgroup -> cpu
mem_cgroup -> memory
perf -> perf_event
* controllers no longer need to initialize ->subsys_id and ->name.
They're generated in cgroup core and set automatically during boot.
* Redundant cgroup_subsys declarations removed.
* While updating BUG_ON()s in cgroup_init_early(), convert them to
WARN()s. BUGging that early during boot is stupid - the kernel
can't print anything, even through serial console and the trap
handler doesn't even link stack frame properly for back-tracing.
This patch doesn't introduce any behavior changes.
v2: Rebased on top of fe1217c4f3f7 ("net: net_cls: move cgroupfs
classid handling into core").
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: "David S. Miller" <davem@davemloft.net>
Acked-by: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Acked-by: Michal Hocko <mhocko@suse.cz>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Aristeu Rozanski <aris@redhat.com>
Acked-by: Ingo Molnar <mingo@redhat.com>
Acked-by: Li Zefan <lizefan@huawei.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Serge E. Hallyn <serue@us.ibm.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Thomas Graf <tgraf@suug.ch>
Diffstat (limited to 'kernel/cpuset.c')
-rw-r--r-- | kernel/cpuset.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 4410ac6a55f1..2d018c795fea 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -119,7 +119,7 @@ static inline struct cpuset *css_cs(struct cgroup_subsys_state *css) | |||
119 | /* Retrieve the cpuset for a task */ | 119 | /* Retrieve the cpuset for a task */ |
120 | static inline struct cpuset *task_cs(struct task_struct *task) | 120 | static inline struct cpuset *task_cs(struct task_struct *task) |
121 | { | 121 | { |
122 | return css_cs(task_css(task, cpuset_subsys_id)); | 122 | return css_cs(task_css(task, cpuset_cgrp_id)); |
123 | } | 123 | } |
124 | 124 | ||
125 | static inline struct cpuset *parent_cs(struct cpuset *cs) | 125 | static inline struct cpuset *parent_cs(struct cpuset *cs) |
@@ -1521,7 +1521,7 @@ static void cpuset_attach(struct cgroup_subsys_state *css, | |||
1521 | struct task_struct *task; | 1521 | struct task_struct *task; |
1522 | struct task_struct *leader = cgroup_taskset_first(tset); | 1522 | struct task_struct *leader = cgroup_taskset_first(tset); |
1523 | struct cgroup_subsys_state *oldcss = cgroup_taskset_cur_css(tset, | 1523 | struct cgroup_subsys_state *oldcss = cgroup_taskset_cur_css(tset, |
1524 | cpuset_subsys_id); | 1524 | cpuset_cgrp_id); |
1525 | struct cpuset *cs = css_cs(css); | 1525 | struct cpuset *cs = css_cs(css); |
1526 | struct cpuset *oldcs = css_cs(oldcss); | 1526 | struct cpuset *oldcs = css_cs(oldcss); |
1527 | struct cpuset *cpus_cs = effective_cpumask_cpuset(cs); | 1527 | struct cpuset *cpus_cs = effective_cpumask_cpuset(cs); |
@@ -2024,8 +2024,7 @@ static void cpuset_css_free(struct cgroup_subsys_state *css) | |||
2024 | kfree(cs); | 2024 | kfree(cs); |
2025 | } | 2025 | } |
2026 | 2026 | ||
2027 | struct cgroup_subsys cpuset_subsys = { | 2027 | struct cgroup_subsys cpuset_cgrp_subsys = { |
2028 | .name = "cpuset", | ||
2029 | .css_alloc = cpuset_css_alloc, | 2028 | .css_alloc = cpuset_css_alloc, |
2030 | .css_online = cpuset_css_online, | 2029 | .css_online = cpuset_css_online, |
2031 | .css_offline = cpuset_css_offline, | 2030 | .css_offline = cpuset_css_offline, |
@@ -2033,7 +2032,6 @@ struct cgroup_subsys cpuset_subsys = { | |||
2033 | .can_attach = cpuset_can_attach, | 2032 | .can_attach = cpuset_can_attach, |
2034 | .cancel_attach = cpuset_cancel_attach, | 2033 | .cancel_attach = cpuset_cancel_attach, |
2035 | .attach = cpuset_attach, | 2034 | .attach = cpuset_attach, |
2036 | .subsys_id = cpuset_subsys_id, | ||
2037 | .base_cftypes = files, | 2035 | .base_cftypes = files, |
2038 | .early_init = 1, | 2036 | .early_init = 1, |
2039 | }; | 2037 | }; |
@@ -2699,7 +2697,7 @@ int proc_cpuset_show(struct seq_file *m, void *unused_v) | |||
2699 | goto out_free; | 2697 | goto out_free; |
2700 | 2698 | ||
2701 | rcu_read_lock(); | 2699 | rcu_read_lock(); |
2702 | css = task_css(tsk, cpuset_subsys_id); | 2700 | css = task_css(tsk, cpuset_cgrp_id); |
2703 | retval = cgroup_path(css->cgroup, buf, PAGE_SIZE); | 2701 | retval = cgroup_path(css->cgroup, buf, PAGE_SIZE); |
2704 | rcu_read_unlock(); | 2702 | rcu_read_unlock(); |
2705 | if (retval < 0) | 2703 | if (retval < 0) |