Skip to content

Commit c53593e

Browse files
committed
sched, cgroup: Don't reject lower cpu.max on ancestors
While adding cgroup2 interface for the cpu controller, 0d59363 ("sched: Implement interface for cgroup unified hierarchy") forgot to update input validation and left it to reject cpu.max config if any descendant has set a higher value. cgroup2 officially supports delegation and a descendant must not be able to restrict what its ancestors can configure. For absolute limits such as cpu.max and memory.max, this means that the config at each level should only act as the upper limit at that level and shouldn't interfere with what other cgroups can configure. This patch updates config validation on cgroup2 so that the cpu controller follows the same convention. Signed-off-by: Tejun Heo <[email protected]> Fixes: 0d59363 ("sched: Implement interface for cgroup unified hierarchy") Acked-by: Peter Zijlstra (Intel) <[email protected]> Cc: [email protected] # v4.15+
1 parent 7928b2c commit c53593e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

kernel/sched/core.c

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

66806680
/*
6681-
* Ensure max(child_quota) <= parent_quota, inherit when no
6681+
* Ensure max(child_quota) <= parent_quota. On cgroup2,
6682+
* always take the min. On cgroup1, only inherit when no
66826683
* limit is set:
66836684
*/
6684-
if (quota == RUNTIME_INF)
6685-
quota = parent_quota;
6686-
else if (parent_quota != RUNTIME_INF && quota > parent_quota)
6687-
return -EINVAL;
6685+
if (cgroup_subsys_on_dfl(cpu_cgrp_subsys)) {
6686+
quota = min(quota, parent_quota);
6687+
} else {
6688+
if (quota == RUNTIME_INF)
6689+
quota = parent_quota;
6690+
else if (parent_quota != RUNTIME_INF && quota > parent_quota)
6691+
return -EINVAL;
6692+
}
66886693
}
66896694
cfs_b->hierarchical_quota = quota;
66906695

0 commit comments

Comments
 (0)