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

Commit 94196f51 authored by Tejun Heo's avatar Tejun Heo
Browse files

cgroup, cpuset: don't use ss->pre_attach()



->pre_attach() is supposed to be called before migration, which is
observed during process migration but task migration does it the other
way around.  The only ->pre_attach() user is cpuset which can do the
same operaitons in ->can_attach().  Collapse cpuset_pre_attach() into
cpuset_can_attach().

-v2: Patch contamination from later patch removed.  Spotted by Paul
     Menage.

Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Reviewed-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Acked-by: default avatarPaul Menage <paul@paulmenage.org>
Cc: Li Zefan <lizf@cn.fujitsu.com>
parent bb9d97b6
Loading
Loading
Loading
Loading
+12 −17
Original line number Diff line number Diff line
@@ -1370,6 +1370,15 @@ static int fmeter_getrate(struct fmeter *fmp)
	return val;
}

/*
 * Protected by cgroup_lock. The nodemasks must be stored globally because
 * dynamically allocating them is not allowed in can_attach, and they must
 * persist until attach.
 */
static cpumask_var_t cpus_attach;
static nodemask_t cpuset_attach_nodemask_from;
static nodemask_t cpuset_attach_nodemask_to;

/* Called by cgroups to determine if a cpuset is usable; cgroup_mutex held */
static int cpuset_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
			     struct cgroup_taskset *tset)
@@ -1396,29 +1405,16 @@ static int cpuset_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
		if ((ret = security_task_setscheduler(task)))
			return ret;
	}
	return 0;
}

/*
 * Protected by cgroup_lock. The nodemasks must be stored globally because
 * dynamically allocating them is not allowed in pre_attach, and they must
 * persist among pre_attach, and attach.
 */
static cpumask_var_t cpus_attach;
static nodemask_t cpuset_attach_nodemask_from;
static nodemask_t cpuset_attach_nodemask_to;

/* Set-up work for before attaching each task. */
static void cpuset_pre_attach(struct cgroup *cont)
{
	struct cpuset *cs = cgroup_cs(cont);

	/* prepare for attach */
	if (cs == &top_cpuset)
		cpumask_copy(cpus_attach, cpu_possible_mask);
	else
		guarantee_online_cpus(cs, cpus_attach);

	guarantee_online_mems(cs, &cpuset_attach_nodemask_to);

	return 0;
}

static void cpuset_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
@@ -1904,7 +1900,6 @@ struct cgroup_subsys cpuset_subsys = {
	.create = cpuset_create,
	.destroy = cpuset_destroy,
	.can_attach = cpuset_can_attach,
	.pre_attach = cpuset_pre_attach,
	.attach = cpuset_attach,
	.populate = cpuset_populate,
	.post_clone = cpuset_post_clone,