[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211118143452.136421-3-bigeasy@linutronix.de>
Date: Thu, 18 Nov 2021 15:34:46 +0100
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: linux-kernel@...r.kernel.org, linux-ia64@...r.kernel.org
Cc: Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Andy Lutomirski <luto@...nel.org>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Subject: [PATCH 2/8] kernel/fork: Duplicate task_struct before stack allocation.
alloc_thread_stack_node() already populates the task_struct::stack
member except on IA64. The stack pointer is saved and populated again
because IA64 needs it and arch_dup_task_struct() overwrites it.
Allocate thread's stack after task_struct has been duplicated as a
preparation.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
---
kernel/fork.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/kernel/fork.c b/kernel/fork.c
index bb3f2980f94fb..ce320d4b8e1f4 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -887,6 +887,10 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
if (!tsk)
return NULL;
+ err = arch_dup_task_struct(tsk, orig);
+ if (err)
+ goto free_tsk;
+
stack = alloc_thread_stack_node(tsk, node);
if (!stack)
goto free_tsk;
@@ -896,8 +900,6 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
stack_vm_area = task_stack_vm_area(tsk);
- err = arch_dup_task_struct(tsk, orig);
-
/*
* arch_dup_task_struct() clobbers the stack-related fields. Make
* sure they're properly initialized before using any stack-related
@@ -911,9 +913,6 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
refcount_set(&tsk->stack_refcount, 1);
#endif
- if (err)
- goto free_stack;
-
err = scs_prepare(tsk, node);
if (err)
goto free_stack;
--
2.33.1
Powered by blists - more mailing lists