Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
Merge tag 'init_task-20180117' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/dhowells/linux-fs

Pull init_task initializer cleanups from David Howells:
 "It doesn't seem useful to have the init_task in a header file rather
  than in a normal source file. We could consolidate init_task handling
  instead and expand out various macros.

  Here's a series of patches that consolidate init_task handling:

   (1) Make THREAD_SIZE available to vmlinux.lds for cris, hexagon and
       openrisc.

   (2) Alter the INIT_TASK_DATA linker script macro to set
       init_thread_union and init_stack rather than defining these in C.

       Insert init_task and init_thread_into into the init_stack area in
       the linker script as appropriate to the configuration, with
       different section markers so that they end up correctly ordered.

       We can then get merge ia64's init_task.c into the main one.

       We then have a bunch of single-use INIT_*() macros that seem only
       to be macros because they used to be used per-arch. We can then
       expand these in place of the user and get rid of a few lines and
       a lot of backslashes.

   (3) Expand INIT_TASK() in place.

   (4) Expand in place various small INIT_*() macros that are defined
       conditionally. Expand them and surround them by #if[n]def/#endif
       in the .c file as it takes fewer lines.

   (5) Expand INIT_SIGNALS() and INIT_SIGHAND() in place.

   (6) Expand INIT_STRUCT_PID in place.

  These macros can then be discarded"

* tag 'init_task-20180117' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs:
  Expand INIT_STRUCT_PID and remove
  Expand the INIT_SIGNALS and INIT_SIGHAND macros and remove
  Expand various INIT_* macros and remove
  Expand INIT_TASK() in init/init_task.c and remove
  Construct init thread stack in the linker script rather than by union
  openrisc: Make THREAD_SIZE available to vmlinux.lds
  hexagon: Make THREAD_SIZE available to vmlinux.lds
  cris: Make THREAD_SIZE available to vmlinux.lds
  • Loading branch information
torvalds committed Jan 29, 2018
2 parents d8a5b80 + e1e871a commit 49f9c35
Show file tree
Hide file tree
Showing 57 changed files with 230 additions and 431 deletions.
4 changes: 2 additions & 2 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ config ARCH_HAS_FORTIFY_SOURCE
config ARCH_HAS_SET_MEMORY
bool

# Select if arch init_task initializer is different to init/init_task.c
config ARCH_INIT_TASK
# Select if arch init_task must go in the __init_task_data section
config ARCH_TASK_STRUCT_ON_STACK
bool

# Select if arch has its private alloc_task_struct() function
Expand Down
3 changes: 0 additions & 3 deletions arch/alpha/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ struct thread_info {
.preempt_count = INIT_PREEMPT_COUNT, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* How to get the thread information struct from C. */
register struct thread_info *__current_thread_info __asm__("$8");
#define current_thread_info() __current_thread_info
Expand Down
3 changes: 0 additions & 3 deletions arch/arc/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

static inline __attribute_const__ struct thread_info *current_thread_info(void)
{
register unsigned long sp asm("sp");
Expand Down
3 changes: 0 additions & 3 deletions arch/arm/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/*
* how to get the current stack pointer in C
*/
Expand Down
2 changes: 0 additions & 2 deletions arch/arm64/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_stack (init_thread_union.stack)

#define thread_saved_pc(tsk) \
((unsigned long)(tsk->thread.cpu_context.pc))
#define thread_saved_sp(tsk) \
Expand Down
2 changes: 0 additions & 2 deletions arch/blackfin/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ struct thread_info {
.cpu = 0, \
.preempt_count = INIT_PREEMPT_COUNT, \
}
#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* Given a task stack pointer, you can find its corresponding
* thread_info structure just by masking it to the THREAD_SIZE
Expand Down
3 changes: 0 additions & 3 deletions arch/c6x/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* get the thread information struct of current task */
static inline __attribute__((const))
struct thread_info *current_thread_info(void)
Expand Down
9 changes: 0 additions & 9 deletions arch/cris/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ struct task_struct;
*/
#define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))

/* THREAD_SIZE is the size of the thread_info/kernel_stack combo.
* normally, the stack is found by doing something like p + THREAD_SIZE
* in CRIS, a page is 8192 bytes, which seems like a sane size
*/
#define THREAD_SIZE PAGE_SIZE
#define THREAD_SIZE_ORDER (0)

/*
* At user->kernel entry, the pt_regs struct is stacked on the top of the kernel-stack.
* This macro allows us to find those regs for a task.
Expand All @@ -59,8 +52,6 @@ static inline void release_thread(struct task_struct *dead_task)
/* Nothing needs to be done. */
}

#define init_stack (init_thread_union.stack)

#define cpu_relax() barrier()

void default_idle(void);
Expand Down
9 changes: 7 additions & 2 deletions arch/cris/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
#endif


/* THREAD_SIZE is the size of the thread_info/kernel_stack combo.
* normally, the stack is found by doing something like p + THREAD_SIZE
* in CRIS, a page is 8192 bytes, which seems like a sane size
*/
#define THREAD_SIZE PAGE_SIZE
#define THREAD_SIZE_ORDER (0)

/*
* low level task data that entry.S needs immediate access to
* - this struct should fit entirely inside of one cache line
Expand Down Expand Up @@ -56,8 +63,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)

#endif /* !__ASSEMBLY__ */

/*
Expand Down
1 change: 1 addition & 0 deletions arch/cris/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <asm-generic/vmlinux.lds.h>
#include <asm/page.h>
#include <asm/thread_info.h>

#ifdef CONFIG_ETRAX_VMEM_SIZE
#define __CONFIG_ETRAX_VMEM_SIZE CONFIG_ETRAX_VMEM_SIZE
Expand Down
3 changes: 0 additions & 3 deletions arch/frv/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the thread information struct from C */
register struct thread_info *__current_thread_info asm("gr15");

Expand Down
3 changes: 0 additions & 3 deletions arch/h8300/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the thread information struct from C */
static inline struct thread_info *current_thread_info(void)
{
Expand Down
3 changes: 0 additions & 3 deletions arch/hexagon/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ struct thread_info {
.regs = NULL, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* Tacky preprocessor trickery */
#define qqstr(s) qstr(s)
#define qstr(s) #s
Expand Down
2 changes: 2 additions & 0 deletions arch/hexagon/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <asm/asm-offsets.h> /* Most of the kernel defines are here */
#include <asm/mem-layout.h> /* except for page_offset */
#include <asm/cache.h> /* and now we're pulling cache line size */
#include <asm/thread_info.h> /* and we need THREAD_SIZE too */

OUTPUT_ARCH(hexagon)
ENTRY(stext)

Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ config IA64
select ARCH_HAVE_NMI_SAFE_CMPXCHG
select GENERIC_IOMAP
select GENERIC_SMP_IDLE_THREAD
select ARCH_INIT_TASK
select ARCH_TASK_STRUCT_ON_STACK
select ARCH_TASK_STRUCT_ALLOCATOR
select ARCH_THREAD_STACK_ALLOCATOR
select ARCH_CLOCKSOURCE_DATA
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $(error Sorry, you need a newer version of the assember, one that is built from
endif

KBUILD_CFLAGS += $(cflags-y)
head-y := arch/ia64/kernel/head.o arch/ia64/kernel/init_task.o
head-y := arch/ia64/kernel/head.o

libs-y += arch/ia64/lib/
core-y += arch/ia64/kernel/ arch/ia64/mm/
Expand Down
4 changes: 2 additions & 2 deletions arch/ia64/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <asm/processor.h>
#include <asm/ptrace.h>

#define THREAD_SIZE KERNEL_STACK_SIZE

#ifndef __ASSEMBLY__

/*
Expand Down Expand Up @@ -41,8 +43,6 @@ struct thread_info {
#endif
};

#define THREAD_SIZE KERNEL_STACK_SIZE

#define INIT_THREAD_INFO(tsk) \
{ \
.task = &tsk, \
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ifdef CONFIG_DYNAMIC_FTRACE
CFLAGS_REMOVE_ftrace.o = -pg
endif

extra-y := head.o init_task.o vmlinux.lds
extra-y := head.o vmlinux.lds

obj-y := entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o irq_ia64.o \
irq_lsapic.o ivt.o machvec.o pal.o patch.o process.o perfmon.o ptrace.o sal.o \
Expand Down
44 changes: 0 additions & 44 deletions arch/ia64/kernel/init_task.c

This file was deleted.

1 change: 1 addition & 0 deletions arch/ia64/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <asm/cache.h>
#include <asm/ptrace.h>
#include <asm/pgtable.h>
#include <asm/thread_info.h>

#include <asm-generic/vmlinux.lds.h>

Expand Down
3 changes: 0 additions & 3 deletions arch/m32r/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the thread information struct from C */
static inline struct thread_info *current_thread_info(void)
{
Expand Down
4 changes: 0 additions & 4 deletions arch/m68k/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ struct thread_info {
.preempt_count = INIT_PREEMPT_COUNT, \
}

#define init_stack (init_thread_union.stack)

#ifndef __ASSEMBLY__
/* how to get the thread information struct from C */
static inline struct thread_info *current_thread_info(void)
Expand All @@ -58,8 +56,6 @@ static inline struct thread_info *current_thread_info(void)
}
#endif

#define init_thread_info (init_thread_union.thread_info)

/* entry.S relies on these definitions!
* bits 0-7 are tested at every exception exit
* bits 8-15 are also tested at syscall exit
Expand Down
3 changes: 0 additions & 3 deletions arch/metag/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the current stack pointer from C */
register unsigned long current_stack_pointer asm("A0StP") __used;

Expand Down
3 changes: 0 additions & 3 deletions arch/microblaze/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the thread information struct from C */
static inline struct thread_info *current_thread_info(void)
{
Expand Down
3 changes: 0 additions & 3 deletions arch/mips/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* How to get the thread information struct from C. */
register struct thread_info *__current_thread_info __asm__("$28");

Expand Down
2 changes: 0 additions & 2 deletions arch/mn10300/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)
#define init_uregs \
((struct pt_regs *) \
((unsigned long) init_stack + THREAD_SIZE - sizeof(struct pt_regs)))
Expand Down
3 changes: 0 additions & 3 deletions arch/nios2/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the thread information struct from C */
static inline struct thread_info *current_thread_info(void)
{
Expand Down
2 changes: 0 additions & 2 deletions arch/openrisc/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp);
void release_thread(struct task_struct *);
unsigned long get_wchan(struct task_struct *p);

#define init_stack (init_thread_union.stack)

#define cpu_relax() barrier()

#endif /* __ASSEMBLY__ */
Expand Down
2 changes: 0 additions & 2 deletions arch/openrisc/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ struct thread_info {
.ksp = 0, \
}

#define init_thread_info (init_thread_union.thread_info)

/* how to get the thread information struct from C */
register struct thread_info *current_thread_info_reg asm("r10");
#define current_thread_info() (current_thread_info_reg)
Expand Down
1 change: 1 addition & 0 deletions arch/openrisc/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <asm/page.h>
#include <asm/cache.h>
#include <asm/thread_info.h>
#include <asm-generic/vmlinux.lds.h>

#ifdef __OR1K__
Expand Down
3 changes: 0 additions & 3 deletions arch/parisc/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ struct thread_info {
.preempt_count = INIT_PREEMPT_COUNT, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the thread information struct from C */
#define current_thread_info() ((struct thread_info *)mfctl(30))

Expand Down
3 changes: 0 additions & 3 deletions arch/powerpc/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ struct thread_info {
.flags = 0, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT)

/* how to get the thread information struct from C */
Expand Down
2 changes: 0 additions & 2 deletions arch/riscv/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_stack (init_thread_union.stack)

#endif /* !__ASSEMBLY__ */

/*
Expand Down
Loading

0 comments on commit 49f9c35

Please sign in to comment.