Skip to content

Commit 2bb0529

Browse files
Sebastian Andrzej SiewiorKAGA-KOKO
authored andcommitted
fork, IA64: Provide alloc_thread_stack_node() for IA64
Provide a generic alloc_thread_stack_node() for IA64 and CONFIG_ARCH_THREAD_STACK_ALLOCATOR which returns stack pointer and sets task_struct::stack so it behaves exactly like the other implementations. Rename IA64's alloc_thread_stack_node() and add the generic version to the fork code so it is in one place _and_ to drastically lower the chances of fat fingering the IA64 code. Do the same for free_thread_stack(). Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Andy Lutomirski <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 546c42b commit 2bb0529

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

arch/ia64/include/asm/thread_info.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ struct thread_info {
5555
#ifndef ASM_OFFSETS_C
5656
/* how to get the thread information struct from C */
5757
#define current_thread_info() ((struct thread_info *) ((char *) current + IA64_TASK_SIZE))
58-
#define alloc_thread_stack_node(tsk, node) \
58+
#define arch_alloc_thread_stack_node(tsk, node) \
5959
((unsigned long *) ((char *) (tsk) + IA64_TASK_SIZE))
6060
#define task_thread_info(tsk) ((struct thread_info *) ((char *) (tsk) + IA64_TASK_SIZE))
6161
#else
6262
#define current_thread_info() ((struct thread_info *) 0)
63-
#define alloc_thread_stack_node(tsk, node) ((unsigned long *) 0)
63+
#define arch_alloc_thread_stack_node(tsk, node) ((unsigned long *) 0)
6464
#define task_thread_info(tsk) ((struct thread_info *) 0)
6565
#endif
66-
#define free_thread_stack(tsk) /* nothing */
66+
#define arch_free_thread_stack(tsk) /* nothing */
6767
#define task_stack_page(tsk) ((void *)(tsk))
6868

6969
#define __HAVE_THREAD_FUNCTIONS

kernel/fork.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,23 @@ void thread_stack_cache_init(void)
330330
}
331331

332332
# endif /* THREAD_SIZE >= PAGE_SIZE || defined(CONFIG_VMAP_STACK) */
333+
#else /* CONFIG_ARCH_THREAD_STACK_ALLOCATOR */
334+
335+
static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node)
336+
{
337+
unsigned long *stack;
338+
339+
stack = arch_alloc_thread_stack_node(tsk, node);
340+
tsk->stack = stack;
341+
return stack;
342+
}
343+
344+
static void free_thread_stack(struct task_struct *tsk)
345+
{
346+
arch_free_thread_stack(tsk);
347+
tsk->stack = NULL;
348+
}
349+
333350
#endif /* !CONFIG_ARCH_THREAD_STACK_ALLOCATOR */
334351

335352
/* SLAB cache for signal_struct structures (tsk->signal) */

0 commit comments

Comments
 (0)