Skip to content

Commit

Permalink
fork, IA64: Provide alloc_thread_stack_node() for IA64
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
Sebastian Andrzej Siewior authored and KAGA-KOKO committed Feb 22, 2022
1 parent 546c42b commit 2bb0529
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arch/ia64/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ struct thread_info {
#ifndef ASM_OFFSETS_C
/* how to get the thread information struct from C */
#define current_thread_info() ((struct thread_info *) ((char *) current + IA64_TASK_SIZE))
#define alloc_thread_stack_node(tsk, node) \
#define arch_alloc_thread_stack_node(tsk, node) \
((unsigned long *) ((char *) (tsk) + IA64_TASK_SIZE))
#define task_thread_info(tsk) ((struct thread_info *) ((char *) (tsk) + IA64_TASK_SIZE))
#else
#define current_thread_info() ((struct thread_info *) 0)
#define alloc_thread_stack_node(tsk, node) ((unsigned long *) 0)
#define arch_alloc_thread_stack_node(tsk, node) ((unsigned long *) 0)
#define task_thread_info(tsk) ((struct thread_info *) 0)
#endif
#define free_thread_stack(tsk) /* nothing */
#define arch_free_thread_stack(tsk) /* nothing */
#define task_stack_page(tsk) ((void *)(tsk))

#define __HAVE_THREAD_FUNCTIONS
Expand Down
17 changes: 17 additions & 0 deletions kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,23 @@ void thread_stack_cache_init(void)
}

# endif /* THREAD_SIZE >= PAGE_SIZE || defined(CONFIG_VMAP_STACK) */
#else /* CONFIG_ARCH_THREAD_STACK_ALLOCATOR */

static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node)
{
unsigned long *stack;

stack = arch_alloc_thread_stack_node(tsk, node);
tsk->stack = stack;
return stack;
}

static void free_thread_stack(struct task_struct *tsk)
{
arch_free_thread_stack(tsk);
tsk->stack = NULL;
}

#endif /* !CONFIG_ARCH_THREAD_STACK_ALLOCATOR */

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

0 comments on commit 2bb0529

Please sign in to comment.