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

Commit 68d47a13 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'for-3.7-hierarchy' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup

Pull cgroup hierarchy update from Tejun Heo:
 "Currently, different cgroup subsystems handle nested cgroups
  completely differently.  There's no consistency among subsystems and
  the behaviors often are outright broken.

  People at least seem to agree that the broken hierarhcy behaviors need
  to be weeded out if any progress is gonna be made on this front and
  that the fallouts from deprecating the broken behaviors should be
  acceptable especially given that the current behaviors don't make much
  sense when nested.

  This patch makes cgroup emit warning messages if cgroups for
  subsystems with broken hierarchy behavior are nested to prepare for
  fixing them in the future.  This was put in a separate branch because
  more related changes were expected (didn't make it this round) and the
  memory cgroup wanted to pull in this and make changes on top."

* 'for-3.7-hierarchy' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
  cgroup: mark subsystems with broken hierarchy support and whine if cgroups are nested for them
parents c0e8a139 8c7f6edb
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -737,6 +737,14 @@ struct cgroup_subsys blkio_subsys = {
	.subsys_id = blkio_subsys_id,
	.subsys_id = blkio_subsys_id,
	.base_cftypes = blkcg_files,
	.base_cftypes = blkcg_files,
	.module = THIS_MODULE,
	.module = THIS_MODULE,

	/*
	 * blkio subsystem is utterly broken in terms of hierarchy support.
	 * It treats all cgroups equally regardless of where they're
	 * located in the hierarchy - all cgroups are treated as if they're
	 * right below the root.  Fix it and remove the following.
	 */
	.broken_hierarchy = true,
};
};
EXPORT_SYMBOL_GPL(blkio_subsys);
EXPORT_SYMBOL_GPL(blkio_subsys);


+15 −0
Original line number Original line Diff line number Diff line
@@ -499,6 +499,21 @@ struct cgroup_subsys {
	 */
	 */
	bool __DEPRECATED_clear_css_refs;
	bool __DEPRECATED_clear_css_refs;


	/*
	 * If %false, this subsystem is properly hierarchical -
	 * configuration, resource accounting and restriction on a parent
	 * cgroup cover those of its children.  If %true, hierarchy support
	 * is broken in some ways - some subsystems ignore hierarchy
	 * completely while others are only implemented half-way.
	 *
	 * It's now disallowed to create nested cgroups if the subsystem is
	 * broken and cgroup core will emit a warning message on such
	 * cases.  Eventually, all subsystems will be made properly
	 * hierarchical and this will go away.
	 */
	bool broken_hierarchy;
	bool warned_broken_hierarchy;

#define MAX_CGROUP_TYPE_NAMELEN 32
#define MAX_CGROUP_TYPE_NAMELEN 32
	const char *name;
	const char *name;


+11 −1
Original line number Original line Diff line number Diff line
@@ -4076,8 +4076,9 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
		set_bit(CGRP_CLONE_CHILDREN, &cgrp->flags);
		set_bit(CGRP_CLONE_CHILDREN, &cgrp->flags);


	for_each_subsys(root, ss) {
	for_each_subsys(root, ss) {
		struct cgroup_subsys_state *css = ss->create(cgrp);
		struct cgroup_subsys_state *css;


		css = ss->create(cgrp);
		if (IS_ERR(css)) {
		if (IS_ERR(css)) {
			err = PTR_ERR(css);
			err = PTR_ERR(css);
			goto err_destroy;
			goto err_destroy;
@@ -4091,6 +4092,15 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
		/* At error, ->destroy() callback has to free assigned ID. */
		/* At error, ->destroy() callback has to free assigned ID. */
		if (clone_children(parent) && ss->post_clone)
		if (clone_children(parent) && ss->post_clone)
			ss->post_clone(cgrp);
			ss->post_clone(cgrp);

		if (ss->broken_hierarchy && !ss->warned_broken_hierarchy &&
		    parent->parent) {
			pr_warning("cgroup: %s (%d) created nested cgroup for controller \"%s\" which has incomplete hierarchy support. Nested cgroups may change behavior in the future.\n",
				   current->comm, current->pid, ss->name);
			if (!strcmp(ss->name, "memory"))
				pr_warning("cgroup: \"memory\" requires setting use_hierarchy to 1 on the root.\n");
			ss->warned_broken_hierarchy = true;
		}
	}
	}


	list_add(&cgrp->sibling, &cgrp->parent->children);
	list_add(&cgrp->sibling, &cgrp->parent->children);
+8 −0
Original line number Original line Diff line number Diff line
@@ -373,4 +373,12 @@ struct cgroup_subsys freezer_subsys = {
	.can_attach	= freezer_can_attach,
	.can_attach	= freezer_can_attach,
	.fork		= freezer_fork,
	.fork		= freezer_fork,
	.base_cftypes	= files,
	.base_cftypes	= files,

	/*
	 * freezer subsys doesn't handle hierarchy at all.  Frozen state
	 * should be inherited through the hierarchy - if a parent is
	 * frozen, all its children should be frozen.  Fix it and remove
	 * the following.
	 */
	.broken_hierarchy = true,
};
};
+7 −0
Original line number Original line Diff line number Diff line
@@ -7503,5 +7503,12 @@ struct cgroup_subsys perf_subsys = {
	.destroy	= perf_cgroup_destroy,
	.destroy	= perf_cgroup_destroy,
	.exit		= perf_cgroup_exit,
	.exit		= perf_cgroup_exit,
	.attach		= perf_cgroup_attach,
	.attach		= perf_cgroup_attach,

	/*
	 * perf_event cgroup doesn't handle nesting correctly.
	 * ctx->nr_cgroups adjustments should be propagated through the
	 * cgroup hierarchy.  Fix it and remove the following.
	 */
	.broken_hierarchy = true,
};
};
#endif /* CONFIG_CGROUP_PERF */
#endif /* CONFIG_CGROUP_PERF */
Loading