sched/deadline: Create DL BW alloc, free & check overflow interface
authorDietmar Eggemann <dietmar.eggemann@arm.com>
Mon, 8 May 2023 07:58:53 +0000 (09:58 +0200)
committerTejun Heo <tj@kernel.org>
Mon, 8 May 2023 23:22:33 +0000 (13:22 -1000)
commit85989106feb734437e2d598b639991b9185a43a6
tree7b423289773fd6bb4c6c1396cada67ed78e2eb2e
parentc0f78fd5edcf29b2822ac165f9248a6c165e8554
sched/deadline: Create DL BW alloc, free & check overflow interface

While moving a set of tasks between exclusive cpusets,
cpuset_can_attach() -> task_can_attach() calls dl_cpu_busy(..., p) for
DL BW overflow checking and per-task DL BW allocation on the destination
root_domain for the DL tasks in this set.

This approach has the issue of not freeing already allocated DL BW in
the following error cases:

(1) The set of tasks includes multiple DL tasks and DL BW overflow
    checking fails for one of the subsequent DL tasks.

(2) Another controller next to the cpuset controller which is attached
    to the same cgroup fails in its can_attach().

To address this problem rework dl_cpu_busy():

(1) Split it into dl_bw_check_overflow() & dl_bw_alloc() and add a
    dedicated dl_bw_free().

(2) dl_bw_alloc() & dl_bw_free() take a `u64 dl_bw` parameter instead of
    a `struct task_struct *p` used in dl_cpu_busy(). This allows to
    allocate DL BW for a set of tasks too rather than only for a single
    task.

Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Juri Lelli <juri.lelli@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
include/linux/sched.h
kernel/sched/core.c
kernel/sched/deadline.c
kernel/sched/sched.h