]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched/core: Swap the order between sched_post_fork() and cgroup_post_fork()
authorTejun Heo <tj@kernel.org>
Fri, 6 Mar 2026 17:58:02 +0000 (07:58 -1000)
committerTejun Heo <tj@kernel.org>
Fri, 6 Mar 2026 17:58:02 +0000 (07:58 -1000)
The planned sched_ext cgroup sub-scheduler support needs the newly forked
task to be associated with its cgroup in its post_fork() hook. There is no
existing ordering requirement between the two now. Swap them and note the
new ordering requirement.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Cc: Ingo Molnar <mingo@redhat.com>
kernel/fork.c

index 65113a304518ae73590704034513ba06e708928a..4759b6214df470e240269adbb7d989c9570dd7c0 100644 (file)
@@ -2463,8 +2463,12 @@ __latent_entropy struct task_struct *copy_process(
                fd_install(pidfd, pidfile);
 
        proc_fork_connector(p);
-       sched_post_fork(p);
+       /*
+        * sched_ext needs @p to be associated with its cgroup in its post_fork
+        * hook. cgroup_post_fork() should come before sched_post_fork().
+        */
        cgroup_post_fork(p, args);
+       sched_post_fork(p);
        perf_event_fork(p);
 
        trace_task_newtask(p, clone_flags);