Skip to content

Commit 1b5f3ba

Browse files
committed
Merge branch 'for-4.16-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
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
2 parents c6256ca + d1897c9 commit 1b5f3ba

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

kernel/cgroup/cgroup.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3183,6 +3183,16 @@ static int cgroup_enable_threaded(struct cgroup *cgrp)
31833183
if (cgroup_is_threaded(cgrp))
31843184
return 0;
31853185

3186+
/*
3187+
* If @cgroup is populated or has domain controllers enabled, it
3188+
* can't be switched. While the below cgroup_can_be_thread_root()
3189+
* test can catch the same conditions, that's only when @parent is
3190+
* not mixable, so let's check it explicitly.
3191+
*/
3192+
if (cgroup_is_populated(cgrp) ||
3193+
cgrp->subtree_control & ~cgrp_dfl_threaded_ss_mask)
3194+
return -EOPNOTSUPP;
3195+
31863196
/* we're joining the parent's domain, ensure its validity */
31873197
if (!cgroup_is_valid_domain(dom_cgrp) ||
31883198
!cgroup_can_be_thread_root(dom_cgrp))

kernel/sched/core.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6683,13 +6683,18 @@ static int tg_cfs_schedulable_down(struct task_group *tg, void *data)
66836683
parent_quota = parent_b->hierarchical_quota;
66846684

66856685
/*
6686-
* Ensure max(child_quota) <= parent_quota, inherit when no
6686+
* Ensure max(child_quota) <= parent_quota. On cgroup2,
6687+
* always take the min. On cgroup1, only inherit when no
66876688
* limit is set:
66886689
*/
6689-
if (quota == RUNTIME_INF)
6690-
quota = parent_quota;
6691-
else if (parent_quota != RUNTIME_INF && quota > parent_quota)
6692-
return -EINVAL;
6690+
if (cgroup_subsys_on_dfl(cpu_cgrp_subsys)) {
6691+
quota = min(quota, parent_quota);
6692+
} else {
6693+
if (quota == RUNTIME_INF)
6694+
quota = parent_quota;
6695+
else if (parent_quota != RUNTIME_INF && quota > parent_quota)
6696+
return -EINVAL;
6697+
}
66936698
}
66946699
cfs_b->hierarchical_quota = quota;
66956700

0 commit comments

Comments
 (0)