aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-01-07 11:51:08 -0500
committerTejun Heo <tj@kernel.org>2013-01-07 11:51:08 -0500
commitc431069fe4bacc0cd3ca94a8453987140a5b3517 (patch)
treec86d339c574086a1b0d2e15087f940441aca0db4 /kernel
parentfc560a26accea9567b7f8f41eefa01e1bb127d74 (diff)
cpuset: remove cpuset->parent
cgroup already tracks the hierarchy. Follow cgroup->parent to find the parent and drop cpuset->parent. Signed-off-by: Tejun Heo <tj@kernel.org> Reviewed-by: Michal Hocko <mhocko@suse.cz> Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cpuset.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 0ddb48d40e4d..6aa5bbb5f33b 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -87,8 +87,6 @@ struct cpuset {
87 cpumask_var_t cpus_allowed; /* CPUs allowed to tasks in cpuset */ 87 cpumask_var_t cpus_allowed; /* CPUs allowed to tasks in cpuset */
88 nodemask_t mems_allowed; /* Memory Nodes allowed to tasks */ 88 nodemask_t mems_allowed; /* Memory Nodes allowed to tasks */
89 89
90 struct cpuset *parent; /* my parent */
91
92 struct fmeter fmeter; /* memory_pressure filter */ 90 struct fmeter fmeter; /* memory_pressure filter */
93 91
94 /* 92 /*
@@ -120,6 +118,15 @@ static inline struct cpuset *task_cs(struct task_struct *task)
120 struct cpuset, css); 118 struct cpuset, css);
121} 119}
122 120
121static inline struct cpuset *parent_cs(const struct cpuset *cs)
122{
123 struct cgroup *pcgrp = cs->css.cgroup->parent;
124
125 if (pcgrp)
126 return cgroup_cs(pcgrp);
127 return NULL;
128}
129
123#ifdef CONFIG_NUMA 130#ifdef CONFIG_NUMA
124static inline bool task_has_mempolicy(struct task_struct *task) 131static inline bool task_has_mempolicy(struct task_struct *task)
125{ 132{
@@ -323,7 +330,7 @@ static void guarantee_online_cpus(const struct cpuset *cs,
323 struct cpumask *pmask) 330 struct cpumask *pmask)
324{ 331{
325 while (cs && !cpumask_intersects(cs->cpus_allowed, cpu_online_mask)) 332 while (cs && !cpumask_intersects(cs->cpus_allowed, cpu_online_mask))
326 cs = cs->parent; 333 cs = parent_cs(cs);
327 if (cs) 334 if (cs)
328 cpumask_and(pmask, cs->cpus_allowed, cpu_online_mask); 335 cpumask_and(pmask, cs->cpus_allowed, cpu_online_mask);
329 else 336 else
@@ -348,7 +355,7 @@ static void guarantee_online_mems(const struct cpuset *cs, nodemask_t *pmask)
348{ 355{
349 while (cs && !nodes_intersects(cs->mems_allowed, 356 while (cs && !nodes_intersects(cs->mems_allowed,
350 node_states[N_MEMORY])) 357 node_states[N_MEMORY]))
351 cs = cs->parent; 358 cs = parent_cs(cs);
352 if (cs) 359 if (cs)
353 nodes_and(*pmask, cs->mems_allowed, 360 nodes_and(*pmask, cs->mems_allowed,
354 node_states[N_MEMORY]); 361 node_states[N_MEMORY]);
@@ -461,7 +468,7 @@ static int validate_change(const struct cpuset *cur, const struct cpuset *trial)
461 if (cur == &top_cpuset) 468 if (cur == &top_cpuset)
462 goto out; 469 goto out;
463 470
464 par = cur->parent; 471 par = parent_cs(cur);
465 472
466 /* We must be a subset of our parent cpuset */ 473 /* We must be a subset of our parent cpuset */
467 ret = -EACCES; 474 ret = -EACCES;
@@ -1866,7 +1873,6 @@ static struct cgroup_subsys_state *cpuset_css_alloc(struct cgroup *cont)
1866 fmeter_init(&cs->fmeter); 1873 fmeter_init(&cs->fmeter);
1867 INIT_WORK(&cs->hotplug_work, cpuset_propagate_hotplug_workfn); 1874 INIT_WORK(&cs->hotplug_work, cpuset_propagate_hotplug_workfn);
1868 cs->relax_domain_level = -1; 1875 cs->relax_domain_level = -1;
1869 cs->parent = cgroup_cs(cont->parent);
1870 1876
1871 return &cs->css; 1877 return &cs->css;
1872} 1878}
@@ -1874,7 +1880,7 @@ static struct cgroup_subsys_state *cpuset_css_alloc(struct cgroup *cont)
1874static int cpuset_css_online(struct cgroup *cgrp) 1880static int cpuset_css_online(struct cgroup *cgrp)
1875{ 1881{
1876 struct cpuset *cs = cgroup_cs(cgrp); 1882 struct cpuset *cs = cgroup_cs(cgrp);
1877 struct cpuset *parent = cs->parent; 1883 struct cpuset *parent = parent_cs(cs);
1878 struct cpuset *tmp_cs; 1884 struct cpuset *tmp_cs;
1879 struct cgroup *pos_cg; 1885 struct cgroup *pos_cg;
1880 1886
@@ -2058,10 +2064,10 @@ static void remove_tasks_in_empty_cpuset(struct cpuset *cs)
2058 * Find its next-highest non-empty parent, (top cpuset 2064 * Find its next-highest non-empty parent, (top cpuset
2059 * has online cpus, so can't be empty). 2065 * has online cpus, so can't be empty).
2060 */ 2066 */
2061 parent = cs->parent; 2067 parent = parent_cs(cs);
2062 while (cpumask_empty(parent->cpus_allowed) || 2068 while (cpumask_empty(parent->cpus_allowed) ||
2063 nodes_empty(parent->mems_allowed)) 2069 nodes_empty(parent->mems_allowed))
2064 parent = parent->parent; 2070 parent = parent_cs(parent);
2065 2071
2066 move_member_tasks_to_cpuset(cs, parent); 2072 move_member_tasks_to_cpuset(cs, parent);
2067} 2073}
@@ -2373,8 +2379,8 @@ int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask)
2373 */ 2379 */
2374static const struct cpuset *nearest_hardwall_ancestor(const struct cpuset *cs) 2380static const struct cpuset *nearest_hardwall_ancestor(const struct cpuset *cs)
2375{ 2381{
2376 while (!(is_mem_exclusive(cs) || is_mem_hardwall(cs)) && cs->parent) 2382 while (!(is_mem_exclusive(cs) || is_mem_hardwall(cs)) && parent_cs(cs))
2377 cs = cs->parent; 2383 cs = parent_cs(cs);
2378 return cs; 2384 return cs;
2379} 2385}
2380 2386