From: He Sheng hesheng@wxiat.com
Sunway inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5GF7A
--------------------------------
The thread_struct has been copied in dup_task_struct() by generic arch_dup_task_struct(), and it's unnecessary to be copied again in copy_thread(). This patch adds arch-specific implementation of arch_dup_task_struct() to reduce data copying.
It does not have to save fpu state for a kernel thread, so call fpstate_save() instead of __fpstate_save() here to save fpu state on demand.
Signed-off-by: He Sheng hesheng@wxiat.com
Signed-off-by: Gu Zitao guzitao@wxiat.com --- arch/sw_64/kernel/process.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/sw_64/kernel/process.c b/arch/sw_64/kernel/process.c index 1f093c5a5235..6b5f0f3a8345 100644 --- a/arch/sw_64/kernel/process.c +++ b/arch/sw_64/kernel/process.c @@ -144,6 +144,13 @@ release_thread(struct task_struct *dead_task) { }
+int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) +{ + fpstate_save(src); + *dst = *src; + return 0; +} + /* * Copy architecture-specific thread state */ @@ -162,8 +169,6 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
childti->pcb.ksp = (unsigned long) childregs; childti->pcb.flags = 7; /* set FEN, clear everything else */ - __fpstate_save(current); - p->thread = current->thread;
if (unlikely(p->flags & PF_KTHREAD)) { /* kernel thread */