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

Changed files
+20 -5
kernel
cgroup
sched
+10
kernel/cgroup/cgroup.c
··· 3183 3183 if (cgroup_is_threaded(cgrp)) 3184 3184 return 0; 3185 3185 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 + 3186 3196 /* we're joining the parent's domain, ensure its validity */ 3187 3197 if (!cgroup_is_valid_domain(dom_cgrp) || 3188 3198 !cgroup_can_be_thread_root(dom_cgrp))
+10 -5
kernel/sched/core.c
··· 6683 6683 parent_quota = parent_b->hierarchical_quota; 6684 6684 6685 6685 /* 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 6687 6688 * limit is set: 6688 6689 */ 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 + } 6693 6698 } 6694 6699 cfs_b->hierarchical_quota = quota; 6695 6700