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

Commit 1b5f3ba4 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull cgroup fixes from Tejun Heo:
 "Two commits to fix the following subtle cgroup2 behavior bugs:

   - cpu.max was rejecting config when it shouldn't

   - thread mode enable was allowed when it shouldn't"

* 'for-4.16-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
  cgroup: fix rule checking for threaded mode switching
  sched, cgroup: Don't reject lower cpu.max on ancestors
parents c6256ca9 d1897c95
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -3183,6 +3183,16 @@ static int cgroup_enable_threaded(struct cgroup *cgrp)
	if (cgroup_is_threaded(cgrp))
	if (cgroup_is_threaded(cgrp))
		return 0;
		return 0;


	/*
	 * If @cgroup is populated or has domain controllers enabled, it
	 * can't be switched.  While the below cgroup_can_be_thread_root()
	 * test can catch the same conditions, that's only when @parent is
	 * not mixable, so let's check it explicitly.
	 */
	if (cgroup_is_populated(cgrp) ||
	    cgrp->subtree_control & ~cgrp_dfl_threaded_ss_mask)
		return -EOPNOTSUPP;

	/* we're joining the parent's domain, ensure its validity */
	/* we're joining the parent's domain, ensure its validity */
	if (!cgroup_is_valid_domain(dom_cgrp) ||
	if (!cgroup_is_valid_domain(dom_cgrp) ||
	    !cgroup_can_be_thread_root(dom_cgrp))
	    !cgroup_can_be_thread_root(dom_cgrp))
+10 −5
Original line number Original line Diff line number Diff line
@@ -6683,14 +6683,19 @@ static int tg_cfs_schedulable_down(struct task_group *tg, void *data)
		parent_quota = parent_b->hierarchical_quota;
		parent_quota = parent_b->hierarchical_quota;


		/*
		/*
		 * Ensure max(child_quota) <= parent_quota, inherit when no
		 * Ensure max(child_quota) <= parent_quota.  On cgroup2,
		 * always take the min.  On cgroup1, only inherit when no
		 * limit is set:
		 * limit is set:
		 */
		 */
		if (cgroup_subsys_on_dfl(cpu_cgrp_subsys)) {
			quota = min(quota, parent_quota);
		} else {
			if (quota == RUNTIME_INF)
			if (quota == RUNTIME_INF)
				quota = parent_quota;
				quota = parent_quota;
			else if (parent_quota != RUNTIME_INF && quota > parent_quota)
			else if (parent_quota != RUNTIME_INF && quota > parent_quota)
				return -EINVAL;
				return -EINVAL;
		}
		}
	}
	cfs_b->hierarchical_quota = quota;
	cfs_b->hierarchical_quota = quota;


	return 0;
	return 0;