Commit c431069fe4bacc0cd3ca94a8453987140a5b3517

Authored by Tejun Heo
1 parent fc560a26ac

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>

Showing 1 changed file with 17 additions and 11 deletions Side-by-side Diff

... ... @@ -87,8 +87,6 @@
87 87 cpumask_var_t cpus_allowed; /* CPUs allowed to tasks in cpuset */
88 88 nodemask_t mems_allowed; /* Memory Nodes allowed to tasks */
89 89  
90   - struct cpuset *parent; /* my parent */
91   -
92 90 struct fmeter fmeter; /* memory_pressure filter */
93 91  
94 92 /*
... ... @@ -120,6 +118,15 @@
120 118 struct cpuset, css);
121 119 }
122 120  
  121 +static 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 130 #ifdef CONFIG_NUMA
124 131 static inline bool task_has_mempolicy(struct task_struct *task)
125 132 {
... ... @@ -323,7 +330,7 @@
323 330 struct cpumask *pmask)
324 331 {
325 332 while (cs && !cpumask_intersects(cs->cpus_allowed, cpu_online_mask))
326   - cs = cs->parent;
  333 + cs = parent_cs(cs);
327 334 if (cs)
328 335 cpumask_and(pmask, cs->cpus_allowed, cpu_online_mask);
329 336 else
... ... @@ -348,7 +355,7 @@
348 355 {
349 356 while (cs && !nodes_intersects(cs->mems_allowed,
350 357 node_states[N_MEMORY]))
351   - cs = cs->parent;
  358 + cs = parent_cs(cs);
352 359 if (cs)
353 360 nodes_and(*pmask, cs->mems_allowed,
354 361 node_states[N_MEMORY]);
... ... @@ -461,7 +468,7 @@
461 468 if (cur == &top_cpuset)
462 469 goto out;
463 470  
464   - par = cur->parent;
  471 + par = parent_cs(cur);
465 472  
466 473 /* We must be a subset of our parent cpuset */
467 474 ret = -EACCES;
... ... @@ -1866,7 +1873,6 @@
1866 1873 fmeter_init(&cs->fmeter);
1867 1874 INIT_WORK(&cs->hotplug_work, cpuset_propagate_hotplug_workfn);
1868 1875 cs->relax_domain_level = -1;
1869   - cs->parent = cgroup_cs(cont->parent);
1870 1876  
1871 1877 return &cs->css;
1872 1878 }
... ... @@ -1874,7 +1880,7 @@
1874 1880 static int cpuset_css_online(struct cgroup *cgrp)
1875 1881 {
1876 1882 struct cpuset *cs = cgroup_cs(cgrp);
1877   - struct cpuset *parent = cs->parent;
  1883 + struct cpuset *parent = parent_cs(cs);
1878 1884 struct cpuset *tmp_cs;
1879 1885 struct cgroup *pos_cg;
1880 1886  
1881 1887  
... ... @@ -2058,10 +2064,10 @@
2058 2064 * Find its next-highest non-empty parent, (top cpuset
2059 2065 * has online cpus, so can't be empty).
2060 2066 */
2061   - parent = cs->parent;
  2067 + parent = parent_cs(cs);
2062 2068 while (cpumask_empty(parent->cpus_allowed) ||
2063 2069 nodes_empty(parent->mems_allowed))
2064   - parent = parent->parent;
  2070 + parent = parent_cs(parent);
2065 2071  
2066 2072 move_member_tasks_to_cpuset(cs, parent);
2067 2073 }
... ... @@ -2373,8 +2379,8 @@
2373 2379 */
2374 2380 static const struct cpuset *nearest_hardwall_ancestor(const struct cpuset *cs)
2375 2381 {
2376   - while (!(is_mem_exclusive(cs) || is_mem_hardwall(cs)) && cs->parent)
2377   - cs = cs->parent;
  2382 + while (!(is_mem_exclusive(cs) || is_mem_hardwall(cs)) && parent_cs(cs))
  2383 + cs = parent_cs(cs);
2378 2384 return cs;
2379 2385 }
2380 2386