aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2014-07-09 10:08:08 -0400
committerTejun Heo <tj@kernel.org>2014-07-09 10:08:08 -0400
commitaa6ec29bee8692ce232132f1a1ea2a1f9196610e (patch)
tree6edb7f3fa4a3ac01ab03d874918a8c45e0b55e40 /kernel
parentc1d5d42efdb3e0470c1cfd2fcb50bc3eae813283 (diff)
cgroup: remove sane_behavior support on non-default hierarchies
sane_behavior has been used as a development vehicle for the default unified hierarchy. Now that the default hierarchy is in place, the flag became redundant and confusing as its usage is allowed on all hierarchies. There are gonna be either the default hierarchy or legacy ones. Let's make that clear by removing sane_behavior support on non-default hierarchies. This patch replaces cgroup_sane_behavior() with cgroup_on_dfl(). The comment on top of CGRP_ROOT_SANE_BEHAVIOR is moved to on top of cgroup_on_dfl() with sane_behavior specific part dropped. On the default and legacy hierarchies w/o sane_behavior, this shouldn't cause any behavior differences. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Vivek Goyal <vgoyal@redhat.com> Acked-by: Li Zefan <lizefan@huawei.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@suse.cz>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cgroup.c19
-rw-r--r--kernel/cpuset.c33
2 files changed, 25 insertions, 27 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 0ea54af6b133..fb07c6d43aff 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1470,8 +1470,8 @@ static int cgroup_remount(struct kernfs_root *kf_root, int *flags, char *data)
1470 struct cgroup_sb_opts opts; 1470 struct cgroup_sb_opts opts;
1471 unsigned int added_mask, removed_mask; 1471 unsigned int added_mask, removed_mask;
1472 1472
1473 if (root->flags & CGRP_ROOT_SANE_BEHAVIOR) { 1473 if (root == &cgrp_dfl_root) {
1474 pr_err("sane_behavior: remount is not allowed\n"); 1474 pr_err("remount is not allowed\n");
1475 return -EINVAL; 1475 return -EINVAL;
1476 } 1476 }
1477 1477
@@ -2943,9 +2943,9 @@ static int cgroup_rename(struct kernfs_node *kn, struct kernfs_node *new_parent,
2943 2943
2944 /* 2944 /*
2945 * This isn't a proper migration and its usefulness is very 2945 * This isn't a proper migration and its usefulness is very
2946 * limited. Disallow if sane_behavior. 2946 * limited. Disallow on the default hierarchy.
2947 */ 2947 */
2948 if (cgroup_sane_behavior(cgrp)) 2948 if (cgroup_on_dfl(cgrp))
2949 return -EPERM; 2949 return -EPERM;
2950 2950
2951 /* 2951 /*
@@ -3031,7 +3031,7 @@ static int cgroup_addrm_files(struct cgroup *cgrp, struct cftype cfts[],
3031 /* does cft->flags tell us to skip this file on @cgrp? */ 3031 /* does cft->flags tell us to skip this file on @cgrp? */
3032 if ((cft->flags & CFTYPE_ONLY_ON_DFL) && !cgroup_on_dfl(cgrp)) 3032 if ((cft->flags & CFTYPE_ONLY_ON_DFL) && !cgroup_on_dfl(cgrp))
3033 continue; 3033 continue;
3034 if ((cft->flags & CFTYPE_INSANE) && cgroup_sane_behavior(cgrp)) 3034 if ((cft->flags & CFTYPE_INSANE) && cgroup_on_dfl(cgrp))
3035 continue; 3035 continue;
3036 if ((cft->flags & CFTYPE_NOT_ON_ROOT) && !cgroup_parent(cgrp)) 3036 if ((cft->flags & CFTYPE_NOT_ON_ROOT) && !cgroup_parent(cgrp))
3037 continue; 3037 continue;
@@ -3764,8 +3764,9 @@ after:
3764 * 3764 *
3765 * All this extra complexity was caused by the original implementation 3765 * All this extra complexity was caused by the original implementation
3766 * committing to an entirely unnecessary property. In the long term, we 3766 * committing to an entirely unnecessary property. In the long term, we
3767 * want to do away with it. Explicitly scramble sort order if 3767 * want to do away with it. Explicitly scramble sort order if on the
3768 * sane_behavior so that no such expectation exists in the new interface. 3768 * default hierarchy so that no such expectation exists in the new
3769 * interface.
3769 * 3770 *
3770 * Scrambling is done by swapping every two consecutive bits, which is 3771 * Scrambling is done by swapping every two consecutive bits, which is
3771 * non-identity one-to-one mapping which disturbs sort order sufficiently. 3772 * non-identity one-to-one mapping which disturbs sort order sufficiently.
@@ -3780,7 +3781,7 @@ static pid_t pid_fry(pid_t pid)
3780 3781
3781static pid_t cgroup_pid_fry(struct cgroup *cgrp, pid_t pid) 3782static pid_t cgroup_pid_fry(struct cgroup *cgrp, pid_t pid)
3782{ 3783{
3783 if (cgroup_sane_behavior(cgrp)) 3784 if (cgroup_on_dfl(cgrp))
3784 return pid_fry(pid); 3785 return pid_fry(pid);
3785 else 3786 else
3786 return pid; 3787 return pid;
@@ -3883,7 +3884,7 @@ static int pidlist_array_load(struct cgroup *cgrp, enum cgroup_filetype type,
3883 css_task_iter_end(&it); 3884 css_task_iter_end(&it);
3884 length = n; 3885 length = n;
3885 /* now sort & (if procs) strip out duplicates */ 3886 /* now sort & (if procs) strip out duplicates */
3886 if (cgroup_sane_behavior(cgrp)) 3887 if (cgroup_on_dfl(cgrp))
3887 sort(array, length, sizeof(pid_t), fried_cmppid, NULL); 3888 sort(array, length, sizeof(pid_t), fried_cmppid, NULL);
3888 else 3889 else
3889 sort(array, length, sizeof(pid_t), cmppid, NULL); 3890 sort(array, length, sizeof(pid_t), cmppid, NULL);
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index f6b33c696224..f9d4807c869f 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1383,12 +1383,9 @@ static int cpuset_can_attach(struct cgroup_subsys_state *css,
1383 1383
1384 mutex_lock(&cpuset_mutex); 1384 mutex_lock(&cpuset_mutex);
1385 1385
1386 /* 1386 /* allow moving tasks into an empty cpuset if on default hierarchy */
1387 * We allow to move tasks into an empty cpuset if sane_behavior
1388 * flag is set.
1389 */
1390 ret = -ENOSPC; 1387 ret = -ENOSPC;
1391 if (!cgroup_sane_behavior(css->cgroup) && 1388 if (!cgroup_on_dfl(css->cgroup) &&
1392 (cpumask_empty(cs->cpus_allowed) || nodes_empty(cs->mems_allowed))) 1389 (cpumask_empty(cs->cpus_allowed) || nodes_empty(cs->mems_allowed)))
1393 goto out_unlock; 1390 goto out_unlock;
1394 1391
@@ -2030,7 +2027,7 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs)
2030 static cpumask_t off_cpus; 2027 static cpumask_t off_cpus;
2031 static nodemask_t off_mems; 2028 static nodemask_t off_mems;
2032 bool is_empty; 2029 bool is_empty;
2033 bool sane = cgroup_sane_behavior(cs->css.cgroup); 2030 bool on_dfl = cgroup_on_dfl(cs->css.cgroup);
2034 2031
2035retry: 2032retry:
2036 wait_event(cpuset_attach_wq, cs->attach_in_progress == 0); 2033 wait_event(cpuset_attach_wq, cs->attach_in_progress == 0);
@@ -2054,12 +2051,12 @@ retry:
2054 mutex_unlock(&callback_mutex); 2051 mutex_unlock(&callback_mutex);
2055 2052
2056 /* 2053 /*
2057 * If sane_behavior flag is set, we need to update tasks' cpumask 2054 * If on_dfl, we need to update tasks' cpumask for empty cpuset to
2058 * for empty cpuset to take on ancestor's cpumask. Otherwise, don't 2055 * take on ancestor's cpumask. Otherwise, don't call
2059 * call update_tasks_cpumask() if the cpuset becomes empty, as 2056 * update_tasks_cpumask() if the cpuset becomes empty, as the tasks
2060 * the tasks in it will be migrated to an ancestor. 2057 * in it will be migrated to an ancestor.
2061 */ 2058 */
2062 if ((sane && cpumask_empty(cs->cpus_allowed)) || 2059 if ((on_dfl && cpumask_empty(cs->cpus_allowed)) ||
2063 (!cpumask_empty(&off_cpus) && !cpumask_empty(cs->cpus_allowed))) 2060 (!cpumask_empty(&off_cpus) && !cpumask_empty(cs->cpus_allowed)))
2064 update_tasks_cpumask(cs); 2061 update_tasks_cpumask(cs);
2065 2062
@@ -2068,12 +2065,12 @@ retry:
2068 mutex_unlock(&callback_mutex); 2065 mutex_unlock(&callback_mutex);
2069 2066
2070 /* 2067 /*
2071 * If sane_behavior flag is set, we need to update tasks' nodemask 2068 * If on_dfl, we need to update tasks' nodemask for empty cpuset to
2072 * for empty cpuset to take on ancestor's nodemask. Otherwise, don't 2069 * take on ancestor's nodemask. Otherwise, don't call
2073 * call update_tasks_nodemask() if the cpuset becomes empty, as 2070 * update_tasks_nodemask() if the cpuset becomes empty, as the
2074 * the tasks in it will be migratd to an ancestor. 2071 * tasks in it will be migratd to an ancestor.
2075 */ 2072 */
2076 if ((sane && nodes_empty(cs->mems_allowed)) || 2073 if ((on_dfl && nodes_empty(cs->mems_allowed)) ||
2077 (!nodes_empty(off_mems) && !nodes_empty(cs->mems_allowed))) 2074 (!nodes_empty(off_mems) && !nodes_empty(cs->mems_allowed)))
2078 update_tasks_nodemask(cs); 2075 update_tasks_nodemask(cs);
2079 2076
@@ -2083,13 +2080,13 @@ retry:
2083 mutex_unlock(&cpuset_mutex); 2080 mutex_unlock(&cpuset_mutex);
2084 2081
2085 /* 2082 /*
2086 * If sane_behavior flag is set, we'll keep tasks in empty cpusets. 2083 * If on_dfl, we'll keep tasks in empty cpusets.
2087 * 2084 *
2088 * Otherwise move tasks to the nearest ancestor with execution 2085 * Otherwise move tasks to the nearest ancestor with execution
2089 * resources. This is full cgroup operation which will 2086 * resources. This is full cgroup operation which will
2090 * also call back into cpuset. Should be done outside any lock. 2087 * also call back into cpuset. Should be done outside any lock.
2091 */ 2088 */
2092 if (!sane && is_empty) 2089 if (!on_dfl && is_empty)
2093 remove_tasks_in_empty_cpuset(cs); 2090 remove_tasks_in_empty_cpuset(cs);
2094} 2091}
2095 2092