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

Commit 4baf6e33 authored by Tejun Heo's avatar Tejun Heo
Browse files

cgroup: convert all non-memcg controllers to the new cftype interface



Convert debug, freezer, cpuset, cpu_cgroup, cpuacct, net_prio, blkio,
net_cls and device controllers to use the new cftype based interface.
Termination entry is added to cftype arrays and populate callbacks are
replaced with cgroup_subsys->base_cftypes initializations.

This is functionally identical transformation.  There shouldn't be any
visible behavior change.

memcg is rather special and will be converted separately.

Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Cc: Paul Menage <paul@paulmenage.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Vivek Goyal <vgoyal@redhat.com>
parent 676f7c8f
Loading
Loading
Loading
Loading
+2 −7
Original line number Original line Diff line number Diff line
@@ -1515,14 +1515,9 @@ struct cftype blkio_files[] = {
		.read_map = blkiocg_file_read_map,
		.read_map = blkiocg_file_read_map,
	},
	},
#endif
#endif
	{ }	/* terminate */
};
};


static int blkiocg_populate(struct cgroup_subsys *subsys, struct cgroup *cgroup)
{
	return cgroup_add_files(cgroup, subsys, blkio_files,
				ARRAY_SIZE(blkio_files));
}

static void blkiocg_destroy(struct cgroup *cgroup)
static void blkiocg_destroy(struct cgroup *cgroup)
{
{
	struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgroup);
	struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgroup);
@@ -1642,11 +1637,11 @@ struct cgroup_subsys blkio_subsys = {
	.can_attach = blkiocg_can_attach,
	.can_attach = blkiocg_can_attach,
	.attach = blkiocg_attach,
	.attach = blkiocg_attach,
	.destroy = blkiocg_destroy,
	.destroy = blkiocg_destroy,
	.populate = blkiocg_populate,
#ifdef CONFIG_BLK_CGROUP
#ifdef CONFIG_BLK_CGROUP
	/* note: blkio_subsys_id is otherwise defined in blk-cgroup.h */
	/* note: blkio_subsys_id is otherwise defined in blk-cgroup.h */
	.subsys_id = blkio_subsys_id,
	.subsys_id = blkio_subsys_id,
#endif
#endif
	.base_cftypes = blkio_files,
	.use_id = 1,
	.use_id = 1,
	.module = THIS_MODULE,
	.module = THIS_MODULE,
};
};
+3 −7
Original line number Original line Diff line number Diff line
@@ -5349,19 +5349,15 @@ static struct cftype debug_files[] = {
		.name = "releasable",
		.name = "releasable",
		.read_u64 = releasable_read,
		.read_u64 = releasable_read,
	},
	},
};


static int debug_populate(struct cgroup_subsys *ss, struct cgroup *cont)
	{ }	/* terminate */
{
};
	return cgroup_add_files(cont, ss, debug_files,
				ARRAY_SIZE(debug_files));
}


struct cgroup_subsys debug_subsys = {
struct cgroup_subsys debug_subsys = {
	.name = "debug",
	.name = "debug",
	.create = debug_create,
	.create = debug_create,
	.destroy = debug_destroy,
	.destroy = debug_destroy,
	.populate = debug_populate,
	.subsys_id = debug_subsys_id,
	.subsys_id = debug_subsys_id,
	.base_cftypes = debug_files,
};
};
#endif /* CONFIG_CGROUP_DEBUG */
#endif /* CONFIG_CGROUP_DEBUG */
+3 −8
Original line number Original line Diff line number Diff line
@@ -358,24 +358,19 @@ static int freezer_write(struct cgroup *cgroup,
static struct cftype files[] = {
static struct cftype files[] = {
	{
	{
		.name = "state",
		.name = "state",
		.flags = CFTYPE_NOT_ON_ROOT,
		.read_seq_string = freezer_read,
		.read_seq_string = freezer_read,
		.write_string = freezer_write,
		.write_string = freezer_write,
	},
	},
	{ }	/* terminate */
};
};


static int freezer_populate(struct cgroup_subsys *ss, struct cgroup *cgroup)
{
	if (!cgroup->parent)
		return 0;
	return cgroup_add_files(cgroup, ss, files, ARRAY_SIZE(files));
}

struct cgroup_subsys freezer_subsys = {
struct cgroup_subsys freezer_subsys = {
	.name		= "freezer",
	.name		= "freezer",
	.create		= freezer_create,
	.create		= freezer_create,
	.destroy	= freezer_destroy,
	.destroy	= freezer_destroy,
	.populate	= freezer_populate,
	.subsys_id	= freezer_subsys_id,
	.subsys_id	= freezer_subsys_id,
	.can_attach	= freezer_can_attach,
	.can_attach	= freezer_can_attach,
	.fork		= freezer_fork,
	.fork		= freezer_fork,
	.base_cftypes	= files,
};
};
+10 −21
Original line number Original line Diff line number Diff line
@@ -1765,28 +1765,17 @@ static struct cftype files[] = {
		.write_u64 = cpuset_write_u64,
		.write_u64 = cpuset_write_u64,
		.private = FILE_SPREAD_SLAB,
		.private = FILE_SPREAD_SLAB,
	},
	},
};


static struct cftype cft_memory_pressure_enabled = {
	{
		.name = "memory_pressure_enabled",
		.name = "memory_pressure_enabled",
		.flags = CFTYPE_ONLY_ON_ROOT,
		.read_u64 = cpuset_read_u64,
		.read_u64 = cpuset_read_u64,
		.write_u64 = cpuset_write_u64,
		.write_u64 = cpuset_write_u64,
		.private = FILE_MEMORY_PRESSURE_ENABLED,
		.private = FILE_MEMORY_PRESSURE_ENABLED,
};
	},

static int cpuset_populate(struct cgroup_subsys *ss, struct cgroup *cont)
{
	int err;


	err = cgroup_add_files(cont, ss, files, ARRAY_SIZE(files));
	{ }	/* terminate */
	if (err)
};
		return err;
	/* memory_pressure_enabled is in root cpuset only */
	if (!cont->parent)
		err = cgroup_add_file(cont, ss,
				      &cft_memory_pressure_enabled);
	return err;
}


/*
/*
 * post_clone() is called during cgroup_create() when the
 * post_clone() is called during cgroup_create() when the
@@ -1887,9 +1876,9 @@ struct cgroup_subsys cpuset_subsys = {
	.destroy = cpuset_destroy,
	.destroy = cpuset_destroy,
	.can_attach = cpuset_can_attach,
	.can_attach = cpuset_can_attach,
	.attach = cpuset_attach,
	.attach = cpuset_attach,
	.populate = cpuset_populate,
	.post_clone = cpuset_post_clone,
	.post_clone = cpuset_post_clone,
	.subsys_id = cpuset_subsys_id,
	.subsys_id = cpuset_subsys_id,
	.base_cftypes = files,
	.early_init = 1,
	.early_init = 1,
};
};


+4 −12
Original line number Original line Diff line number Diff line
@@ -7970,13 +7970,9 @@ static struct cftype cpu_files[] = {
		.write_u64 = cpu_rt_period_write_uint,
		.write_u64 = cpu_rt_period_write_uint,
	},
	},
#endif
#endif
	{ }	/* terminate */
};
};


static int cpu_cgroup_populate(struct cgroup_subsys *ss, struct cgroup *cont)
{
	return cgroup_add_files(cont, ss, cpu_files, ARRAY_SIZE(cpu_files));
}

struct cgroup_subsys cpu_cgroup_subsys = {
struct cgroup_subsys cpu_cgroup_subsys = {
	.name		= "cpu",
	.name		= "cpu",
	.create		= cpu_cgroup_create,
	.create		= cpu_cgroup_create,
@@ -7984,8 +7980,8 @@ struct cgroup_subsys cpu_cgroup_subsys = {
	.can_attach	= cpu_cgroup_can_attach,
	.can_attach	= cpu_cgroup_can_attach,
	.attach		= cpu_cgroup_attach,
	.attach		= cpu_cgroup_attach,
	.exit		= cpu_cgroup_exit,
	.exit		= cpu_cgroup_exit,
	.populate	= cpu_cgroup_populate,
	.subsys_id	= cpu_cgroup_subsys_id,
	.subsys_id	= cpu_cgroup_subsys_id,
	.base_cftypes	= cpu_files,
	.early_init	= 1,
	.early_init	= 1,
};
};


@@ -8170,13 +8166,9 @@ static struct cftype files[] = {
		.name = "stat",
		.name = "stat",
		.read_map = cpuacct_stats_show,
		.read_map = cpuacct_stats_show,
	},
	},
	{ }	/* terminate */
};
};


static int cpuacct_populate(struct cgroup_subsys *ss, struct cgroup *cgrp)
{
	return cgroup_add_files(cgrp, ss, files, ARRAY_SIZE(files));
}

/*
/*
 * charge this task's execution time to its accounting group.
 * charge this task's execution time to its accounting group.
 *
 *
@@ -8208,7 +8200,7 @@ struct cgroup_subsys cpuacct_subsys = {
	.name = "cpuacct",
	.name = "cpuacct",
	.create = cpuacct_create,
	.create = cpuacct_create,
	.destroy = cpuacct_destroy,
	.destroy = cpuacct_destroy,
	.populate = cpuacct_populate,
	.subsys_id = cpuacct_subsys_id,
	.subsys_id = cpuacct_subsys_id,
	.base_cftypes = files,
};
};
#endif	/* CONFIG_CGROUP_CPUACCT */
#endif	/* CONFIG_CGROUP_CPUACCT */
Loading