Skip to content

Commit 39bd0d1

Browse files
lizf-oshtejun
authored andcommitted
cpuset: initialize top_cpuset's configured masks at mount
We now have to support different behaviors for default hierachy and legacy hiearchy, top_cpuset's configured masks need to be initialized accordingly. Suppose we've offlined cpu1. On default hierarchy: # mount -t cgroup -o __DEVEL__sane_behavior xxx /cpuset # cat /cpuset/cpuset.cpus 0-15 On legacy hierarchy: # mount -t cgroup xxx /cpuset # cat /cpuset/cpuset.cpus 0,2-15 Signed-off-by: Li Zefan <lizefan@huawei.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 8b5f1c5 commit 39bd0d1

1 file changed

Lines changed: 28 additions & 9 deletions

File tree

‎kernel/cpuset.c‎

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,16 +2015,35 @@ static void cpuset_css_free(struct cgroup_subsys_state *css)
20152015
kfree(cs);
20162016
}
20172017

2018+
static void cpuset_bind(struct cgroup_subsys_state *root_css)
2019+
{
2020+
mutex_lock(&cpuset_mutex);
2021+
mutex_lock(&callback_mutex);
2022+
2023+
if (cgroup_on_dfl(root_css->cgroup)) {
2024+
cpumask_copy(top_cpuset.cpus_allowed, cpu_possible_mask);
2025+
top_cpuset.mems_allowed = node_possible_map;
2026+
} else {
2027+
cpumask_copy(top_cpuset.cpus_allowed,
2028+
top_cpuset.effective_cpus);
2029+
top_cpuset.mems_allowed = top_cpuset.effective_mems;
2030+
}
2031+
2032+
mutex_unlock(&callback_mutex);
2033+
mutex_unlock(&cpuset_mutex);
2034+
}
2035+
20182036
struct cgroup_subsys cpuset_cgrp_subsys = {
2019-
.css_alloc = cpuset_css_alloc,
2020-
.css_online = cpuset_css_online,
2021-
.css_offline = cpuset_css_offline,
2022-
.css_free = cpuset_css_free,
2023-
.can_attach = cpuset_can_attach,
2024-
.cancel_attach = cpuset_cancel_attach,
2025-
.attach = cpuset_attach,
2026-
.base_cftypes = files,
2027-
.early_init = 1,
2037+
.css_alloc = cpuset_css_alloc,
2038+
.css_online = cpuset_css_online,
2039+
.css_offline = cpuset_css_offline,
2040+
.css_free = cpuset_css_free,
2041+
.can_attach = cpuset_can_attach,
2042+
.cancel_attach = cpuset_cancel_attach,
2043+
.attach = cpuset_attach,
2044+
.bind = cpuset_bind,
2045+
.base_cftypes = files,
2046+
.early_init = 1,
20282047
};
20292048

20302049
/**

0 commit comments

Comments
 (0)