From: Zhang Qiao zhangqiao22@huawei.com
hulk inclusion category: bugfix bugzilla: 186973, https://gitee.com/openeuler/kernel/issues/I5CA6K CVE: NA
--------------------------------
This reverts commit 74bd9b82dd7d3797be4b04f682dbdc7899ee3b23.
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 | 1 - kernel/fork.c | 1 - kernel/sched/core.c | 36 ++++++++++++++++-------------------- 3 files changed, 16 insertions(+), 22 deletions(-)
diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h index c8b52b3ec865..8b02ee42348b 100644 --- a/include/linux/sched/task.h +++ b/include/linux/sched/task.h @@ -33,7 +33,6 @@ 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_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 88463fd56930..7608869f4f1e 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2171,7 +2171,6 @@ 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 496ce71f93a7..36d7422da0ac 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2298,6 +2298,8 @@ static inline void init_schedstats(void) {} */ int sched_fork(unsigned long clone_flags, struct task_struct *p) { + unsigned long flags; + __sched_fork(clone_flags, p); /* * We mark the process as NEW here. This guarantees that @@ -2341,26 +2343,6 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
init_entity_runnable_average(&p->se);
-#ifdef CONFIG_SCHED_INFO - if (likely(sched_info_on())) - memset(&p->sched_info, 0, sizeof(p->sched_info)); -#endif -#if defined(CONFIG_SMP) - p->on_cpu = 0; -#endif - init_task_preempt_count(p); -#ifdef CONFIG_SMP - plist_node_init(&p->pushable_tasks, MAX_PRIO); - RB_CLEAR_NODE(&p->pushable_dl_tasks); -#endif - - return 0; -} - -void sched_post_fork(struct task_struct *p) -{ - unsigned long flags; - /* * The child is not yet in the pid-hash so no cgroup attach races, * and the cgroup is pinned to this child due to cgroup_fork() @@ -2378,6 +2360,20 @@ void sched_post_fork(struct task_struct *p) if (p->sched_class->task_fork) p->sched_class->task_fork(p); raw_spin_unlock_irqrestore(&p->pi_lock, flags); + +#ifdef CONFIG_SCHED_INFO + if (likely(sched_info_on())) + memset(&p->sched_info, 0, sizeof(p->sched_info)); +#endif +#if defined(CONFIG_SMP) + p->on_cpu = 0; +#endif + init_task_preempt_count(p); +#ifdef CONFIG_SMP + plist_node_init(&p->pushable_tasks, MAX_PRIO); + RB_CLEAR_NODE(&p->pushable_dl_tasks); +#endif + return 0; }
unsigned long to_ratio(u64 period, u64 runtime)