Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 39bd0d15 authored by Li Zefan's avatar Li Zefan Committed by Tejun Heo
Browse files

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: default avatarLi Zefan <lizefan@huawei.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 8b5f1c52
Loading
Loading
Loading
Loading
+28 −9
Original line number Diff line number Diff line
@@ -2015,6 +2015,24 @@ static void cpuset_css_free(struct cgroup_subsys_state *css)
	kfree(cs);
}

static void cpuset_bind(struct cgroup_subsys_state *root_css)
{
	mutex_lock(&cpuset_mutex);
	mutex_lock(&callback_mutex);

	if (cgroup_on_dfl(root_css->cgroup)) {
		cpumask_copy(top_cpuset.cpus_allowed, cpu_possible_mask);
		top_cpuset.mems_allowed = node_possible_map;
	} else {
		cpumask_copy(top_cpuset.cpus_allowed,
			     top_cpuset.effective_cpus);
		top_cpuset.mems_allowed = top_cpuset.effective_mems;
	}

	mutex_unlock(&callback_mutex);
	mutex_unlock(&cpuset_mutex);
}

struct cgroup_subsys cpuset_cgrp_subsys = {
	.css_alloc	= cpuset_css_alloc,
	.css_online	= cpuset_css_online,
@@ -2023,6 +2041,7 @@ struct cgroup_subsys cpuset_cgrp_subsys = {
	.can_attach	= cpuset_can_attach,
	.cancel_attach	= cpuset_cancel_attach,
	.attach		= cpuset_attach,
	.bind		= cpuset_bind,
	.base_cftypes	= files,
	.early_init	= 1,
};