aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2014-05-04 15:09:13 -0400
committerTejun Heo <tj@kernel.org>2014-05-04 15:09:13 -0400
commit69dfa00ccb72a37f3810687ca110e5a8154c6eed (patch)
tree8e4c8511c940f844d555c3791fce13bbda1f7d73 /kernel/cgroup.c
parented3d261b53f51c9505822d757d1800c79fb68788 (diff)
cgroup: make flags and subsys_masks unsigned int
There's no reason to use atomic bitops for cgroup_subsys_state->flags, cgroup_root->flags and various subsys_masks. This patch updates those to use bitwise and/or operations instead and converts them form unsigned long to unsigned int. This makes the fields occupy (marginally) smaller space and makes it clear that they don't require atomicity. This patch doesn't cause any behavior difference. 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.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 3873267c9ee3..21667f396a1e 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -181,7 +181,7 @@ static struct cftype cgroup_base_files[];
181 181
182static void cgroup_put(struct cgroup *cgrp); 182static void cgroup_put(struct cgroup *cgrp);
183static int rebind_subsystems(struct cgroup_root *dst_root, 183static int rebind_subsystems(struct cgroup_root *dst_root,
184 unsigned long ss_mask); 184 unsigned int ss_mask);
185static void cgroup_destroy_css_killed(struct cgroup *cgrp); 185static void cgroup_destroy_css_killed(struct cgroup *cgrp);
186static int cgroup_destroy_locked(struct cgroup *cgrp); 186static int cgroup_destroy_locked(struct cgroup *cgrp);
187static int create_css(struct cgroup *cgrp, struct cgroup_subsys *ss); 187static int create_css(struct cgroup *cgrp, struct cgroup_subsys *ss);
@@ -963,7 +963,7 @@ static struct cgroup *task_cgroup_from_root(struct task_struct *task,
963 * update of a tasks cgroup pointer by cgroup_attach_task() 963 * update of a tasks cgroup pointer by cgroup_attach_task()
964 */ 964 */
965 965
966static int cgroup_populate_dir(struct cgroup *cgrp, unsigned long subsys_mask); 966static int cgroup_populate_dir(struct cgroup *cgrp, unsigned int subsys_mask);
967static struct kernfs_syscall_ops cgroup_kf_syscall_ops; 967static struct kernfs_syscall_ops cgroup_kf_syscall_ops;
968static const struct file_operations proc_cgroupstats_operations; 968static const struct file_operations proc_cgroupstats_operations;
969 969
@@ -1079,7 +1079,7 @@ static void cgroup_rm_file(struct cgroup *cgrp, const struct cftype *cft)
1079 * @cgrp: target cgroup 1079 * @cgrp: target cgroup
1080 * @subsys_mask: mask of the subsystem ids whose files should be removed 1080 * @subsys_mask: mask of the subsystem ids whose files should be removed
1081 */ 1081 */
1082static void cgroup_clear_dir(struct cgroup *cgrp, unsigned long subsys_mask) 1082static void cgroup_clear_dir(struct cgroup *cgrp, unsigned int subsys_mask)
1083{ 1083{
1084 struct cgroup_subsys *ss; 1084 struct cgroup_subsys *ss;
1085 int i; 1085 int i;
@@ -1087,15 +1087,14 @@ static void cgroup_clear_dir(struct cgroup *cgrp, unsigned long subsys_mask)
1087 for_each_subsys(ss, i) { 1087 for_each_subsys(ss, i) {
1088 struct cftype *cfts; 1088 struct cftype *cfts;
1089 1089
1090 if (!test_bit(i, &subsys_mask)) 1090 if (!(subsys_mask & (1 << i)))
1091 continue; 1091 continue;
1092 list_for_each_entry(cfts, &ss->cfts, node) 1092 list_for_each_entry(cfts, &ss->cfts, node)
1093 cgroup_addrm_files(cgrp, cfts, false); 1093 cgroup_addrm_files(cgrp, cfts, false);
1094 } 1094 }
1095} 1095}
1096 1096
1097static int rebind_subsystems(struct cgroup_root *dst_root, 1097static int rebind_subsystems(struct cgroup_root *dst_root, unsigned int ss_mask)
1098 unsigned long ss_mask)
1099{ 1098{
1100 struct cgroup_subsys *ss; 1099 struct cgroup_subsys *ss;
1101 int ssid, i, ret; 1100 int ssid, i, ret;
@@ -1128,7 +1127,7 @@ static int rebind_subsystems(struct cgroup_root *dst_root,
1128 * Just warn about it and continue. 1127 * Just warn about it and continue.
1129 */ 1128 */
1130 if (cgrp_dfl_root_visible) { 1129 if (cgrp_dfl_root_visible) {
1131 pr_warn("failed to create files (%d) while rebinding 0x%lx to default root\n", 1130 pr_warn("failed to create files (%d) while rebinding 0x%x to default root\n",
1132 ret, ss_mask); 1131 ret, ss_mask);
1133 pr_warn("you may retry by moving them to a different hierarchy and unbinding\n"); 1132 pr_warn("you may retry by moving them to a different hierarchy and unbinding\n");
1134 } 1133 }
@@ -1214,8 +1213,8 @@ static int cgroup_show_options(struct seq_file *seq,
1214} 1213}
1215 1214
1216struct cgroup_sb_opts { 1215struct cgroup_sb_opts {
1217 unsigned long subsys_mask; 1216 unsigned int subsys_mask;
1218 unsigned long flags; 1217 unsigned int flags;
1219 char *release_agent; 1218 char *release_agent;
1220 bool cpuset_clone_children; 1219 bool cpuset_clone_children;
1221 char *name; 1220 char *name;
@@ -1227,12 +1226,12 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
1227{ 1226{
1228 char *token, *o = data; 1227 char *token, *o = data;
1229 bool all_ss = false, one_ss = false; 1228 bool all_ss = false, one_ss = false;
1230 unsigned long mask = (unsigned long)-1; 1229 unsigned int mask = -1U;
1231 struct cgroup_subsys *ss; 1230 struct cgroup_subsys *ss;
1232 int i; 1231 int i;
1233 1232
1234#ifdef CONFIG_CPUSETS 1233#ifdef CONFIG_CPUSETS
1235 mask = ~(1UL << cpuset_cgrp_id); 1234 mask = ~(1U << cpuset_cgrp_id);
1236#endif 1235#endif
1237 1236
1238 memset(opts, 0, sizeof(*opts)); 1237 memset(opts, 0, sizeof(*opts));
@@ -1313,7 +1312,7 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
1313 /* Mutually exclusive option 'all' + subsystem name */ 1312 /* Mutually exclusive option 'all' + subsystem name */
1314 if (all_ss) 1313 if (all_ss)
1315 return -EINVAL; 1314 return -EINVAL;
1316 set_bit(i, &opts->subsys_mask); 1315 opts->subsys_mask |= (1 << i);
1317 one_ss = true; 1316 one_ss = true;
1318 1317
1319 break; 1318 break;
@@ -1342,7 +1341,7 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
1342 if (all_ss || (!one_ss && !opts->none && !opts->name)) 1341 if (all_ss || (!one_ss && !opts->none && !opts->name))
1343 for_each_subsys(ss, i) 1342 for_each_subsys(ss, i)
1344 if (!ss->disabled) 1343 if (!ss->disabled)
1345 set_bit(i, &opts->subsys_mask); 1344 opts->subsys_mask |= (1 << i);
1346 1345
1347 /* 1346 /*
1348 * We either have to specify by name or by subsystems. (So 1347 * We either have to specify by name or by subsystems. (So
@@ -1373,7 +1372,7 @@ static int cgroup_remount(struct kernfs_root *kf_root, int *flags, char *data)
1373 int ret = 0; 1372 int ret = 0;
1374 struct cgroup_root *root = cgroup_root_from_kf(kf_root); 1373 struct cgroup_root *root = cgroup_root_from_kf(kf_root);
1375 struct cgroup_sb_opts opts; 1374 struct cgroup_sb_opts opts;
1376 unsigned long added_mask, removed_mask; 1375 unsigned int added_mask, removed_mask;
1377 1376
1378 if (root->flags & CGRP_ROOT_SANE_BEHAVIOR) { 1377 if (root->flags & CGRP_ROOT_SANE_BEHAVIOR) {
1379 pr_err("sane_behavior: remount is not allowed\n"); 1378 pr_err("sane_behavior: remount is not allowed\n");
@@ -1398,7 +1397,7 @@ static int cgroup_remount(struct kernfs_root *kf_root, int *flags, char *data)
1398 /* Don't allow flags or name to change at remount */ 1397 /* Don't allow flags or name to change at remount */
1399 if (((opts.flags ^ root->flags) & CGRP_ROOT_OPTION_MASK) || 1398 if (((opts.flags ^ root->flags) & CGRP_ROOT_OPTION_MASK) ||
1400 (opts.name && strcmp(opts.name, root->name))) { 1399 (opts.name && strcmp(opts.name, root->name))) {
1401 pr_err("option or name mismatch, new: 0x%lx \"%s\", old: 0x%lx \"%s\"\n", 1400 pr_err("option or name mismatch, new: 0x%x \"%s\", old: 0x%x \"%s\"\n",
1402 opts.flags & CGRP_ROOT_OPTION_MASK, opts.name ?: "", 1401 opts.flags & CGRP_ROOT_OPTION_MASK, opts.name ?: "",
1403 root->flags & CGRP_ROOT_OPTION_MASK, root->name); 1402 root->flags & CGRP_ROOT_OPTION_MASK, root->name);
1404 ret = -EINVAL; 1403 ret = -EINVAL;
@@ -1522,7 +1521,7 @@ static void init_cgroup_root(struct cgroup_root *root,
1522 set_bit(CGRP_CPUSET_CLONE_CHILDREN, &root->cgrp.flags); 1521 set_bit(CGRP_CPUSET_CLONE_CHILDREN, &root->cgrp.flags);
1523} 1522}
1524 1523
1525static int cgroup_setup_root(struct cgroup_root *root, unsigned long ss_mask) 1524static int cgroup_setup_root(struct cgroup_root *root, unsigned int ss_mask)
1526{ 1525{
1527 LIST_HEAD(tmp_links); 1526 LIST_HEAD(tmp_links);
1528 struct cgroup *root_cgrp = &root->cgrp; 1527 struct cgroup *root_cgrp = &root->cgrp;
@@ -2507,7 +2506,7 @@ out_finish:
2507static int cgroup_subtree_control_write(struct cgroup_subsys_state *dummy_css, 2506static int cgroup_subtree_control_write(struct cgroup_subsys_state *dummy_css,
2508 struct cftype *cft, char *buffer) 2507 struct cftype *cft, char *buffer)
2509{ 2508{
2510 unsigned long enable_req = 0, disable_req = 0, enable, disable; 2509 unsigned int enable_req = 0, disable_req = 0, enable, disable;
2511 struct cgroup *cgrp = dummy_css->cgroup, *child; 2510 struct cgroup *cgrp = dummy_css->cgroup, *child;
2512 struct cgroup_subsys *ss; 2511 struct cgroup_subsys *ss;
2513 char *tok, *p; 2512 char *tok, *p;
@@ -3998,7 +3997,7 @@ static struct cftype cgroup_base_files[] = {
3998 * 3997 *
3999 * On failure, no file is added. 3998 * On failure, no file is added.
4000 */ 3999 */
4001static int cgroup_populate_dir(struct cgroup *cgrp, unsigned long subsys_mask) 4000static int cgroup_populate_dir(struct cgroup *cgrp, unsigned int subsys_mask)
4002{ 4001{
4003 struct cgroup_subsys *ss; 4002 struct cgroup_subsys *ss;
4004 int i, ret = 0; 4003 int i, ret = 0;
@@ -4007,7 +4006,7 @@ static int cgroup_populate_dir(struct cgroup *cgrp, unsigned long subsys_mask)
4007 for_each_subsys(ss, i) { 4006 for_each_subsys(ss, i) {
4008 struct cftype *cfts; 4007 struct cftype *cfts;
4009 4008
4010 if (!test_bit(i, &subsys_mask)) 4009 if (!(subsys_mask & (1 << i)))
4011 continue; 4010 continue;
4012 4011
4013 list_for_each_entry(cfts, &ss->cfts, node) { 4012 list_for_each_entry(cfts, &ss->cfts, node) {