sched: Allow sched_cgroup_fork() to fail and introduce sched_cancel_fork()
authorTejun Heo <tj@kernel.org>
Tue, 18 Jun 2024 20:09:16 +0000 (10:09 -1000)
committerTejun Heo <tj@kernel.org>
Tue, 18 Jun 2024 20:09:16 +0000 (10:09 -1000)
commit304b3f2bc07ba7c74a1ebc7917a8f0549e6b8d54
tree582484f486f8bfb72c9d02c59f9fe5eb3e63b3bd
parentdf268382adc1f7aa3ad92f7de71b70395f24e4e7
sched: Allow sched_cgroup_fork() to fail and introduce sched_cancel_fork()

A new BPF extensible sched_class will need more control over the forking
process. It wants to be able to fail from sched_cgroup_fork() after the new
task's sched_task_group is initialized so that the loaded BPF program can
prepare the task with its cgroup association is established and reject fork
if e.g. allocation fails.

Allow sched_cgroup_fork() to fail by making it return int instead of void
and adding sched_cancel_fork() to undo sched_fork() in the error path.

sched_cgroup_fork() doesn't fail yet and this patch shouldn't cause any
behavior changes.

v2: Patch description updated to detail the expected use.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: David Vernet <dvernet@meta.com>
Acked-by: Josh Don <joshdon@google.com>
Acked-by: Hao Luo <haoluo@google.com>
Acked-by: Barret Rhoden <brho@google.com>
include/linux/sched/task.h
kernel/fork.c
kernel/sched/core.c