From: Zhang Qiao zhangqiao22@huawei.com
hulk inclusion category: bugfix bugzilla: 186973, https://gitee.com/openeuler/kernel/issues/I5CA6K CVE: NA
--------------------------------
This reverts commit af98db5ff58f3657d68ac5f744de3c9ad69388ac. the patch af98db5ff58f("sched: Fix yet more sched_fork()") may be cause a process sleep at cgroup_post_fork()->freezer_fork() while taking group_threadgroup_rwsem lock long time, it cause a problem that other tasks will wait while fork child process and the system will stall.
Signed-off-by: Zhang Qiao zhangqiao22@huawei.com Reviewed-by: Chen Hui judy.chenhui@huawei.com Signed-off-by: Yongqiang Liu liuyongqiang13@huawei.com --- include/linux/sched/task.h | 2 +- kernel/fork.c | 12 +----------- kernel/sched/core.c | 6 +----- 3 files changed, 3 insertions(+), 17 deletions(-)
diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h index 1c2c099e393b..c8b52b3ec865 100644 --- a/include/linux/sched/task.h +++ b/include/linux/sched/task.h @@ -33,7 +33,7 @@ extern asmlinkage void schedule_tail(struct task_struct *prev); extern void init_idle(struct task_struct *idle, int cpu);
extern int sched_fork(unsigned long clone_flags, struct task_struct *p); -extern void sched_cgroup_fork(struct task_struct *p); +extern void sched_post_fork(struct task_struct *p); extern void sched_dead(struct task_struct *p);
void __noreturn do_task_dead(void); diff --git a/kernel/fork.c b/kernel/fork.c index 231b01eba6e1..88463fd56930 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2063,17 +2063,6 @@ static __latent_entropy struct task_struct *copy_process( if (retval) goto bad_fork_free_futex_mutex;
- /* - * Now that the cgroups are pinned, re-clone the parent cgroup and put - * the new task on the correct runqueue. All this *before* the task - * becomes visible. - * - * This isn't part of ->can_fork() because while the re-cloning is - * cgroup specific, it unconditionally needs to place the task on a - * runqueue. - */ - sched_cgroup_fork(p); - /* * From this point on we must avoid any synchronous user-space * communication until we take the tasklist-lock. In particular, we do @@ -2182,6 +2171,7 @@ static __latent_entropy struct task_struct *copy_process(
proc_fork_connector(p); cgroup_post_fork(p); + sched_post_fork(p); cgroup_threadgroup_change_end(current); perf_event_fork(p);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index b09153710259..496ce71f93a7 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2357,9 +2357,8 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p) return 0; }
-void sched_cgroup_fork(struct task_struct *p) +void sched_post_fork(struct task_struct *p) { - unsigned long flags;
/* @@ -2370,9 +2369,6 @@ void sched_cgroup_fork(struct task_struct *p) * Silence PROVE_RCU. */ raw_spin_lock_irqsave(&p->pi_lock, flags); -#ifdef CONFIG_CGROUP_SCHED - p->sched_task_group = task_group(current); - #endif rseq_migrate(p); /* * We're setting the CPU for the first time, we don't migrate,