aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-05-21 22:43:57 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-21 22:43:57 -0400
commitbf67f3a5c456a18f2e8d062f7e88506ef2cd9837 (patch)
tree2a2324b2572162059307db82f9238eeb25673a77
parent226da0dbc84ed97f448523e2a4cb91c27fa68ed9 (diff)
parent203dacbdca977bedaba61ad2fca75d934060a5d5 (diff)
Merge branch 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull smp hotplug cleanups from Thomas Gleixner: "This series is merily a cleanup of code copied around in arch/* and not changing any of the real cpu hotplug horrors yet. I wish I'd had something more substantial for 3.5, but I underestimated the lurking horror..." Fix up trivial conflicts in arch/{arm,sparc,x86}/Kconfig and arch/sparc/include/asm/thread_info_32.h * 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (79 commits) um: Remove leftover declaration of alloc_task_struct_node() task_allocator: Use config switches instead of magic defines sparc: Use common threadinfo allocator score: Use common threadinfo allocator sh-use-common-threadinfo-allocator mn10300: Use common threadinfo allocator powerpc: Use common threadinfo allocator mips: Use common threadinfo allocator hexagon: Use common threadinfo allocator m32r: Use common threadinfo allocator frv: Use common threadinfo allocator cris: Use common threadinfo allocator x86: Use common threadinfo allocator c6x: Use common threadinfo allocator fork: Provide kmemcache based thread_info allocator tile: Use common threadinfo allocator fork: Provide weak arch_release_[task_struct|thread_info] functions fork: Move thread info gfp flags to header fork: Remove the weak insanity sh: Remove cpu_idle_wait() ...
-rw-r--r--arch/Kconfig15
-rw-r--r--arch/alpha/Kconfig1
-rw-r--r--arch/alpha/kernel/Makefile2
-rw-r--r--arch/alpha/kernel/smp.c20
-rw-r--r--arch/arm/Kconfig4
-rw-r--r--arch/arm/Makefile2
-rw-r--r--arch/arm/include/asm/cpu.h1
-rw-r--r--arch/arm/include/asm/processor.h2
-rw-r--r--arch/arm/kernel/Makefile2
-rw-r--r--arch/arm/kernel/init_task.c37
-rw-r--r--arch/arm/kernel/process.c20
-rw-r--r--arch/arm/kernel/smp.c26
-rw-r--r--arch/avr32/kernel/Makefile2
-rw-r--r--arch/avr32/kernel/init_task.c31
-rw-r--r--arch/blackfin/Kconfig1
-rw-r--r--arch/blackfin/Makefile2
-rw-r--r--arch/blackfin/kernel/Makefile2
-rw-r--r--arch/blackfin/kernel/init_task.c32
-rw-r--r--arch/blackfin/mach-common/smp.c19
-rw-r--r--arch/c6x/include/asm/thread_info.h17
-rw-r--r--arch/c6x/kernel/process.c16
-rw-r--r--arch/cris/Kconfig1
-rw-r--r--arch/cris/arch-v32/kernel/smp.c14
-rw-r--r--arch/cris/include/asm/processor.h5
-rw-r--r--arch/cris/include/asm/thread_info.h6
-rw-r--r--arch/cris/kernel/process.c28
-rw-r--r--arch/frv/Makefile2
-rw-r--r--arch/frv/include/asm/thread_info.h15
-rw-r--r--arch/frv/kernel/Makefile2
-rw-r--r--arch/frv/kernel/init_task.c32
-rw-r--r--arch/frv/kernel/process.c15
-rw-r--r--arch/h8300/kernel/Makefile2
-rw-r--r--arch/h8300/kernel/init_task.c36
-rw-r--r--arch/hexagon/Kconfig1
-rw-r--r--arch/hexagon/Makefile3
-rw-r--r--arch/hexagon/include/asm/thread_info.h8
-rw-r--r--arch/hexagon/kernel/Makefile2
-rw-r--r--arch/hexagon/kernel/init_task.c54
-rw-r--r--arch/hexagon/kernel/process.c37
-rw-r--r--arch/hexagon/kernel/smp.c11
-rw-r--r--arch/ia64/Kconfig4
-rw-r--r--arch/ia64/include/asm/processor.h1
-rw-r--r--arch/ia64/include/asm/thread_info.h3
-rw-r--r--arch/ia64/kernel/process.c20
-rw-r--r--arch/ia64/kernel/smpboot.c63
-rw-r--r--arch/m32r/Makefile2
-rw-r--r--arch/m32r/include/asm/thread_info.h17
-rw-r--r--arch/m32r/kernel/Makefile2
-rw-r--r--arch/m32r/kernel/init_task.c34
-rw-r--r--arch/m32r/kernel/smpboot.c6
-rw-r--r--arch/m68k/kernel/Makefile2
-rw-r--r--arch/m68k/kernel/init_task.c35
-rw-r--r--arch/microblaze/kernel/Makefile2
-rw-r--r--arch/microblaze/kernel/init_task.c26
-rw-r--r--arch/mips/Kconfig1
-rw-r--r--arch/mips/Makefile2
-rw-r--r--arch/mips/include/asm/thread_info.h12
-rw-r--r--arch/mips/kernel/Makefile2
-rw-r--r--arch/mips/kernel/init_task.c35
-rw-r--r--arch/mips/kernel/smp.c56
-rw-r--r--arch/mn10300/Makefile2
-rw-r--r--arch/mn10300/include/asm/thread_info.h17
-rw-r--r--arch/mn10300/kernel/Makefile2
-rw-r--r--arch/mn10300/kernel/init_task.c39
-rw-r--r--arch/mn10300/kernel/kgdb.c3
-rw-r--r--arch/mn10300/kernel/smp.c2
-rw-r--r--arch/openrisc/Makefile2
-rw-r--r--arch/openrisc/kernel/Makefile2
-rw-r--r--arch/openrisc/kernel/init_task.c42
-rw-r--r--arch/parisc/Kconfig1
-rw-r--r--arch/parisc/Makefile2
-rw-r--r--arch/parisc/kernel/Makefile2
-rw-r--r--arch/parisc/kernel/init_task.c70
-rw-r--r--arch/parisc/kernel/smp.c25
-rw-r--r--arch/parisc/mm/init.c12
-rw-r--r--arch/powerpc/Kconfig5
-rw-r--r--arch/powerpc/include/asm/processor.h1
-rw-r--r--arch/powerpc/include/asm/thread_info.h13
-rw-r--r--arch/powerpc/kernel/Makefile2
-rw-r--r--arch/powerpc/kernel/idle.c23
-rw-r--r--arch/powerpc/kernel/init_task.c29
-rw-r--r--arch/powerpc/kernel/process.c31
-rw-r--r--arch/powerpc/kernel/smp.c76
-rw-r--r--arch/s390/Kconfig1
-rw-r--r--arch/s390/Makefile1
-rw-r--r--arch/s390/include/asm/smp.h2
-rw-r--r--arch/s390/kernel/Makefile2
-rw-r--r--arch/s390/kernel/init_task.c38
-rw-r--r--arch/s390/kernel/smp.c35
-rw-r--r--arch/score/include/asm/thread_info.h10
-rw-r--r--arch/score/kernel/Makefile2
-rw-r--r--arch/score/kernel/init_task.c46
-rw-r--r--arch/sh/Kconfig4
-rw-r--r--arch/sh/Makefile2
-rw-r--r--arch/sh/include/asm/processor.h5
-rw-r--r--arch/sh/include/asm/thread_info.h11
-rw-r--r--arch/sh/kernel/Makefile2
-rw-r--r--arch/sh/kernel/idle.c20
-rw-r--r--arch/sh/kernel/init_task.c30
-rw-r--r--arch/sh/kernel/process.c46
-rw-r--r--arch/sh/kernel/smp.c14
-rw-r--r--arch/sparc/Kconfig2
-rw-r--r--arch/sparc/Makefile1
-rw-r--r--arch/sparc/include/asm/leon.h5
-rw-r--r--arch/sparc/include/asm/thread_info_32.h2
-rw-r--r--arch/sparc/include/asm/thread_info_64.h25
-rw-r--r--arch/sparc/kernel/Makefile1
-rw-r--r--arch/sparc/kernel/init_task.c22
-rw-r--r--arch/sparc/kernel/leon_smp.c9
-rw-r--r--arch/sparc/kernel/smp_32.c12
-rw-r--r--arch/sparc/kernel/smp_64.c12
-rw-r--r--arch/sparc/kernel/sun4d_smp.c8
-rw-r--r--arch/sparc/kernel/sun4m_smp.c7
-rw-r--r--arch/tile/include/asm/thread_info.h6
-rw-r--r--arch/tile/kernel/Makefile2
-rw-r--r--arch/tile/kernel/init_task.c59
-rw-r--r--arch/tile/kernel/process.c23
-rw-r--r--arch/tile/kernel/setup.c16
-rw-r--r--arch/tile/kernel/smpboot.c2
-rw-r--r--arch/um/include/asm/processor-generic.h2
-rw-r--r--arch/um/kernel/Makefile2
-rw-r--r--arch/um/kernel/init_task.c38
-rw-r--r--arch/um/kernel/smp.c2
-rw-r--r--arch/um/kernel/um_arch.c5
-rw-r--r--arch/unicore32/Makefile1
-rw-r--r--arch/unicore32/kernel/Makefile2
-rw-r--r--arch/unicore32/kernel/init_task.c44
-rw-r--r--arch/x86/Kconfig4
-rw-r--r--arch/x86/Makefile1
-rw-r--r--arch/x86/include/asm/boot.h2
-rw-r--r--arch/x86/include/asm/page_32_types.h4
-rw-r--r--arch/x86/include/asm/page_64_types.h4
-rw-r--r--arch/x86/include/asm/processor.h2
-rw-r--r--arch/x86/include/asm/smp.h11
-rw-r--r--arch/x86/include/asm/thread_info.h21
-rw-r--r--arch/x86/kernel/Makefile2
-rw-r--r--arch/x86/kernel/apm_32.c2
-rw-r--r--arch/x86/kernel/init_task.c42
-rw-r--r--arch/x86/kernel/irq_32.c8
-rw-r--r--arch/x86/kernel/process.c34
-rw-r--r--arch/x86/kernel/smpboot.c83
-rw-r--r--arch/x86/xen/smp.c19
-rw-r--r--arch/xtensa/kernel/Makefile2
-rw-r--r--arch/xtensa/kernel/init_task.c31
-rw-r--r--drivers/cpuidle/cpuidle.c13
-rw-r--r--include/linux/smp.h6
-rw-r--r--include/linux/thread_info.h6
-rw-r--r--init/Makefile4
-rw-r--r--init/init_task.c (renamed from arch/alpha/kernel/init_task.c)17
-rw-r--r--kernel/Makefile1
-rw-r--r--kernel/cpu.c13
-rw-r--r--kernel/fork.c69
-rw-r--r--kernel/sched/Makefile2
-rw-r--r--kernel/sched/core.c2
-rw-r--r--kernel/smp.c27
-rw-r--r--kernel/smpboot.c62
-rw-r--r--kernel/smpboot.h18
157 files changed, 415 insertions, 1934 deletions
diff --git a/arch/Kconfig b/arch/Kconfig
index 684eb5af439d..bd265a217bd2 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -145,6 +145,21 @@ config HAVE_DMA_ATTRS
145config USE_GENERIC_SMP_HELPERS 145config USE_GENERIC_SMP_HELPERS
146 bool 146 bool
147 147
148config GENERIC_SMP_IDLE_THREAD
149 bool
150
151# Select if arch init_task initializer is different to init/init_task.c
152config ARCH_INIT_TASK
153 bool
154
155# Select if arch has its private alloc_task_struct() function
156config ARCH_TASK_STRUCT_ALLOCATOR
157 bool
158
159# Select if arch has its private alloc_thread_info() function
160config ARCH_THREAD_INFO_ALLOCATOR
161 bool
162
148config HAVE_REGS_AND_STACK_ACCESS_API 163config HAVE_REGS_AND_STACK_ACCESS_API
149 bool 164 bool
150 help 165 help
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 22e58a99f38b..0893f023efb8 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -15,6 +15,7 @@ config ALPHA
15 select GENERIC_IRQ_SHOW 15 select GENERIC_IRQ_SHOW
16 select ARCH_WANT_OPTIONAL_GPIOLIB 16 select ARCH_WANT_OPTIONAL_GPIOLIB
17 select ARCH_HAVE_NMI_SAFE_CMPXCHG 17 select ARCH_HAVE_NMI_SAFE_CMPXCHG
18 select GENERIC_SMP_IDLE_THREAD
18 help 19 help
19 The Alpha is a 64-bit general-purpose processor designed and 20 The Alpha is a 64-bit general-purpose processor designed and
20 marketed by the Digital Equipment Corporation of blessed memory, 21 marketed by the Digital Equipment Corporation of blessed memory,
diff --git a/arch/alpha/kernel/Makefile b/arch/alpha/kernel/Makefile
index 7a6d908bb865..84ec46b38f7d 100644
--- a/arch/alpha/kernel/Makefile
+++ b/arch/alpha/kernel/Makefile
@@ -6,7 +6,7 @@ extra-y := head.o vmlinux.lds
6asflags-y := $(KBUILD_CFLAGS) 6asflags-y := $(KBUILD_CFLAGS)
7ccflags-y := -Wno-sign-compare 7ccflags-y := -Wno-sign-compare
8 8
9obj-y := entry.o traps.o process.o init_task.o osf_sys.o irq.o \ 9obj-y := entry.o traps.o process.o osf_sys.o irq.o \
10 irq_alpha.o signal.o setup.o ptrace.o time.o \ 10 irq_alpha.o signal.o setup.o ptrace.o time.o \
11 alpha_ksyms.o systbls.o err_common.o io.o 11 alpha_ksyms.o systbls.o err_common.o io.o
12 12
diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index 50d438db1f6b..35ddc02bfa4a 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -357,24 +357,10 @@ secondary_cpu_start(int cpuid, struct task_struct *idle)
357 * Bring one cpu online. 357 * Bring one cpu online.
358 */ 358 */
359static int __cpuinit 359static int __cpuinit
360smp_boot_one_cpu(int cpuid) 360smp_boot_one_cpu(int cpuid, struct task_struct *idle)
361{ 361{
362 struct task_struct *idle;
363 unsigned long timeout; 362 unsigned long timeout;
364 363
365 /* Cook up an idler for this guy. Note that the address we
366 give to kernel_thread is irrelevant -- it's going to start
367 where HWRPB.CPU_restart says to start. But this gets all
368 the other task-y sort of data structures set up like we
369 wish. We can't use kernel_thread since we must avoid
370 rescheduling the child. */
371 idle = fork_idle(cpuid);
372 if (IS_ERR(idle))
373 panic("failed fork for CPU %d", cpuid);
374
375 DBGS(("smp_boot_one_cpu: CPU %d state 0x%lx flags 0x%lx\n",
376 cpuid, idle->state, idle->flags));
377
378 /* Signal the secondary to wait a moment. */ 364 /* Signal the secondary to wait a moment. */
379 smp_secondary_alive = -1; 365 smp_secondary_alive = -1;
380 366
@@ -487,9 +473,9 @@ smp_prepare_boot_cpu(void)
487} 473}
488 474
489int __cpuinit 475int __cpuinit
490__cpu_up(unsigned int cpu) 476__cpu_up(unsigned int cpu, struct task_struct *tidle)
491{ 477{
492 smp_boot_one_cpu(cpu); 478 smp_boot_one_cpu(cpu, tidle);
493 479
494 return cpu_online(cpu) ? 0 : -ENOSYS; 480 return cpu_online(cpu) ? 0 : -ENOSYS;
495} 481}
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 554ec1dd89d4..4305ae25652b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -37,6 +37,7 @@ config ARM
37 select CPU_PM if (SUSPEND || CPU_IDLE) 37 select CPU_PM if (SUSPEND || CPU_IDLE)
38 select GENERIC_PCI_IOMAP 38 select GENERIC_PCI_IOMAP
39 select HAVE_BPF_JIT 39 select HAVE_BPF_JIT
40 select GENERIC_SMP_IDLE_THREAD
40 help 41 help
41 The ARM series is a line of low-power-consumption RISC chip designs 42 The ARM series is a line of low-power-consumption RISC chip designs
42 licensed by ARM Ltd and targeted at embedded applications and 43 licensed by ARM Ltd and targeted at embedded applications and
@@ -154,9 +155,6 @@ config ARCH_HAS_CPUFREQ
154 and that the relevant menu configurations are displayed for 155 and that the relevant menu configurations are displayed for
155 it. 156 it.
156 157
157config ARCH_HAS_CPU_IDLE_WAIT
158 def_bool y
159
160config GENERIC_HWEIGHT 158config GENERIC_HWEIGHT
161 bool 159 bool
162 default y 160 default y
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index aaf96bccd4a0..3b18ef7ad278 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -117,7 +117,7 @@ KBUILD_AFLAGS +=$(CFLAGS_ABI) $(AFLAGS_THUMB2) $(arch-y) $(tune-y) -include asm/
117CHECKFLAGS += -D__arm__ 117CHECKFLAGS += -D__arm__
118 118
119#Default value 119#Default value
120head-y := arch/arm/kernel/head$(MMUEXT).o arch/arm/kernel/init_task.o 120head-y := arch/arm/kernel/head$(MMUEXT).o
121textofs-y := 0x00008000 121textofs-y := 0x00008000
122textofs-$(CONFIG_ARCH_CLPS711X) := 0x00028000 122textofs-$(CONFIG_ARCH_CLPS711X) := 0x00028000
123# We don't want the htc bootloader to corrupt kernel during resume 123# We don't want the htc bootloader to corrupt kernel during resume
diff --git a/arch/arm/include/asm/cpu.h b/arch/arm/include/asm/cpu.h
index 793968173bef..d797223b39d5 100644
--- a/arch/arm/include/asm/cpu.h
+++ b/arch/arm/include/asm/cpu.h
@@ -16,7 +16,6 @@
16struct cpuinfo_arm { 16struct cpuinfo_arm {
17 struct cpu cpu; 17 struct cpu cpu;
18#ifdef CONFIG_SMP 18#ifdef CONFIG_SMP
19 struct task_struct *idle;
20 unsigned int loops_per_jiffy; 19 unsigned int loops_per_jiffy;
21#endif 20#endif
22}; 21};
diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
index 5ac8d3d3e025..d7038fa22343 100644
--- a/arch/arm/include/asm/processor.h
+++ b/arch/arm/include/asm/processor.h
@@ -88,8 +88,6 @@ unsigned long get_wchan(struct task_struct *p);
88#define cpu_relax() barrier() 88#define cpu_relax() barrier()
89#endif 89#endif
90 90
91void cpu_idle_wait(void);
92
93/* 91/*
94 * Create a new kernel thread 92 * Create a new kernel thread
95 */ 93 */
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index 22b0f1e255f0..7ad2d5cf7008 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -82,4 +82,4 @@ head-y := head$(MMUEXT).o
82obj-$(CONFIG_DEBUG_LL) += debug.o 82obj-$(CONFIG_DEBUG_LL) += debug.o
83obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 83obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
84 84
85extra-y := $(head-y) init_task.o vmlinux.lds 85extra-y := $(head-y) vmlinux.lds
diff --git a/arch/arm/kernel/init_task.c b/arch/arm/kernel/init_task.c
deleted file mode 100644
index e7cbb50dc356..000000000000
--- a/arch/arm/kernel/init_task.c
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * linux/arch/arm/kernel/init_task.c
3 */
4#include <linux/mm.h>
5#include <linux/module.h>
6#include <linux/fs.h>
7#include <linux/sched.h>
8#include <linux/init.h>
9#include <linux/init_task.h>
10#include <linux/mqueue.h>
11#include <linux/uaccess.h>
12
13#include <asm/pgtable.h>
14
15static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
16static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
17/*
18 * Initial thread structure.
19 *
20 * We need to make sure that this is 8192-byte aligned due to the
21 * way process stacks are handled. This is done by making sure
22 * the linker maps this in the .text segment right after head.S,
23 * and making head.S ensure the proper alignment.
24 *
25 * The things we do for performance..
26 */
27union thread_union init_thread_union __init_task_data =
28 { INIT_THREAD_INFO(init_task) };
29
30/*
31 * Initial task structure.
32 *
33 * All other task structs will be allocated on slabs in fork.c
34 */
35struct task_struct init_task = INIT_TASK(init_task);
36
37EXPORT_SYMBOL(init_task);
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 2b7b017a20cd..19c95ea65b2f 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -157,26 +157,6 @@ EXPORT_SYMBOL(pm_power_off);
157void (*arm_pm_restart)(char str, const char *cmd) = null_restart; 157void (*arm_pm_restart)(char str, const char *cmd) = null_restart;
158EXPORT_SYMBOL_GPL(arm_pm_restart); 158EXPORT_SYMBOL_GPL(arm_pm_restart);
159 159
160static void do_nothing(void *unused)
161{
162}
163
164/*
165 * cpu_idle_wait - Used to ensure that all the CPUs discard old value of
166 * pm_idle and update to new pm_idle value. Required while changing pm_idle
167 * handler on SMP systems.
168 *
169 * Caller must have changed pm_idle to the new value before the call. Old
170 * pm_idle value will not be used by any CPU after the return of this function.
171 */
172void cpu_idle_wait(void)
173{
174 smp_mb();
175 /* kick all the CPUs so that they exit out of pm_idle */
176 smp_call_function(do_nothing, NULL, 1);
177}
178EXPORT_SYMBOL_GPL(cpu_idle_wait);
179
180/* 160/*
181 * This is our default idle handler. 161 * This is our default idle handler.
182 */ 162 */
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index cf58558ef4b9..b735521a4a54 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -60,32 +60,11 @@ enum ipi_msg_type {
60 60
61static DECLARE_COMPLETION(cpu_running); 61static DECLARE_COMPLETION(cpu_running);
62 62
63int __cpuinit __cpu_up(unsigned int cpu) 63int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)
64{ 64{
65 struct cpuinfo_arm *ci = &per_cpu(cpu_data, cpu);
66 struct task_struct *idle = ci->idle;
67 int ret; 65 int ret;
68 66
69 /* 67 /*
70 * Spawn a new process manually, if not already done.
71 * Grab a pointer to its task struct so we can mess with it
72 */
73 if (!idle) {
74 idle = fork_idle(cpu);
75 if (IS_ERR(idle)) {
76 printk(KERN_ERR "CPU%u: fork() failed\n", cpu);
77 return PTR_ERR(idle);
78 }
79 ci->idle = idle;
80 } else {
81 /*
82 * Since this idle thread is being re-used, call
83 * init_idle() to reinitialize the thread structure.
84 */
85 init_idle(idle, cpu);
86 }
87
88 /*
89 * We need to tell the secondary core where to find 68 * We need to tell the secondary core where to find
90 * its stack and the page tables. 69 * its stack and the page tables.
91 */ 70 */
@@ -318,9 +297,6 @@ void __init smp_cpus_done(unsigned int max_cpus)
318 297
319void __init smp_prepare_boot_cpu(void) 298void __init smp_prepare_boot_cpu(void)
320{ 299{
321 unsigned int cpu = smp_processor_id();
322
323 per_cpu(cpu_data, cpu).idle = current;
324} 300}
325 301
326void __init smp_prepare_cpus(unsigned int max_cpus) 302void __init smp_prepare_cpus(unsigned int max_cpus)
diff --git a/arch/avr32/kernel/Makefile b/arch/avr32/kernel/Makefile
index 18229d0d1861..9e2c465ef3a6 100644
--- a/arch/avr32/kernel/Makefile
+++ b/arch/avr32/kernel/Makefile
@@ -8,7 +8,7 @@ obj-$(CONFIG_SUBARCH_AVR32B) += entry-avr32b.o
8obj-y += syscall_table.o syscall-stubs.o irq.o 8obj-y += syscall_table.o syscall-stubs.o irq.o
9obj-y += setup.o traps.o ocd.o ptrace.o 9obj-y += setup.o traps.o ocd.o ptrace.o
10obj-y += signal.o sys_avr32.o process.o time.o 10obj-y += signal.o sys_avr32.o process.o time.o
11obj-y += init_task.o switch_to.o cpu.o 11obj-y += switch_to.o cpu.o
12obj-$(CONFIG_MODULES) += module.o avr32_ksyms.o 12obj-$(CONFIG_MODULES) += module.o avr32_ksyms.o
13obj-$(CONFIG_KPROBES) += kprobes.o 13obj-$(CONFIG_KPROBES) += kprobes.o
14obj-$(CONFIG_STACKTRACE) += stacktrace.o 14obj-$(CONFIG_STACKTRACE) += stacktrace.o
diff --git a/arch/avr32/kernel/init_task.c b/arch/avr32/kernel/init_task.c
deleted file mode 100644
index 6b2343e6fe33..000000000000
--- a/arch/avr32/kernel/init_task.c
+++ /dev/null
@@ -1,31 +0,0 @@
1/*
2 * Copyright (C) 2004-2006 Atmel Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8#include <linux/module.h>
9#include <linux/fs.h>
10#include <linux/sched.h>
11#include <linux/init_task.h>
12#include <linux/mqueue.h>
13
14#include <asm/pgtable.h>
15
16static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
17static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
18/*
19 * Initial thread structure. Must be aligned on an 8192-byte boundary.
20 */
21union thread_union init_thread_union __init_task_data =
22 { INIT_THREAD_INFO(init_task) };
23
24/*
25 * Initial task structure.
26 *
27 * All other task structs will be allocated on slabs in fork.c
28 */
29struct task_struct init_task = INIT_TASK(init_task);
30
31EXPORT_SYMBOL(init_task);
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index 383e7ecda923..7f3c589cc024 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -37,6 +37,7 @@ config BLACKFIN
37 select GENERIC_IRQ_PROBE 37 select GENERIC_IRQ_PROBE
38 select IRQ_PER_CPU if SMP 38 select IRQ_PER_CPU if SMP
39 select HAVE_NMI_WATCHDOG if NMI_WATCHDOG 39 select HAVE_NMI_WATCHDOG if NMI_WATCHDOG
40 select GENERIC_SMP_IDLE_THREAD
40 41
41config GENERIC_CSUM 42config GENERIC_CSUM
42 def_bool y 43 def_bool y
diff --git a/arch/blackfin/Makefile b/arch/blackfin/Makefile
index 74fdf679da01..d3d7e64ca96d 100644
--- a/arch/blackfin/Makefile
+++ b/arch/blackfin/Makefile
@@ -109,8 +109,6 @@ KBUILD_AFLAGS += -mcpu=$(CPU_REV)
109CHECKFLAGS_SILICON = $(shell echo "" | $(CPP) $(KBUILD_CFLAGS) -dD - 2>/dev/null | awk '$$2 == "__SILICON_REVISION__" { print $$3 }') 109CHECKFLAGS_SILICON = $(shell echo "" | $(CPP) $(KBUILD_CFLAGS) -dD - 2>/dev/null | awk '$$2 == "__SILICON_REVISION__" { print $$3 }')
110CHECKFLAGS += -D__SILICON_REVISION__=$(CHECKFLAGS_SILICON) -D__bfin__ 110CHECKFLAGS += -D__SILICON_REVISION__=$(CHECKFLAGS_SILICON) -D__bfin__
111 111
112head-y := arch/$(ARCH)/kernel/init_task.o
113
114core-y += arch/$(ARCH)/kernel/ arch/$(ARCH)/mm/ arch/$(ARCH)/mach-common/ 112core-y += arch/$(ARCH)/kernel/ arch/$(ARCH)/mm/ arch/$(ARCH)/mach-common/
115 113
116# If we have a machine-specific directory, then include it in the build. 114# If we have a machine-specific directory, then include it in the build.
diff --git a/arch/blackfin/kernel/Makefile b/arch/blackfin/kernel/Makefile
index 9a0d6d706443..08e6625106be 100644
--- a/arch/blackfin/kernel/Makefile
+++ b/arch/blackfin/kernel/Makefile
@@ -2,7 +2,7 @@
2# arch/blackfin/kernel/Makefile 2# arch/blackfin/kernel/Makefile
3# 3#
4 4
5extra-y := init_task.o vmlinux.lds 5extra-y := vmlinux.lds
6 6
7obj-y := \ 7obj-y := \
8 entry.o process.o bfin_ksyms.o ptrace.o setup.o signal.o \ 8 entry.o process.o bfin_ksyms.o ptrace.o setup.o signal.o \
diff --git a/arch/blackfin/kernel/init_task.c b/arch/blackfin/kernel/init_task.c
deleted file mode 100644
index d3970e8acd1a..000000000000
--- a/arch/blackfin/kernel/init_task.c
+++ /dev/null
@@ -1,32 +0,0 @@
1/*
2 * Copyright 2004-2009 Analog Devices Inc.
3 *
4 * Licensed under the GPL-2 or later
5 */
6
7#include <linux/mm.h>
8#include <linux/module.h>
9#include <linux/init_task.h>
10#include <linux/mqueue.h>
11#include <linux/fs.h>
12
13static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
14static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
15/*
16 * Initial task structure.
17 *
18 * All other task structs will be allocated on slabs in fork.c
19 */
20struct task_struct init_task = INIT_TASK(init_task);
21EXPORT_SYMBOL(init_task);
22
23/*
24 * Initial thread structure.
25 *
26 * We need to make sure that this is 8192-byte aligned due to the
27 * way process stacks are handled. This is done by having a special
28 * "init_task" linker map entry.
29 */
30union thread_union init_thread_union
31 __init_task_data = {
32INIT_THREAD_INFO(init_task)};
diff --git a/arch/blackfin/mach-common/smp.c b/arch/blackfin/mach-common/smp.c
index ac8f8a43158c..00bbe672b3b3 100644
--- a/arch/blackfin/mach-common/smp.c
+++ b/arch/blackfin/mach-common/smp.c
@@ -340,27 +340,10 @@ void smp_send_stop(void)
340 return; 340 return;
341} 341}
342 342
343int __cpuinit __cpu_up(unsigned int cpu) 343int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)
344{ 344{
345 int ret; 345 int ret;
346 struct blackfin_cpudata *ci = &per_cpu(cpu_data, cpu);
347 struct task_struct *idle = ci->idle;
348 346
349 if (idle) {
350 free_task(idle);
351 idle = NULL;
352 }
353
354 if (!idle) {
355 idle = fork_idle(cpu);
356 if (IS_ERR(idle)) {
357 printk(KERN_ERR "CPU%u: fork() failed\n", cpu);
358 return PTR_ERR(idle);
359 }
360 ci->idle = idle;
361 } else {
362 init_idle(idle, cpu);
363 }
364 secondary_stack = task_stack_page(idle) + THREAD_SIZE; 347 secondary_stack = task_stack_page(idle) + THREAD_SIZE;
365 348
366 ret = platform_boot_secondary(cpu, idle); 349 ret = platform_boot_secondary(cpu, idle);
diff --git a/arch/c6x/include/asm/thread_info.h b/arch/c6x/include/asm/thread_info.h
index fd99148cda9d..1710bcbb8d09 100644
--- a/arch/c6x/include/asm/thread_info.h
+++ b/arch/c6x/include/asm/thread_info.h
@@ -20,11 +20,11 @@
20#ifdef CONFIG_4KSTACKS 20#ifdef CONFIG_4KSTACKS
21#define THREAD_SIZE 4096 21#define THREAD_SIZE 4096
22#define THREAD_SHIFT 12 22#define THREAD_SHIFT 12
23#define THREAD_ORDER 0 23#define THREAD_SIZE_ORDER 0
24#else 24#else
25#define THREAD_SIZE 8192 25#define THREAD_SIZE 8192
26#define THREAD_SHIFT 13 26#define THREAD_SHIFT 13
27#define THREAD_ORDER 1 27#define THREAD_SIZE_ORDER 1
28#endif 28#endif
29 29
30#define THREAD_START_SP (THREAD_SIZE - 8) 30#define THREAD_START_SP (THREAD_SIZE - 8)
@@ -80,19 +80,6 @@ struct thread_info *current_thread_info(void)
80 return ti; 80 return ti;
81} 81}
82 82
83#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
84
85/* thread information allocation */
86#ifdef CONFIG_DEBUG_STACK_USAGE
87#define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO)
88#else
89#define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK)
90#endif
91
92#define alloc_thread_info_node(tsk, node) \
93 ((struct thread_info *)__get_free_pages(THREAD_FLAGS, THREAD_ORDER))
94
95#define free_thread_info(ti) free_pages((unsigned long) (ti), THREAD_ORDER)
96#define get_thread_info(ti) get_task_struct((ti)->task) 83#define get_thread_info(ti) get_task_struct((ti)->task)
97#define put_thread_info(ti) put_task_struct((ti)->task) 84#define put_thread_info(ti) put_task_struct((ti)->task)
98#endif /* __ASSEMBLY__ */ 85#endif /* __ASSEMBLY__ */
diff --git a/arch/c6x/kernel/process.c b/arch/c6x/kernel/process.c
index 7ca8c41b03cd..45e924a636a0 100644
--- a/arch/c6x/kernel/process.c
+++ b/arch/c6x/kernel/process.c
@@ -26,22 +26,6 @@ void (*c6x_halt)(void);
26 26
27extern asmlinkage void ret_from_fork(void); 27extern asmlinkage void ret_from_fork(void);
28 28
29static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
30static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
31
32/*
33 * Initial thread structure.
34 */
35union thread_union init_thread_union __init_task_data = {
36 INIT_THREAD_INFO(init_task)
37};
38
39/*
40 * Initial task structure.
41 */
42struct task_struct init_task = INIT_TASK(init_task);
43EXPORT_SYMBOL(init_task);
44
45/* 29/*
46 * power off function, if any 30 * power off function, if any
47 */ 31 */
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig
index b3abfb08aa5c..2995035812ec 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -49,6 +49,7 @@ config CRIS
49 select HAVE_GENERIC_HARDIRQS 49 select HAVE_GENERIC_HARDIRQS
50 select GENERIC_IRQ_SHOW 50 select GENERIC_IRQ_SHOW
51 select GENERIC_IOMAP 51 select GENERIC_IOMAP
52 select GENERIC_SMP_IDLE_THREAD if ETRAX_ARCH_V32
52 53
53config HZ 54config HZ
54 int 55 int
diff --git a/arch/cris/arch-v32/kernel/smp.c b/arch/cris/arch-v32/kernel/smp.c
index 0b99df72d2a4..ebe2cb30bd11 100644
--- a/arch/cris/arch-v32/kernel/smp.c
+++ b/arch/cris/arch-v32/kernel/smp.c
@@ -108,17 +108,12 @@ void __init smp_cpus_done(unsigned int max_cpus)
108 108
109/* Bring one cpu online.*/ 109/* Bring one cpu online.*/
110static int __init 110static int __init
111smp_boot_one_cpu(int cpuid) 111smp_boot_one_cpu(int cpuid, struct task_struct idle)
112{ 112{
113 unsigned timeout; 113 unsigned timeout;
114 struct task_struct *idle;
115 cpumask_t cpu_mask; 114 cpumask_t cpu_mask;
116 115
117 cpumask_clear(&cpu_mask); 116 cpumask_clear(&cpu_mask);
118 idle = fork_idle(cpuid);
119 if (IS_ERR(idle))
120 panic("SMP: fork failed for CPU:%d", cpuid);
121
122 task_thread_info(idle)->cpu = cpuid; 117 task_thread_info(idle)->cpu = cpuid;
123 118
124 /* Information to the CPU that is about to boot */ 119 /* Information to the CPU that is about to boot */
@@ -142,9 +137,6 @@ smp_boot_one_cpu(int cpuid)
142 barrier(); 137 barrier();
143 } 138 }
144 139
145 put_task_struct(idle);
146 idle = NULL;
147
148 printk(KERN_CRIT "SMP: CPU:%d is stuck.\n", cpuid); 140 printk(KERN_CRIT "SMP: CPU:%d is stuck.\n", cpuid);
149 return -1; 141 return -1;
150} 142}
@@ -207,9 +199,9 @@ int setup_profiling_timer(unsigned int multiplier)
207 */ 199 */
208unsigned long cache_decay_ticks = 1; 200unsigned long cache_decay_ticks = 1;
209 201
210int __cpuinit __cpu_up(unsigned int cpu) 202int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
211{ 203{
212 smp_boot_one_cpu(cpu); 204 smp_boot_one_cpu(cpu, tidle);
213 return cpu_online(cpu) ? 0 : -ENOSYS; 205 return cpu_online(cpu) ? 0 : -ENOSYS;
214} 206}
215 207
diff --git a/arch/cris/include/asm/processor.h b/arch/cris/include/asm/processor.h
index 4210d72a6667..8dc56ef08712 100644
--- a/arch/cris/include/asm/processor.h
+++ b/arch/cris/include/asm/processor.h
@@ -25,13 +25,12 @@ struct task_struct;
25 */ 25 */
26#define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3)) 26#define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
27 27
28/* THREAD_SIZE is the size of the task_struct/kernel_stack combo. 28/* THREAD_SIZE is the size of the thread_info/kernel_stack combo.
29 * normally, the stack is found by doing something like p + THREAD_SIZE 29 * normally, the stack is found by doing something like p + THREAD_SIZE
30 * in CRIS, a page is 8192 bytes, which seems like a sane size 30 * in CRIS, a page is 8192 bytes, which seems like a sane size
31 */ 31 */
32
33#define THREAD_SIZE PAGE_SIZE 32#define THREAD_SIZE PAGE_SIZE
34#define KERNEL_STACK_SIZE PAGE_SIZE 33#define THREAD_SIZE_ORDER (0)
35 34
36/* 35/*
37 * At user->kernel entry, the pt_regs struct is stacked on the top of the kernel-stack. 36 * At user->kernel entry, the pt_regs struct is stacked on the top of the kernel-stack.
diff --git a/arch/cris/include/asm/thread_info.h b/arch/cris/include/asm/thread_info.h
index 29b92884d793..5b1c448df5c0 100644
--- a/arch/cris/include/asm/thread_info.h
+++ b/arch/cris/include/asm/thread_info.h
@@ -65,12 +65,6 @@ struct thread_info {
65 65
66#define init_thread_info (init_thread_union.thread_info) 66#define init_thread_info (init_thread_union.thread_info)
67 67
68#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
69/* thread information allocation */
70#define alloc_thread_info_node(tsk, node) \
71 ((struct thread_info *) __get_free_pages(GFP_KERNEL, 1))
72#define free_thread_info(ti) free_pages((unsigned long) (ti), 1)
73
74#endif /* !__ASSEMBLY__ */ 68#endif /* !__ASSEMBLY__ */
75 69
76/* 70/*
diff --git a/arch/cris/kernel/process.c b/arch/cris/kernel/process.c
index 891dad85e8bd..66fd01728790 100644
--- a/arch/cris/kernel/process.c
+++ b/arch/cris/kernel/process.c
@@ -29,34 +29,6 @@
29//#define DEBUG 29//#define DEBUG
30 30
31/* 31/*
32 * Initial task structure. Make this a per-architecture thing,
33 * because different architectures tend to have different
34 * alignment requirements and potentially different initial
35 * setup.
36 */
37
38static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
39static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
40/*
41 * Initial thread structure.
42 *
43 * We need to make sure that this is 8192-byte aligned due to the
44 * way process stacks are handled. This is done by having a special
45 * "init_task" linker map entry..
46 */
47union thread_union init_thread_union __init_task_data =
48 { INIT_THREAD_INFO(init_task) };
49
50/*
51 * Initial task structure.
52 *
53 * All other task structs will be allocated on slabs in fork.c
54 */
55struct task_struct init_task = INIT_TASK(init_task);
56
57EXPORT_SYMBOL(init_task);
58
59/*
60 * The hlt_counter, disable_hlt and enable_hlt is just here as a hook if 32 * The hlt_counter, disable_hlt and enable_hlt is just here as a hook if
61 * there would ever be a halt sequence (for power save when idle) with 33 * there would ever be a halt sequence (for power save when idle) with
62 * some largish delay when halting or resuming *and* a driver that can't 34 * some largish delay when halting or resuming *and* a driver that can't
diff --git a/arch/frv/Makefile b/arch/frv/Makefile
index 7ff84575b186..4d1b1e9baef1 100644
--- a/arch/frv/Makefile
+++ b/arch/frv/Makefile
@@ -81,7 +81,7 @@ ifdef CONFIG_DEBUG_INFO
81KBUILD_AFLAGS += -Wa,--gdwarf2 81KBUILD_AFLAGS += -Wa,--gdwarf2
82endif 82endif
83 83
84head-y := arch/frv/kernel/head.o arch/frv/kernel/init_task.o 84head-y := arch/frv/kernel/head.o
85 85
86core-y += arch/frv/kernel/ arch/frv/mm/ 86core-y += arch/frv/kernel/ arch/frv/mm/
87libs-y += arch/frv/lib/ 87libs-y += arch/frv/lib/
diff --git a/arch/frv/include/asm/thread_info.h b/arch/frv/include/asm/thread_info.h
index 92d83ea99ae5..54ab13a0de41 100644
--- a/arch/frv/include/asm/thread_info.h
+++ b/arch/frv/include/asm/thread_info.h
@@ -21,8 +21,6 @@
21 21
22#define THREAD_SIZE 8192 22#define THREAD_SIZE 8192
23 23
24#define __HAVE_ARCH_TASK_STRUCT_ALLOCATOR
25
26/* 24/*
27 * low level task data that entry.S needs immediate access to 25 * low level task data that entry.S needs immediate access to
28 * - this struct should fit entirely inside of one cache line 26 * - this struct should fit entirely inside of one cache line
@@ -82,19 +80,6 @@ register struct thread_info *__current_thread_info asm("gr15");
82 80
83#define current_thread_info() ({ __current_thread_info; }) 81#define current_thread_info() ({ __current_thread_info; })
84 82
85#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
86
87/* thread information allocation */
88#ifdef CONFIG_DEBUG_STACK_USAGE
89#define alloc_thread_info_node(tsk, node) \
90 kzalloc_node(THREAD_SIZE, GFP_KERNEL, node)
91#else
92#define alloc_thread_info_node(tsk, node) \
93 kmalloc_node(THREAD_SIZE, GFP_KERNEL, node)
94#endif
95
96#define free_thread_info(info) kfree(info)
97
98#endif /* __ASSEMBLY__ */ 83#endif /* __ASSEMBLY__ */
99 84
100/* 85/*
diff --git a/arch/frv/kernel/Makefile b/arch/frv/kernel/Makefile
index c36f70b6699a..ad4087b69968 100644
--- a/arch/frv/kernel/Makefile
+++ b/arch/frv/kernel/Makefile
@@ -5,7 +5,7 @@
5heads-y := head-uc-fr401.o head-uc-fr451.o head-uc-fr555.o 5heads-y := head-uc-fr401.o head-uc-fr451.o head-uc-fr555.o
6heads-$(CONFIG_MMU) := head-mmu-fr451.o 6heads-$(CONFIG_MMU) := head-mmu-fr451.o
7 7
8extra-y:= head.o init_task.o vmlinux.lds 8extra-y:= head.o vmlinux.lds
9 9
10obj-y := $(heads-y) entry.o entry-table.o break.o switch_to.o kernel_thread.o \ 10obj-y := $(heads-y) entry.o entry-table.o break.o switch_to.o kernel_thread.o \
11 kernel_execve.o process.o traps.o ptrace.o signal.o dma.o \ 11 kernel_execve.o process.o traps.o ptrace.o signal.o dma.o \
diff --git a/arch/frv/kernel/init_task.c b/arch/frv/kernel/init_task.c
deleted file mode 100644
index 3c3e0b336a9d..000000000000
--- a/arch/frv/kernel/init_task.c
+++ /dev/null
@@ -1,32 +0,0 @@
1#include <linux/mm.h>
2#include <linux/module.h>
3#include <linux/sched.h>
4#include <linux/init.h>
5#include <linux/init_task.h>
6#include <linux/fs.h>
7#include <linux/mqueue.h>
8
9#include <asm/uaccess.h>
10#include <asm/pgtable.h>
11
12
13static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
14static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
15/*
16 * Initial thread structure.
17 *
18 * We need to make sure that this is THREAD_SIZE aligned due to the
19 * way process stacks are handled. This is done by having a special
20 * "init_task" linker map entry..
21 */
22union thread_union init_thread_union __init_task_data =
23 { INIT_THREAD_INFO(init_task) };
24
25/*
26 * Initial task structure.
27 *
28 * All other task structs will be allocated on slabs in fork.c
29 */
30struct task_struct init_task = INIT_TASK(init_task);
31
32EXPORT_SYMBOL(init_task);
diff --git a/arch/frv/kernel/process.c b/arch/frv/kernel/process.c
index d4de48bd5efe..ed09e9e2c653 100644
--- a/arch/frv/kernel/process.c
+++ b/arch/frv/kernel/process.c
@@ -43,21 +43,6 @@ asmlinkage void ret_from_fork(void);
43void (*pm_power_off)(void); 43void (*pm_power_off)(void);
44EXPORT_SYMBOL(pm_power_off); 44EXPORT_SYMBOL(pm_power_off);
45 45
46struct task_struct *alloc_task_struct_node(int node)
47{
48 struct task_struct *p = kmalloc_node(THREAD_SIZE, GFP_KERNEL, node);
49
50 if (p)
51 atomic_set((atomic_t *)(p+1), 1);
52 return p;
53}
54
55void free_task_struct(struct task_struct *p)
56{
57 if (atomic_dec_and_test((atomic_t *)(p+1)))
58 kfree(p);
59}
60
61static void core_sleep_idle(void) 46static void core_sleep_idle(void)
62{ 47{
63#ifdef LED_DEBUG_SLEEP 48#ifdef LED_DEBUG_SLEEP
diff --git a/arch/h8300/kernel/Makefile b/arch/h8300/kernel/Makefile
index 8d4d2a54be9e..1cc57f872d34 100644
--- a/arch/h8300/kernel/Makefile
+++ b/arch/h8300/kernel/Makefile
@@ -6,7 +6,7 @@ extra-y := vmlinux.lds
6 6
7obj-y := process.o traps.o ptrace.o irq.o \ 7obj-y := process.o traps.o ptrace.o irq.o \
8 sys_h8300.o time.o signal.o \ 8 sys_h8300.o time.o signal.o \
9 setup.o gpio.o init_task.o syscalls.o \ 9 setup.o gpio.o syscalls.o \
10 entry.o timer/ 10 entry.o timer/
11 11
12obj-$(CONFIG_MODULES) += module.o h8300_ksyms.o 12obj-$(CONFIG_MODULES) += module.o h8300_ksyms.o
diff --git a/arch/h8300/kernel/init_task.c b/arch/h8300/kernel/init_task.c
deleted file mode 100644
index 54c1062ee80e..000000000000
--- a/arch/h8300/kernel/init_task.c
+++ /dev/null
@@ -1,36 +0,0 @@
1/*
2 * linux/arch/h8300/kernel/init_task.c
3 */
4#include <linux/mm.h>
5#include <linux/module.h>
6#include <linux/sched.h>
7#include <linux/init.h>
8#include <linux/init_task.h>
9#include <linux/fs.h>
10#include <linux/mqueue.h>
11
12#include <asm/uaccess.h>
13#include <asm/pgtable.h>
14
15static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
16static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
17/*
18 * Initial task structure.
19 *
20 * All other task structs will be allocated on slabs in fork.c
21 */
22__asm__(".align 4");
23struct task_struct init_task = INIT_TASK(init_task);
24
25EXPORT_SYMBOL(init_task);
26
27/*
28 * Initial thread structure.
29 *
30 * We need to make sure that this is 8192-byte aligned due to the
31 * way process stacks are handled. This is done by having a special
32 * "init_task" linker map entry..
33 */
34union thread_union init_thread_union __init_task_data =
35 { INIT_THREAD_INFO(init_task) };
36
diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
index 9059e3905887..d2e4a3330336 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -27,6 +27,7 @@ config HEXAGON
27 select HAVE_ARCH_TRACEHOOK 27 select HAVE_ARCH_TRACEHOOK
28 select NO_IOPORT 28 select NO_IOPORT
29 select GENERIC_IOMAP 29 select GENERIC_IOMAP
30 select GENERIC_SMP_IDLE_THREAD
30 # mostly generic routines, with some accelerated ones 31 # mostly generic routines, with some accelerated ones
31 ---help--- 32 ---help---
32 Qualcomm Hexagon is a processor architecture designed for high 33 Qualcomm Hexagon is a processor architecture designed for high
diff --git a/arch/hexagon/Makefile b/arch/hexagon/Makefile
index 0c4de8790fd5..e27d030846ae 100644
--- a/arch/hexagon/Makefile
+++ b/arch/hexagon/Makefile
@@ -45,8 +45,7 @@ KBUILD_AFLAGS += -DTHREADINFO_REG=$(TIR_NAME)
45LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) 45LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
46libs-y += $(LIBGCC) 46libs-y += $(LIBGCC)
47 47
48head-y := arch/hexagon/kernel/head.o \ 48head-y := arch/hexagon/kernel/head.o
49 arch/hexagon/kernel/init_task.o
50 49
51core-y += arch/hexagon/kernel/ \ 50core-y += arch/hexagon/kernel/ \
52 arch/hexagon/mm/ \ 51 arch/hexagon/mm/ \
diff --git a/arch/hexagon/include/asm/thread_info.h b/arch/hexagon/include/asm/thread_info.h
index 9c2934ff5756..4f936a7ee847 100644
--- a/arch/hexagon/include/asm/thread_info.h
+++ b/arch/hexagon/include/asm/thread_info.h
@@ -31,15 +31,7 @@
31 31
32#define THREAD_SHIFT 12 32#define THREAD_SHIFT 12
33#define THREAD_SIZE (1<<THREAD_SHIFT) 33#define THREAD_SIZE (1<<THREAD_SHIFT)
34
35#if THREAD_SHIFT >= PAGE_SHIFT
36#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT) 34#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT)
37#else /* don't use standard allocator */
38#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
39extern struct thread_info *alloc_thread_info_node(struct task_struct *tsk, int node);
40extern void free_thread_info(struct thread_info *ti);
41#endif
42
43 35
44#ifndef __ASSEMBLY__ 36#ifndef __ASSEMBLY__
45 37
diff --git a/arch/hexagon/kernel/Makefile b/arch/hexagon/kernel/Makefile
index 3689f3754d09..536aec093e62 100644
--- a/arch/hexagon/kernel/Makefile
+++ b/arch/hexagon/kernel/Makefile
@@ -1,4 +1,4 @@
1extra-y := head.o vmlinux.lds init_task.o 1extra-y := head.o vmlinux.lds
2 2
3obj-$(CONFIG_SMP) += smp.o topology.o 3obj-$(CONFIG_SMP) += smp.o topology.o
4 4
diff --git a/arch/hexagon/kernel/init_task.c b/arch/hexagon/kernel/init_task.c
deleted file mode 100644
index 73283d3edf09..000000000000
--- a/arch/hexagon/kernel/init_task.c
+++ /dev/null
@@ -1,54 +0,0 @@
1/*
2 * Init task definition
3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 and
8 * only version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
19 */
20
21#include <linux/mm.h>
22#include <linux/module.h>
23#include <linux/sched.h>
24#include <linux/init_task.h>
25#include <linux/fs.h>
26#include <linux/mqueue.h>
27#include <asm/thread_info.h>
28#include <asm/uaccess.h>
29#include <asm/pgtable.h>
30
31static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
32static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
33
34/*
35 * Initial thread structure.
36 *
37 * We need to make sure that this is 8192-byte aligned due to the
38 * way process stacks are handled. This is done by making sure
39 * the linker maps this in the .text segment right after head.S,
40 * and making head.S ensure the proper alignment.
41 */
42union thread_union init_thread_union
43 __attribute__((__section__(".data.init_task"),
44 __aligned__(THREAD_SIZE))) = {
45 INIT_THREAD_INFO(init_task)
46 };
47
48/*
49 * Initial task structure.
50 *
51 * All other task structs will be allocated on slabs in fork.c
52 */
53struct task_struct init_task = INIT_TASK(init_task);
54EXPORT_SYMBOL(init_task);
diff --git a/arch/hexagon/kernel/process.c b/arch/hexagon/kernel/process.c
index ff02821bfb7e..af51de63b835 100644
--- a/arch/hexagon/kernel/process.c
+++ b/arch/hexagon/kernel/process.c
@@ -234,43 +234,6 @@ unsigned long get_wchan(struct task_struct *p)
234} 234}
235 235
236/* 236/*
237 * Borrowed from PowerPC -- basically allow smaller kernel stacks if we
238 * go crazy with the page sizes.
239 */
240#if THREAD_SHIFT < PAGE_SHIFT
241
242static struct kmem_cache *thread_info_cache;
243
244struct thread_info *alloc_thread_info_node(struct task_struct *tsk, int node)
245{
246 struct thread_info *ti;
247
248 ti = kmem_cache_alloc_node(thread_info_cache, GFP_KERNEL, node);
249 if (unlikely(ti == NULL))
250 return NULL;
251#ifdef CONFIG_DEBUG_STACK_USAGE
252 memset(ti, 0, THREAD_SIZE);
253#endif
254 return ti;
255}
256
257void free_thread_info(struct thread_info *ti)
258{
259 kmem_cache_free(thread_info_cache, ti);
260}
261
262/* Weak symbol; called by init/main.c */
263
264void thread_info_cache_init(void)
265{
266 thread_info_cache = kmem_cache_create("thread_info", THREAD_SIZE,
267 THREAD_SIZE, 0, NULL);
268 BUG_ON(thread_info_cache == NULL);
269}
270
271#endif /* THREAD_SHIFT < PAGE_SHIFT */
272
273/*
274 * Required placeholder. 237 * Required placeholder.
275 */ 238 */
276int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu) 239int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c
index 1298141874a3..f7264621e58d 100644
--- a/arch/hexagon/kernel/smp.c
+++ b/arch/hexagon/kernel/smp.c
@@ -196,18 +196,11 @@ void __cpuinit start_secondary(void)
196 * maintains control until "cpu_online(cpu)" is set. 196 * maintains control until "cpu_online(cpu)" is set.
197 */ 197 */
198 198
199int __cpuinit __cpu_up(unsigned int cpu) 199int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)
200{ 200{
201 struct task_struct *idle; 201 struct thread_info *thread = (struct thread_info *)idle->stack;
202 struct thread_info *thread;
203 void *stack_start; 202 void *stack_start;
204 203
205 /* Create new init task for the CPU */
206 idle = fork_idle(cpu);
207 if (IS_ERR(idle))
208 panic(KERN_ERR "fork_idle failed\n");
209
210 thread = (struct thread_info *)idle->stack;
211 thread->cpu = cpu; 204 thread->cpu = cpu;
212 205
213 /* Boot to the head. */ 206 /* Boot to the head. */
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index bd7266903bf8..ba667b60f32d 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -33,6 +33,10 @@ config IA64
33 select ARCH_WANT_OPTIONAL_GPIOLIB 33 select ARCH_WANT_OPTIONAL_GPIOLIB
34 select ARCH_HAVE_NMI_SAFE_CMPXCHG 34 select ARCH_HAVE_NMI_SAFE_CMPXCHG
35 select GENERIC_IOMAP 35 select GENERIC_IOMAP
36 select GENERIC_SMP_IDLE_THREAD
37 select ARCH_INIT_TASK
38 select ARCH_TASK_STRUCT_ALLOCATOR
39 select ARCH_THREAD_INFO_ALLOCATOR
36 default y 40 default y
37 help 41 help
38 The Itanium Processor Family is Intel's 64-bit successor to 42 The Itanium Processor Family is Intel's 64-bit successor to
diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
index 483f6c6a4238..f92f67aba618 100644
--- a/arch/ia64/include/asm/processor.h
+++ b/arch/ia64/include/asm/processor.h
@@ -723,7 +723,6 @@ extern unsigned long boot_option_idle_override;
723enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, IDLE_FORCE_MWAIT, 723enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, IDLE_FORCE_MWAIT,
724 IDLE_NOMWAIT, IDLE_POLL}; 724 IDLE_NOMWAIT, IDLE_POLL};
725 725
726void cpu_idle_wait(void);
727void default_idle(void); 726void default_idle(void);
728 727
729#define ia64_platform_is(x) (strcmp(x, platform_name) == 0) 728#define ia64_platform_is(x) (strcmp(x, platform_name) == 0)
diff --git a/arch/ia64/include/asm/thread_info.h b/arch/ia64/include/asm/thread_info.h
index e054bcc4273c..310d9734f02d 100644
--- a/arch/ia64/include/asm/thread_info.h
+++ b/arch/ia64/include/asm/thread_info.h
@@ -54,8 +54,6 @@ struct thread_info {
54 }, \ 54 }, \
55} 55}
56 56
57#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
58
59#ifndef ASM_OFFSETS_C 57#ifndef ASM_OFFSETS_C
60/* how to get the thread information struct from C */ 58/* how to get the thread information struct from C */
61#define current_thread_info() ((struct thread_info *) ((char *) current + IA64_TASK_SIZE)) 59#define current_thread_info() ((struct thread_info *) ((char *) current + IA64_TASK_SIZE))
@@ -84,7 +82,6 @@ struct thread_info {
84#endif 82#endif
85#define end_of_stack(p) (unsigned long *)((void *)(p) + IA64_RBS_OFFSET) 83#define end_of_stack(p) (unsigned long *)((void *)(p) + IA64_RBS_OFFSET)
86 84
87#define __HAVE_ARCH_TASK_STRUCT_ALLOCATOR
88#define alloc_task_struct_node(node) \ 85#define alloc_task_struct_node(node) \
89({ \ 86({ \
90 struct page *page = alloc_pages_node(node, GFP_KERNEL | __GFP_COMP, \ 87 struct page *page = alloc_pages_node(node, GFP_KERNEL | __GFP_COMP, \
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index ce74e143aea3..5e0e86ddb12f 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -273,26 +273,6 @@ static inline void play_dead(void)
273} 273}
274#endif /* CONFIG_HOTPLUG_CPU */ 274#endif /* CONFIG_HOTPLUG_CPU */
275 275
276static void do_nothing(void *unused)
277{
278}
279
280/*
281 * cpu_idle_wait - Used to ensure that all the CPUs discard old value of
282 * pm_idle and update to new pm_idle value. Required while changing pm_idle
283 * handler on SMP systems.
284 *
285 * Caller must have changed pm_idle to the new value before the call. Old
286 * pm_idle value will not be used by any CPU after the return of this function.
287 */
288void cpu_idle_wait(void)
289{
290 smp_mb();
291 /* kick all the CPUs so that they exit out of pm_idle */
292 smp_call_function(do_nothing, NULL, 1);
293}
294EXPORT_SYMBOL_GPL(cpu_idle_wait);
295
296void __attribute__((noreturn)) 276void __attribute__((noreturn))
297cpu_idle (void) 277cpu_idle (void)
298{ 278{
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index 796f6a5b966a..1113b8aba07f 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -75,13 +75,6 @@
75#endif 75#endif
76 76
77/* 77/*
78 * Store all idle threads, this can be reused instead of creating
79 * a new thread. Also avoids complicated thread destroy functionality
80 * for idle threads.
81 */
82struct task_struct *idle_thread_array[NR_CPUS];
83
84/*
85 * Global array allocated for NR_CPUS at boot time 78 * Global array allocated for NR_CPUS at boot time
86 */ 79 */
87struct sal_to_os_boot sal_boot_rendez_state[NR_CPUS]; 80struct sal_to_os_boot sal_boot_rendez_state[NR_CPUS];
@@ -94,13 +87,7 @@ struct sal_to_os_boot *sal_state_for_booting_cpu = &sal_boot_rendez_state[0];
94 87
95#define set_brendez_area(x) (sal_state_for_booting_cpu = &sal_boot_rendez_state[(x)]); 88#define set_brendez_area(x) (sal_state_for_booting_cpu = &sal_boot_rendez_state[(x)]);
96 89
97#define get_idle_for_cpu(x) (idle_thread_array[(x)])
98#define set_idle_for_cpu(x,p) (idle_thread_array[(x)] = (p))
99
100#else 90#else
101
102#define get_idle_for_cpu(x) (NULL)
103#define set_idle_for_cpu(x,p)
104#define set_brendez_area(x) 91#define set_brendez_area(x)
105#endif 92#endif
106 93
@@ -480,54 +467,12 @@ struct pt_regs * __cpuinit idle_regs(struct pt_regs *regs)
480 return NULL; 467 return NULL;
481} 468}
482 469
483struct create_idle {
484 struct work_struct work;
485 struct task_struct *idle;
486 struct completion done;
487 int cpu;
488};
489
490void __cpuinit
491do_fork_idle(struct work_struct *work)
492{
493 struct create_idle *c_idle =
494 container_of(work, struct create_idle, work);
495
496 c_idle->idle = fork_idle(c_idle->cpu);
497 complete(&c_idle->done);
498}
499
500static int __cpuinit 470static int __cpuinit
501do_boot_cpu (int sapicid, int cpu) 471do_boot_cpu (int sapicid, int cpu, struct task_struct *idle)
502{ 472{
503 int timeout; 473 int timeout;
504 struct create_idle c_idle = {
505 .work = __WORK_INITIALIZER(c_idle.work, do_fork_idle),
506 .cpu = cpu,
507 .done = COMPLETION_INITIALIZER(c_idle.done),
508 };
509
510 /*
511 * We can't use kernel_thread since we must avoid to
512 * reschedule the child.
513 */
514 c_idle.idle = get_idle_for_cpu(cpu);
515 if (c_idle.idle) {
516 init_idle(c_idle.idle, cpu);
517 goto do_rest;
518 }
519
520 schedule_work(&c_idle.work);
521 wait_for_completion(&c_idle.done);
522
523 if (IS_ERR(c_idle.idle))
524 panic("failed fork for CPU %d", cpu);
525
526 set_idle_for_cpu(cpu, c_idle.idle);
527
528do_rest:
529 task_for_booting_cpu = c_idle.idle;
530 474
475 task_for_booting_cpu = idle;
531 Dprintk("Sending wakeup vector %lu to AP 0x%x/0x%x.\n", ap_wakeup_vector, cpu, sapicid); 476 Dprintk("Sending wakeup vector %lu to AP 0x%x/0x%x.\n", ap_wakeup_vector, cpu, sapicid);
532 477
533 set_brendez_area(cpu); 478 set_brendez_area(cpu);
@@ -793,7 +738,7 @@ set_cpu_sibling_map(int cpu)
793} 738}
794 739
795int __cpuinit 740int __cpuinit
796__cpu_up (unsigned int cpu) 741__cpu_up(unsigned int cpu, struct task_struct *tidle)
797{ 742{
798 int ret; 743 int ret;
799 int sapicid; 744 int sapicid;
@@ -811,7 +756,7 @@ __cpu_up (unsigned int cpu)
811 756
812 per_cpu(cpu_state, cpu) = CPU_UP_PREPARE; 757 per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
813 /* Processor goes to start_secondary(), sets online flag */ 758 /* Processor goes to start_secondary(), sets online flag */
814 ret = do_boot_cpu(sapicid, cpu); 759 ret = do_boot_cpu(sapicid, cpu, tidle);
815 if (ret < 0) 760 if (ret < 0)
816 return ret; 761 return ret;
817 762
diff --git a/arch/m32r/Makefile b/arch/m32r/Makefile
index 8ff5ba0ea26c..def8dd0b6bc5 100644
--- a/arch/m32r/Makefile
+++ b/arch/m32r/Makefile
@@ -31,7 +31,7 @@ KBUILD_AFLAGS += $(aflags-y)
31 31
32CHECKFLAGS += -D__m32r__ -D__BIG_ENDIAN__=1 32CHECKFLAGS += -D__m32r__ -D__BIG_ENDIAN__=1
33 33
34head-y := arch/m32r/kernel/head.o arch/m32r/kernel/init_task.o 34head-y := arch/m32r/kernel/head.o
35 35
36LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) 36LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
37 37
diff --git a/arch/m32r/include/asm/thread_info.h b/arch/m32r/include/asm/thread_info.h
index bf8fa3c06f4e..c083f6073ef4 100644
--- a/arch/m32r/include/asm/thread_info.h
+++ b/arch/m32r/include/asm/thread_info.h
@@ -55,8 +55,8 @@ struct thread_info {
55 55
56#define PREEMPT_ACTIVE 0x10000000 56#define PREEMPT_ACTIVE 0x10000000
57 57
58#define THREAD_SIZE (PAGE_SIZE << 1) 58#define THREAD_SIZE (PAGE_SIZE << 1)
59 59#define THREAD_SIZE_ORDER 1
60/* 60/*
61 * macros/functions for gaining access to the thread information structure 61 * macros/functions for gaining access to the thread information structure
62 */ 62 */
@@ -92,19 +92,6 @@ static inline struct thread_info *current_thread_info(void)
92 return ti; 92 return ti;
93} 93}
94 94
95#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
96
97/* thread information allocation */
98#ifdef CONFIG_DEBUG_STACK_USAGE
99#define alloc_thread_info_node(tsk, node) \
100 kzalloc_node(THREAD_SIZE, GFP_KERNEL, node)
101#else
102#define alloc_thread_info_node(tsk, node) \
103 kmalloc_node(THREAD_SIZE, GFP_KERNEL, node)
104#endif
105
106#define free_thread_info(info) kfree(info)
107
108#define TI_FLAG_FAULT_CODE_SHIFT 28 95#define TI_FLAG_FAULT_CODE_SHIFT 28
109 96
110static inline void set_thread_fault_code(unsigned int val) 97static inline void set_thread_fault_code(unsigned int val)
diff --git a/arch/m32r/kernel/Makefile b/arch/m32r/kernel/Makefile
index b1a4b6036591..0c09dad8b1f8 100644
--- a/arch/m32r/kernel/Makefile
+++ b/arch/m32r/kernel/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the Linux/M32R kernel. 2# Makefile for the Linux/M32R kernel.
3# 3#
4 4
5extra-y := head.o init_task.o vmlinux.lds 5extra-y := head.o vmlinux.lds
6 6
7obj-y := process.o entry.o traps.o align.o irq.o setup.o time.o \ 7obj-y := process.o entry.o traps.o align.o irq.o setup.o time.o \
8 m32r_ksyms.o sys_m32r.o signal.o ptrace.o 8 m32r_ksyms.o sys_m32r.o signal.o ptrace.o
diff --git a/arch/m32r/kernel/init_task.c b/arch/m32r/kernel/init_task.c
deleted file mode 100644
index 6c42d5f8df50..000000000000
--- a/arch/m32r/kernel/init_task.c
+++ /dev/null
@@ -1,34 +0,0 @@
1/* orig : i386 init_task.c */
2
3#include <linux/mm.h>
4#include <linux/module.h>
5#include <linux/sched.h>
6#include <linux/init.h>
7#include <linux/init_task.h>
8#include <linux/fs.h>
9#include <linux/mqueue.h>
10
11#include <asm/uaccess.h>
12#include <asm/pgtable.h>
13
14static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
15static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
16/*
17 * Initial thread structure.
18 *
19 * We need to make sure that this is 8192-byte aligned due to the
20 * way process stacks are handled. This is done by having a special
21 * "init_task" linker map entry..
22 */
23union thread_union init_thread_union __init_task_data =
24 { INIT_THREAD_INFO(init_task) };
25
26/*
27 * Initial task structure.
28 *
29 * All other task structs will be allocated on slabs in fork.c
30 */
31struct task_struct init_task = INIT_TASK(init_task);
32
33EXPORT_SYMBOL(init_task);
34
diff --git a/arch/m32r/kernel/smpboot.c b/arch/m32r/kernel/smpboot.c
index cfdbe5d15002..a2cfc0abb05c 100644
--- a/arch/m32r/kernel/smpboot.c
+++ b/arch/m32r/kernel/smpboot.c
@@ -109,12 +109,8 @@ static unsigned int calibration_result;
109/* Function Prototypes */ 109/* Function Prototypes */
110/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ 110/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
111 111
112void smp_prepare_boot_cpu(void);
113void smp_prepare_cpus(unsigned int);
114static void init_ipi_lock(void); 112static void init_ipi_lock(void);
115static void do_boot_cpu(int); 113static void do_boot_cpu(int);
116int __cpu_up(unsigned int);
117void smp_cpus_done(unsigned int);
118 114
119int start_secondary(void *); 115int start_secondary(void *);
120static void smp_callin(void); 116static void smp_callin(void);
@@ -347,7 +343,7 @@ static void __init do_boot_cpu(int phys_id)
347 } 343 }
348} 344}
349 345
350int __cpuinit __cpu_up(unsigned int cpu_id) 346int __cpuinit __cpu_up(unsigned int cpu_id, struct task_struct *tidle)
351{ 347{
352 int timeout; 348 int timeout;
353 349
diff --git a/arch/m68k/kernel/Makefile b/arch/m68k/kernel/Makefile
index 40d29a788b05..5c7070e21eb7 100644
--- a/arch/m68k/kernel/Makefile
+++ b/arch/m68k/kernel/Makefile
@@ -13,7 +13,7 @@ extra-$(CONFIG_SUN3X) := head.o
13extra-$(CONFIG_SUN3) := sun3-head.o 13extra-$(CONFIG_SUN3) := sun3-head.o
14extra-y += vmlinux.lds 14extra-y += vmlinux.lds
15 15
16obj-y := entry.o init_task.o irq.o m68k_ksyms.o module.o process.o ptrace.o 16obj-y := entry.o irq.o m68k_ksyms.o module.o process.o ptrace.o
17obj-y += setup.o signal.o sys_m68k.o syscalltable.o time.o traps.o 17obj-y += setup.o signal.o sys_m68k.o syscalltable.o time.o traps.o
18 18
19obj-$(CONFIG_MMU_MOTOROLA) += ints.o vectors.o 19obj-$(CONFIG_MMU_MOTOROLA) += ints.o vectors.o
diff --git a/arch/m68k/kernel/init_task.c b/arch/m68k/kernel/init_task.c
deleted file mode 100644
index c744cfc6bfa1..000000000000
--- a/arch/m68k/kernel/init_task.c
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * linux/arch/m68knommu/kernel/init_task.c
3 */
4#include <linux/mm.h>
5#include <linux/module.h>
6#include <linux/sched.h>
7#include <linux/init.h>
8#include <linux/init_task.h>
9#include <linux/fs.h>
10#include <linux/mqueue.h>
11
12#include <asm/uaccess.h>
13#include <asm/pgtable.h>
14
15static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
16static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
17/*
18 * Initial task structure.
19 *
20 * All other task structs will be allocated on slabs in fork.c
21 */
22struct task_struct init_task = INIT_TASK(init_task);
23
24EXPORT_SYMBOL(init_task);
25
26/*
27 * Initial thread structure.
28 *
29 * We need to make sure that this is THREAD size aligned due to the
30 * way process stacks are handled. This is done by having a special
31 * "init_task" linker map entry..
32 */
33union thread_union init_thread_union __init_task_data =
34 { INIT_THREAD_INFO(init_task) };
35
diff --git a/arch/microblaze/kernel/Makefile b/arch/microblaze/kernel/Makefile
index 494b63b72dd7..928c950fc14c 100644
--- a/arch/microblaze/kernel/Makefile
+++ b/arch/microblaze/kernel/Makefile
@@ -16,7 +16,7 @@ endif
16extra-y := head.o vmlinux.lds 16extra-y := head.o vmlinux.lds
17 17
18obj-y += dma.o exceptions.o \ 18obj-y += dma.o exceptions.o \
19 hw_exception_handler.o init_task.o intc.o irq.o \ 19 hw_exception_handler.o intc.o irq.o \
20 process.o prom.o prom_parse.o ptrace.o \ 20 process.o prom.o prom_parse.o ptrace.o \
21 reset.o setup.o signal.o sys_microblaze.o timer.o traps.o unwind.o 21 reset.o setup.o signal.o sys_microblaze.o timer.o traps.o unwind.o
22 22
diff --git a/arch/microblaze/kernel/init_task.c b/arch/microblaze/kernel/init_task.c
deleted file mode 100644
index b5d711f94ff8..000000000000
--- a/arch/microblaze/kernel/init_task.c
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * Copyright (C) 2009 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2009 PetaLogix
4 * Copyright (C) 2006 Atmark Techno, Inc.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/module.h>
12#include <linux/sched.h>
13#include <linux/init_task.h>
14#include <linux/fs.h>
15#include <linux/mqueue.h>
16
17#include <asm/pgtable.h>
18
19static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
20static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
21
22union thread_union init_thread_union __init_task_data =
23 { INIT_THREAD_INFO(init_task) };
24
25struct task_struct init_task = INIT_TASK(init_task);
26EXPORT_SYMBOL(init_task);
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index ce30e2f91d77..186fc8cf9ee0 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -29,6 +29,7 @@ config MIPS
29 select HAVE_MEMBLOCK 29 select HAVE_MEMBLOCK
30 select HAVE_MEMBLOCK_NODE_MAP 30 select HAVE_MEMBLOCK_NODE_MAP
31 select ARCH_DISCARD_MEMBLOCK 31 select ARCH_DISCARD_MEMBLOCK
32 select GENERIC_SMP_IDLE_THREAD
32 33
33menu "Machine selection" 34menu "Machine selection"
34 35
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 4fedf5a51d96..76017c25a9e6 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -235,7 +235,7 @@ endif
235 235
236OBJCOPYFLAGS += --remove-section=.reginfo 236OBJCOPYFLAGS += --remove-section=.reginfo
237 237
238head-y := arch/mips/kernel/head.o arch/mips/kernel/init_task.o 238head-y := arch/mips/kernel/head.o
239 239
240libs-y += arch/mips/lib/ 240libs-y += arch/mips/lib/
241 241
diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
index 0d85d8e440c5..e2eca7d10598 100644
--- a/arch/mips/include/asm/thread_info.h
+++ b/arch/mips/include/asm/thread_info.h
@@ -85,18 +85,6 @@ register struct thread_info *__current_thread_info __asm__("$28");
85 85
86#define STACK_WARN (THREAD_SIZE / 8) 86#define STACK_WARN (THREAD_SIZE / 8)
87 87
88#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
89
90#ifdef CONFIG_DEBUG_STACK_USAGE
91#define alloc_thread_info_node(tsk, node) \
92 kzalloc_node(THREAD_SIZE, GFP_KERNEL, node)
93#else
94#define alloc_thread_info_node(tsk, node) \
95 kmalloc_node(THREAD_SIZE, GFP_KERNEL, node)
96#endif
97
98#define free_thread_info(info) kfree(info)
99
100#endif /* !__ASSEMBLY__ */ 88#endif /* !__ASSEMBLY__ */
101 89
102#define PREEMPT_ACTIVE 0x10000000 90#define PREEMPT_ACTIVE 0x10000000
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 0c6877ea9004..fdaf65e1a99d 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the Linux/MIPS kernel. 2# Makefile for the Linux/MIPS kernel.
3# 3#
4 4
5extra-y := head.o init_task.o vmlinux.lds 5extra-y := head.o vmlinux.lds
6 6
7obj-y += cpu-probe.o branch.o entry.o genex.o irq.o process.o \ 7obj-y += cpu-probe.o branch.o entry.o genex.o irq.o process.o \
8 ptrace.o reset.o setup.o signal.o syscall.o \ 8 ptrace.o reset.o setup.o signal.o syscall.o \
diff --git a/arch/mips/kernel/init_task.c b/arch/mips/kernel/init_task.c
deleted file mode 100644
index 5f9a76263c9a..000000000000
--- a/arch/mips/kernel/init_task.c
+++ /dev/null
@@ -1,35 +0,0 @@
1#include <linux/mm.h>
2#include <linux/export.h>
3#include <linux/sched.h>
4#include <linux/init_task.h>
5#include <linux/fs.h>
6#include <linux/mqueue.h>
7
8#include <asm/thread_info.h>
9#include <asm/uaccess.h>
10#include <asm/pgtable.h>
11
12static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
13static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
14/*
15 * Initial thread structure.
16 *
17 * We need to make sure that this is 8192-byte aligned due to the
18 * way process stacks are handled. This is done by making sure
19 * the linker maps this in the .text segment right after head.S,
20 * and making head.S ensure the proper alignment.
21 *
22 * The things we do for performance..
23 */
24union thread_union init_thread_union __init_task_data
25 __attribute__((__aligned__(THREAD_SIZE))) =
26 { INIT_THREAD_INFO(init_task) };
27
28/*
29 * Initial task structure.
30 *
31 * All other task structs will be allocated on slabs in fork.c
32 */
33struct task_struct init_task = INIT_TASK(init_task);
34
35EXPORT_SYMBOL(init_task);
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index ba9376bf52a1..71a95f55a649 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -186,61 +186,9 @@ void __devinit smp_prepare_boot_cpu(void)
186 cpu_set(0, cpu_callin_map); 186 cpu_set(0, cpu_callin_map);
187} 187}
188 188
189/* 189int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
190 * Called once for each "cpu_possible(cpu)". Needs to spin up the cpu
191 * and keep control until "cpu_online(cpu)" is set. Note: cpu is
192 * physical, not logical.
193 */
194static struct task_struct *cpu_idle_thread[NR_CPUS];
195
196struct create_idle {
197 struct work_struct work;
198 struct task_struct *idle;
199 struct completion done;
200 int cpu;
201};
202
203static void __cpuinit do_fork_idle(struct work_struct *work)
204{
205 struct create_idle *c_idle =
206 container_of(work, struct create_idle, work);
207
208 c_idle->idle = fork_idle(c_idle->cpu);
209 complete(&c_idle->done);
210}
211
212int __cpuinit __cpu_up(unsigned int cpu)
213{ 190{
214 struct task_struct *idle; 191 mp_ops->boot_secondary(cpu, tidle);
215
216 /*
217 * Processor goes to start_secondary(), sets online flag
218 * The following code is purely to make sure
219 * Linux can schedule processes on this slave.
220 */
221 if (!cpu_idle_thread[cpu]) {
222 /*
223 * Schedule work item to avoid forking user task
224 * Ported from arch/x86/kernel/smpboot.c
225 */
226 struct create_idle c_idle = {
227 .cpu = cpu,
228 .done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done),
229 };
230
231 INIT_WORK_ONSTACK(&c_idle.work, do_fork_idle);
232 schedule_work(&c_idle.work);
233 wait_for_completion(&c_idle.done);
234 idle = cpu_idle_thread[cpu] = c_idle.idle;
235
236 if (IS_ERR(idle))
237 panic(KERN_ERR "Fork failed for CPU %d", cpu);
238 } else {
239 idle = cpu_idle_thread[cpu];
240 init_idle(idle, cpu);
241 }
242
243 mp_ops->boot_secondary(cpu, idle);
244 192
245 /* 193 /*
246 * Trust is futile. We should really have timeouts ... 194 * Trust is futile. We should really have timeouts ...
diff --git a/arch/mn10300/Makefile b/arch/mn10300/Makefile
index 7120282bf0d8..33188b6e81e4 100644
--- a/arch/mn10300/Makefile
+++ b/arch/mn10300/Makefile
@@ -51,7 +51,7 @@ UNIT := asb2364
51endif 51endif
52 52
53 53
54head-y := arch/mn10300/kernel/head.o arch/mn10300/kernel/init_task.o 54head-y := arch/mn10300/kernel/head.o
55 55
56core-y += arch/mn10300/kernel/ arch/mn10300/mm/ 56core-y += arch/mn10300/kernel/ arch/mn10300/mm/
57 57
diff --git a/arch/mn10300/include/asm/thread_info.h b/arch/mn10300/include/asm/thread_info.h
index 28cf52100baa..08251d6f6b11 100644
--- a/arch/mn10300/include/asm/thread_info.h
+++ b/arch/mn10300/include/asm/thread_info.h
@@ -20,8 +20,10 @@
20 20
21#ifdef CONFIG_4KSTACKS 21#ifdef CONFIG_4KSTACKS
22#define THREAD_SIZE (4096) 22#define THREAD_SIZE (4096)
23#define THREAD_SIZE_ORDER (0)
23#else 24#else
24#define THREAD_SIZE (8192) 25#define THREAD_SIZE (8192)
26#define THREAD_SIZE_ORDER (1)
25#endif 27#endif
26 28
27#define STACK_WARN (THREAD_SIZE / 8) 29#define STACK_WARN (THREAD_SIZE / 8)
@@ -120,21 +122,8 @@ static inline unsigned long current_stack_pointer(void)
120 return sp; 122 return sp;
121} 123}
122 124
123#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
124
125/* thread information allocation */
126#ifdef CONFIG_DEBUG_STACK_USAGE
127#define alloc_thread_info_node(tsk, node) \
128 kzalloc_node(THREAD_SIZE, GFP_KERNEL, node)
129#else
130#define alloc_thread_info_node(tsk, node) \
131 kmalloc_node(THREAD_SIZE, GFP_KERNEL, node)
132#endif
133
134#ifndef CONFIG_KGDB 125#ifndef CONFIG_KGDB
135#define free_thread_info(ti) kfree((ti)) 126void arch_release_thread_info(struct thread_info *ti)
136#else
137extern void free_thread_info(struct thread_info *);
138#endif 127#endif
139#define get_thread_info(ti) get_task_struct((ti)->task) 128#define get_thread_info(ti) get_task_struct((ti)->task)
140#define put_thread_info(ti) put_task_struct((ti)->task) 129#define put_thread_info(ti) put_task_struct((ti)->task)
diff --git a/arch/mn10300/kernel/Makefile b/arch/mn10300/kernel/Makefile
index 47ed30fe8178..d06749173d63 100644
--- a/arch/mn10300/kernel/Makefile
+++ b/arch/mn10300/kernel/Makefile
@@ -1,7 +1,7 @@
1# 1#
2# Makefile for the MN10300-specific core kernel code 2# Makefile for the MN10300-specific core kernel code
3# 3#
4extra-y := head.o init_task.o vmlinux.lds 4extra-y := head.o vmlinux.lds
5 5
6fpu-obj-y := fpu-nofpu.o fpu-nofpu-low.o 6fpu-obj-y := fpu-nofpu.o fpu-nofpu-low.o
7fpu-obj-$(CONFIG_FPU) := fpu.o fpu-low.o 7fpu-obj-$(CONFIG_FPU) := fpu.o fpu-low.o
diff --git a/arch/mn10300/kernel/init_task.c b/arch/mn10300/kernel/init_task.c
deleted file mode 100644
index a481b043bea7..000000000000
--- a/arch/mn10300/kernel/init_task.c
+++ /dev/null
@@ -1,39 +0,0 @@
1/* MN10300 Initial task definitions
2 *
3 * Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd.
4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11#include <linux/mm.h>
12#include <linux/module.h>
13#include <linux/sched.h>
14#include <linux/init.h>
15#include <linux/init_task.h>
16#include <linux/fs.h>
17#include <linux/mqueue.h>
18#include <asm/uaccess.h>
19#include <asm/pgtable.h>
20
21static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
22static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
23/*
24 * Initial thread structure.
25 *
26 * We need to make sure that this is THREAD_SIZE aligned due to the
27 * way process stacks are handled. This is done by having a special
28 * "init_task" linker map entry..
29 */
30union thread_union init_thread_union __init_task_data =
31 { INIT_THREAD_INFO(init_task) };
32
33/*
34 * Initial task structure.
35 *
36 * All other task structs will be allocated on slabs in fork.c
37 */
38struct task_struct init_task = INIT_TASK(init_task);
39EXPORT_SYMBOL(init_task);
diff --git a/arch/mn10300/kernel/kgdb.c b/arch/mn10300/kernel/kgdb.c
index f6c981db2a36..99770823451a 100644
--- a/arch/mn10300/kernel/kgdb.c
+++ b/arch/mn10300/kernel/kgdb.c
@@ -397,7 +397,7 @@ static bool kgdb_arch_undo_singlestep(struct pt_regs *regs)
397 * single-step state is cleared. At this point the breakpoints should have 397 * single-step state is cleared. At this point the breakpoints should have
398 * been removed by __switch_to(). 398 * been removed by __switch_to().
399 */ 399 */
400void free_thread_info(struct thread_info *ti) 400void arch_release_thread_info(struct thread_info *ti)
401{ 401{
402 if (kgdb_sstep_thread == ti) { 402 if (kgdb_sstep_thread == ti) {
403 kgdb_sstep_thread = NULL; 403 kgdb_sstep_thread = NULL;
@@ -407,7 +407,6 @@ void free_thread_info(struct thread_info *ti)
407 * so force immediate reentry */ 407 * so force immediate reentry */
408 kgdb_breakpoint(); 408 kgdb_breakpoint();
409 } 409 }
410 kfree(ti);
411} 410}
412 411
413/* 412/*
diff --git a/arch/mn10300/kernel/smp.c b/arch/mn10300/kernel/smp.c
index 9cd69ad6aa02..090d35d36973 100644
--- a/arch/mn10300/kernel/smp.c
+++ b/arch/mn10300/kernel/smp.c
@@ -924,7 +924,7 @@ void initialize_secondary(void)
924 * __cpu_up - Set smp_commenced_mask for the nominated CPU 924 * __cpu_up - Set smp_commenced_mask for the nominated CPU
925 * @cpu: The target CPU. 925 * @cpu: The target CPU.
926 */ 926 */
927int __devinit __cpu_up(unsigned int cpu) 927int __devinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
928{ 928{
929 int timeout; 929 int timeout;
930 930
diff --git a/arch/openrisc/Makefile b/arch/openrisc/Makefile
index 158ae4c0dc6c..966886c8daf5 100644
--- a/arch/openrisc/Makefile
+++ b/arch/openrisc/Makefile
@@ -38,7 +38,7 @@ else
38 KBUILD_CFLAGS += $(call cc-option,-msoft-div) 38 KBUILD_CFLAGS += $(call cc-option,-msoft-div)
39endif 39endif
40 40
41head-y := arch/openrisc/kernel/head.o arch/openrisc/kernel/init_task.o 41head-y := arch/openrisc/kernel/head.o
42 42
43core-y += arch/openrisc/lib/ \ 43core-y += arch/openrisc/lib/ \
44 arch/openrisc/kernel/ \ 44 arch/openrisc/kernel/ \
diff --git a/arch/openrisc/kernel/Makefile b/arch/openrisc/kernel/Makefile
index 9a4c2706d795..e1ee0fa2bbda 100644
--- a/arch/openrisc/kernel/Makefile
+++ b/arch/openrisc/kernel/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the linux kernel. 2# Makefile for the linux kernel.
3# 3#
4 4
5extra-y := head.o vmlinux.lds init_task.o 5extra-y := head.o vmlinux.lds
6 6
7obj-y := setup.o idle.o or32_ksyms.o process.o dma.o \ 7obj-y := setup.o idle.o or32_ksyms.o process.o dma.o \
8 traps.o time.o irq.o entry.o ptrace.o signal.o sys_or32.o \ 8 traps.o time.o irq.o entry.o ptrace.o signal.o sys_or32.o \
diff --git a/arch/openrisc/kernel/init_task.c b/arch/openrisc/kernel/init_task.c
deleted file mode 100644
index ca534082d5f3..000000000000
--- a/arch/openrisc/kernel/init_task.c
+++ /dev/null
@@ -1,42 +0,0 @@
1/*
2 * OpenRISC init_task.c
3 *
4 * Linux architectural port borrowing liberally from similar works of
5 * others. All original copyrights apply as per the original source
6 * declaration.
7 *
8 * Modifications for the OpenRISC architecture:
9 * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
10 * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
16 */
17
18#include <linux/init_task.h>
19#include <linux/mqueue.h>
20#include <linux/export.h>
21
22static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
23static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
24
25/*
26 * Initial thread structure.
27 *
28 * We need to make sure that this is THREAD_SIZE aligned due to the
29 * way process stacks are handled. This is done by having a special
30 * "init_task" linker map entry..
31 */
32union thread_union init_thread_union __init_task_data = {
33 INIT_THREAD_INFO(init_task)
34};
35
36/*
37 * Initial task structure.
38 *
39 * All other task structs will be allocated on slabs in fork.c
40 */
41struct task_struct init_task = INIT_TASK(init_task);
42EXPORT_SYMBOL(init_task);
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 242a1b7ac759..ddb8b24b823d 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -17,6 +17,7 @@ config PARISC
17 select GENERIC_PCI_IOMAP 17 select GENERIC_PCI_IOMAP
18 select IRQ_PER_CPU 18 select IRQ_PER_CPU
19 select ARCH_HAVE_NMI_SAFE_CMPXCHG 19 select ARCH_HAVE_NMI_SAFE_CMPXCHG
20 select GENERIC_SMP_IDLE_THREAD
20 21
21 help 22 help
22 The PA-RISC microprocessor is designed by Hewlett-Packard and used 23 The PA-RISC microprocessor is designed by Hewlett-Packard and used
diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index 19ab7b2ea1cd..dbc3850b1d0d 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -75,7 +75,7 @@ head-y := arch/parisc/kernel/head.o
75 75
76KBUILD_CFLAGS += $(cflags-y) 76KBUILD_CFLAGS += $(cflags-y)
77 77
78kernel-y := mm/ kernel/ math-emu/ kernel/init_task.o 78kernel-y := mm/ kernel/ math-emu/
79kernel-$(CONFIG_HPUX) += hpux/ 79kernel-$(CONFIG_HPUX) += hpux/
80 80
81core-y += $(addprefix arch/parisc/, $(kernel-y)) 81core-y += $(addprefix arch/parisc/, $(kernel-y))
diff --git a/arch/parisc/kernel/Makefile b/arch/parisc/kernel/Makefile
index 67db0722e6ca..66ee3f12df58 100644
--- a/arch/parisc/kernel/Makefile
+++ b/arch/parisc/kernel/Makefile
@@ -2,7 +2,7 @@
2# Makefile for arch/parisc/kernel 2# Makefile for arch/parisc/kernel
3# 3#
4 4
5extra-y := init_task.o head.o vmlinux.lds 5extra-y := head.o vmlinux.lds
6 6
7obj-y := cache.o pacache.o setup.o traps.o time.o irq.o \ 7obj-y := cache.o pacache.o setup.o traps.o time.o irq.o \
8 pa7300lc.o syscall.o entry.o sys_parisc.o firmware.o \ 8 pa7300lc.o syscall.o entry.o sys_parisc.o firmware.o \
diff --git a/arch/parisc/kernel/init_task.c b/arch/parisc/kernel/init_task.c
deleted file mode 100644
index 4a91e433416f..000000000000
--- a/arch/parisc/kernel/init_task.c
+++ /dev/null
@@ -1,70 +0,0 @@
1/*
2 * Static declaration of "init" task data structure.
3 *
4 * Copyright (C) 2000 Paul Bame <bame at parisc-linux.org>
5 * Copyright (C) 2000-2001 John Marvin <jsm at parisc-linux.org>
6 * Copyright (C) 2001 Helge Deller <deller @ parisc-linux.org>
7 * Copyright (C) 2002 Matthew Wilcox <willy with parisc-linux.org>
8 *
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#include <linux/mm.h>
26#include <linux/fs.h>
27#include <linux/module.h>
28#include <linux/sched.h>
29#include <linux/init.h>
30#include <linux/init_task.h>
31#include <linux/mqueue.h>
32
33#include <asm/uaccess.h>
34#include <asm/pgtable.h>
35#include <asm/pgalloc.h>
36
37static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
38static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
39/*
40 * Initial task structure.
41 *
42 * We need to make sure that this is 16384-byte aligned due to the
43 * way process stacks are handled. This is done by having a special
44 * "init_task" linker map entry..
45 */
46union thread_union init_thread_union __init_task_data
47 __attribute__((aligned(128))) =
48 { INIT_THREAD_INFO(init_task) };
49
50#if PT_NLEVELS == 3
51/* NOTE: This layout exactly conforms to the hybrid L2/L3 page table layout
52 * with the first pmd adjacent to the pgd and below it. gcc doesn't actually
53 * guarantee that global objects will be laid out in memory in the same order
54 * as the order of declaration, so put these in different sections and use
55 * the linker script to order them. */
56pmd_t pmd0[PTRS_PER_PMD] __attribute__ ((__section__ (".data..vm0.pmd"), aligned(PAGE_SIZE)));
57#endif
58
59pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__ ((__section__ (".data..vm0.pgd"), aligned(PAGE_SIZE)));
60pte_t pg0[PT_INITIAL * PTRS_PER_PTE] __attribute__ ((__section__ (".data..vm0.pte"), aligned(PAGE_SIZE)));
61
62/*
63 * Initial task structure.
64 *
65 * All other task structs will be allocated on slabs in fork.c
66 */
67EXPORT_SYMBOL(init_task);
68
69__asm__(".data");
70struct task_struct init_task = INIT_TASK(init_task);
diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
index 4dc7b7942b4c..a47828d31fe6 100644
--- a/arch/parisc/kernel/smp.c
+++ b/arch/parisc/kernel/smp.c
@@ -340,26 +340,11 @@ void __init smp_callin(void)
340/* 340/*
341 * Bring one cpu online. 341 * Bring one cpu online.
342 */ 342 */
343int __cpuinit smp_boot_one_cpu(int cpuid) 343int __cpuinit smp_boot_one_cpu(int cpuid, struct task_struct *idle)
344{ 344{
345 const struct cpuinfo_parisc *p = &per_cpu(cpu_data, cpuid); 345 const struct cpuinfo_parisc *p = &per_cpu(cpu_data, cpuid);
346 struct task_struct *idle;
347 long timeout; 346 long timeout;
348 347
349 /*
350 * Create an idle task for this CPU. Note the address wed* give
351 * to kernel_thread is irrelevant -- it's going to start
352 * where OS_BOOT_RENDEVZ vector in SAL says to start. But
353 * this gets all the other task-y sort of data structures set
354 * up like we wish. We need to pull the just created idle task
355 * off the run queue and stuff it into the init_tasks[] array.
356 * Sheesh . . .
357 */
358
359 idle = fork_idle(cpuid);
360 if (IS_ERR(idle))
361 panic("SMP: fork failed for CPU:%d", cpuid);
362
363 task_thread_info(idle)->cpu = cpuid; 348 task_thread_info(idle)->cpu = cpuid;
364 349
365 /* Let _start know what logical CPU we're booting 350 /* Let _start know what logical CPU we're booting
@@ -403,10 +388,6 @@ int __cpuinit smp_boot_one_cpu(int cpuid)
403 udelay(100); 388 udelay(100);
404 barrier(); 389 barrier();
405 } 390 }
406
407 put_task_struct(idle);
408 idle = NULL;
409
410 printk(KERN_CRIT "SMP: CPU:%d is stuck.\n", cpuid); 391 printk(KERN_CRIT "SMP: CPU:%d is stuck.\n", cpuid);
411 return -1; 392 return -1;
412 393
@@ -455,10 +436,10 @@ void smp_cpus_done(unsigned int cpu_max)
455} 436}
456 437
457 438
458int __cpuinit __cpu_up(unsigned int cpu) 439int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
459{ 440{
460 if (cpu != 0 && cpu < parisc_max_cpus) 441 if (cpu != 0 && cpu < parisc_max_cpus)
461 smp_boot_one_cpu(cpu); 442 smp_boot_one_cpu(cpu, tidle);
462 443
463 return cpu_online(cpu) ? 0 : -ENOSYS; 444 return cpu_online(cpu) ? 0 : -ENOSYS;
464} 445}
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index 82f364e209fc..3ac462de53a4 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -33,6 +33,18 @@
33 33
34extern int data_start; 34extern int data_start;
35 35
36#if PT_NLEVELS == 3
37/* NOTE: This layout exactly conforms to the hybrid L2/L3 page table layout
38 * with the first pmd adjacent to the pgd and below it. gcc doesn't actually
39 * guarantee that global objects will be laid out in memory in the same order
40 * as the order of declaration, so put these in different sections and use
41 * the linker script to order them. */
42pmd_t pmd0[PTRS_PER_PMD] __attribute__ ((__section__ (".data..vm0.pmd"), aligned(PAGE_SIZE)));
43#endif
44
45pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__ ((__section__ (".data..vm0.pgd"), aligned(PAGE_SIZE)));
46pte_t pg0[PT_INITIAL * PTRS_PER_PTE] __attribute__ ((__section__ (".data..vm0.pte"), aligned(PAGE_SIZE)));
47
36#ifdef CONFIG_DISCONTIGMEM 48#ifdef CONFIG_DISCONTIGMEM
37struct node_map_data node_data[MAX_NUMNODES] __read_mostly; 49struct node_map_data node_data[MAX_NUMNODES] __read_mostly;
38unsigned char pfnnid_map[PFNNID_MAP_MAX] __read_mostly; 50unsigned char pfnnid_map[PFNNID_MAP_MAX] __read_mostly;
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 73ec03945717..8a01098eaaca 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -87,10 +87,6 @@ config ARCH_HAS_ILOG2_U64
87 bool 87 bool
88 default y if 64BIT 88 default y if 64BIT
89 89
90config ARCH_HAS_CPU_IDLE_WAIT
91 bool
92 default y
93
94config GENERIC_HWEIGHT 90config GENERIC_HWEIGHT
95 bool 91 bool
96 default y 92 default y
@@ -144,6 +140,7 @@ config PPC
144 select HAVE_BPF_JIT if PPC64 140 select HAVE_BPF_JIT if PPC64
145 select HAVE_ARCH_JUMP_LABEL 141 select HAVE_ARCH_JUMP_LABEL
146 select ARCH_HAVE_NMI_SAFE_CMPXCHG 142 select ARCH_HAVE_NMI_SAFE_CMPXCHG
143 select GENERIC_SMP_IDLE_THREAD
147 144
148config EARLY_PRINTK 145config EARLY_PRINTK
149 bool 146 bool
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index 8e2d0371fe1e..48a26d379222 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -386,7 +386,6 @@ extern unsigned long cpuidle_disable;
386enum idle_boot_override {IDLE_NO_OVERRIDE = 0, IDLE_POWERSAVE_OFF}; 386enum idle_boot_override {IDLE_NO_OVERRIDE = 0, IDLE_POWERSAVE_OFF};
387 387
388extern int powersave_nap; /* set if nap mode can be used in idle loop */ 388extern int powersave_nap; /* set if nap mode can be used in idle loop */
389void cpu_idle_wait(void);
390 389
391#ifdef CONFIG_PSERIES_IDLE 390#ifdef CONFIG_PSERIES_IDLE
392extern void update_smt_snooze_delay(int snooze); 391extern void update_smt_snooze_delay(int snooze);
diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
index 4a741c7efd02..1a1bb00f061a 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -62,21 +62,8 @@ struct thread_info {
62#define init_thread_info (init_thread_union.thread_info) 62#define init_thread_info (init_thread_union.thread_info)
63#define init_stack (init_thread_union.stack) 63#define init_stack (init_thread_union.stack)
64 64
65/* thread information allocation */
66
67#if THREAD_SHIFT >= PAGE_SHIFT
68
69#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT) 65#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT)
70 66
71#else /* THREAD_SHIFT < PAGE_SHIFT */
72
73#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
74
75extern struct thread_info *alloc_thread_info_node(struct task_struct *tsk, int node);
76extern void free_thread_info(struct thread_info *ti);
77
78#endif /* THREAD_SHIFT < PAGE_SHIFT */
79
80/* how to get the thread information struct from C */ 67/* how to get the thread information struct from C */
81static inline struct thread_info *current_thread_info(void) 68static inline struct thread_info *current_thread_info(void)
82{ 69{
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index f5808a35688c..83afacd3ba7b 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -28,7 +28,7 @@ endif
28 28
29obj-y := cputable.o ptrace.o syscalls.o \ 29obj-y := cputable.o ptrace.o syscalls.o \
30 irq.o align.o signal_32.o pmc.o vdso.o \ 30 irq.o align.o signal_32.o pmc.o vdso.o \
31 init_task.o process.o systbl.o idle.o \ 31 process.o systbl.o idle.o \
32 signal.o sysfs.o cacheinfo.o time.o \ 32 signal.o sysfs.o cacheinfo.o time.o \
33 prom.o traps.o setup-common.o \ 33 prom.o traps.o setup-common.o \
34 udbg.o misc.o io.o dma.o \ 34 udbg.o misc.o io.o dma.o \
diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c
index 6d2209ac0c44..2099d9a879e8 100644
--- a/arch/powerpc/kernel/idle.c
+++ b/arch/powerpc/kernel/idle.c
@@ -113,29 +113,6 @@ void cpu_idle(void)
113 } 113 }
114} 114}
115 115
116
117/*
118 * cpu_idle_wait - Used to ensure that all the CPUs come out of the old
119 * idle loop and start using the new idle loop.
120 * Required while changing idle handler on SMP systems.
121 * Caller must have changed idle handler to the new value before the call.
122 * This window may be larger on shared systems.
123 */
124void cpu_idle_wait(void)
125{
126 int cpu;
127 smp_mb();
128
129 /* kick all the CPUs so that they exit out of old idle routine */
130 get_online_cpus();
131 for_each_online_cpu(cpu) {
132 if (cpu != smp_processor_id())
133 smp_send_reschedule(cpu);
134 }
135 put_online_cpus();
136}
137EXPORT_SYMBOL_GPL(cpu_idle_wait);
138
139int powersave_nap; 116int powersave_nap;
140 117
141#ifdef CONFIG_SYSCTL 118#ifdef CONFIG_SYSCTL
diff --git a/arch/powerpc/kernel/init_task.c b/arch/powerpc/kernel/init_task.c
deleted file mode 100644
index d076d465dbd1..000000000000
--- a/arch/powerpc/kernel/init_task.c
+++ /dev/null
@@ -1,29 +0,0 @@
1#include <linux/mm.h>
2#include <linux/export.h>
3#include <linux/sched.h>
4#include <linux/init.h>
5#include <linux/init_task.h>
6#include <linux/fs.h>
7#include <linux/mqueue.h>
8#include <asm/uaccess.h>
9
10static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
11static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
12/*
13 * Initial thread structure.
14 *
15 * We need to make sure that this is 16384-byte aligned due to the
16 * way process stacks are handled. This is done by having a special
17 * "init_task" linker map entry..
18 */
19union thread_union init_thread_union __init_task_data =
20 { INIT_THREAD_INFO(init_task) };
21
22/*
23 * Initial task structure.
24 *
25 * All other task structs will be allocated on slabs in fork.c
26 */
27struct task_struct init_task = INIT_TASK(init_task);
28
29EXPORT_SYMBOL(init_task);
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 4937c9690090..aa05935b6947 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1252,37 +1252,6 @@ void __ppc64_runlatch_off(void)
1252} 1252}
1253#endif /* CONFIG_PPC64 */ 1253#endif /* CONFIG_PPC64 */
1254 1254
1255#if THREAD_SHIFT < PAGE_SHIFT
1256
1257static struct kmem_cache *thread_info_cache;
1258
1259struct thread_info *alloc_thread_info_node(struct task_struct *tsk, int node)
1260{
1261 struct thread_info *ti;
1262
1263 ti = kmem_cache_alloc_node(thread_info_cache, GFP_KERNEL, node);
1264 if (unlikely(ti == NULL))
1265 return NULL;
1266#ifdef CONFIG_DEBUG_STACK_USAGE
1267 memset(ti, 0, THREAD_SIZE);
1268#endif
1269 return ti;
1270}
1271
1272void free_thread_info(struct thread_info *ti)
1273{
1274 kmem_cache_free(thread_info_cache, ti);
1275}
1276
1277void thread_info_cache_init(void)
1278{
1279 thread_info_cache = kmem_cache_create("thread_info", THREAD_SIZE,
1280 THREAD_SIZE, 0, NULL);
1281 BUG_ON(thread_info_cache == NULL);
1282}
1283
1284#endif /* THREAD_SHIFT < PAGE_SHIFT */
1285
1286unsigned long arch_align_stack(unsigned long sp) 1255unsigned long arch_align_stack(unsigned long sp)
1287{ 1256{
1288 if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space) 1257 if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index d9f94410fd7f..e4cb34322de4 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -57,27 +57,9 @@
57#define DBG(fmt...) 57#define DBG(fmt...)
58#endif 58#endif
59 59
60
61/* Store all idle threads, this can be reused instead of creating
62* a new thread. Also avoids complicated thread destroy functionality
63* for idle threads.
64*/
65#ifdef CONFIG_HOTPLUG_CPU 60#ifdef CONFIG_HOTPLUG_CPU
66/*
67 * Needed only for CONFIG_HOTPLUG_CPU because __cpuinitdata is
68 * removed after init for !CONFIG_HOTPLUG_CPU.
69 */
70static DEFINE_PER_CPU(struct task_struct *, idle_thread_array);
71#define get_idle_for_cpu(x) (per_cpu(idle_thread_array, x))
72#define set_idle_for_cpu(x, p) (per_cpu(idle_thread_array, x) = (p))
73
74/* State of each CPU during hotplug phases */ 61/* State of each CPU during hotplug phases */
75static DEFINE_PER_CPU(int, cpu_state) = { 0 }; 62static DEFINE_PER_CPU(int, cpu_state) = { 0 };
76
77#else
78static struct task_struct *idle_thread_array[NR_CPUS] __cpuinitdata ;
79#define get_idle_for_cpu(x) (idle_thread_array[(x)])
80#define set_idle_for_cpu(x, p) (idle_thread_array[(x)] = (p))
81#endif 63#endif
82 64
83struct thread_info *secondary_ti; 65struct thread_info *secondary_ti;
@@ -429,60 +411,19 @@ int generic_check_cpu_restart(unsigned int cpu)
429} 411}
430#endif 412#endif
431 413
432struct create_idle { 414static void cpu_idle_thread_init(unsigned int cpu, struct task_struct *idle)
433 struct work_struct work;
434 struct task_struct *idle;
435 struct completion done;
436 int cpu;
437};
438
439static void __cpuinit do_fork_idle(struct work_struct *work)
440{ 415{
441 struct create_idle *c_idle = 416 struct thread_info *ti = task_thread_info(idle);
442 container_of(work, struct create_idle, work);
443
444 c_idle->idle = fork_idle(c_idle->cpu);
445 complete(&c_idle->done);
446}
447
448static int __cpuinit create_idle(unsigned int cpu)
449{
450 struct thread_info *ti;
451 struct create_idle c_idle = {
452 .cpu = cpu,
453 .done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done),
454 };
455 INIT_WORK_ONSTACK(&c_idle.work, do_fork_idle);
456
457 c_idle.idle = get_idle_for_cpu(cpu);
458
459 /* We can't use kernel_thread since we must avoid to
460 * reschedule the child. We use a workqueue because
461 * we want to fork from a kernel thread, not whatever
462 * userspace process happens to be trying to online us.
463 */
464 if (!c_idle.idle) {
465 schedule_work(&c_idle.work);
466 wait_for_completion(&c_idle.done);
467 } else
468 init_idle(c_idle.idle, cpu);
469 if (IS_ERR(c_idle.idle)) {
470 pr_err("Failed fork for CPU %u: %li", cpu, PTR_ERR(c_idle.idle));
471 return PTR_ERR(c_idle.idle);
472 }
473 ti = task_thread_info(c_idle.idle);
474 417
475#ifdef CONFIG_PPC64 418#ifdef CONFIG_PPC64
476 paca[cpu].__current = c_idle.idle; 419 paca[cpu].__current = idle;
477 paca[cpu].kstack = (unsigned long)ti + THREAD_SIZE - STACK_FRAME_OVERHEAD; 420 paca[cpu].kstack = (unsigned long)ti + THREAD_SIZE - STACK_FRAME_OVERHEAD;
478#endif 421#endif
479 ti->cpu = cpu; 422 ti->cpu = cpu;
480 current_set[cpu] = ti; 423 secondary_ti = current_set[cpu] = ti;
481
482 return 0;
483} 424}
484 425
485int __cpuinit __cpu_up(unsigned int cpu) 426int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
486{ 427{
487 int rc, c; 428 int rc, c;
488 429
@@ -490,12 +431,7 @@ int __cpuinit __cpu_up(unsigned int cpu)
490 (smp_ops->cpu_bootable && !smp_ops->cpu_bootable(cpu))) 431 (smp_ops->cpu_bootable && !smp_ops->cpu_bootable(cpu)))
491 return -EINVAL; 432 return -EINVAL;
492 433
493 /* Make sure we have an idle thread */ 434 cpu_idle_thread_init(cpu, tidle);
494 rc = create_idle(cpu);
495 if (rc)
496 return rc;
497
498 secondary_ti = current_set[cpu];
499 435
500 /* Make sure callin-map entry is 0 (can be leftover a CPU 436 /* Make sure callin-map entry is 0 (can be leftover a CPU
501 * hotplug 437 * hotplug
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index b42f2866594b..e16390c0bca8 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -122,6 +122,7 @@ config S390
122 select ARCH_INLINE_WRITE_UNLOCK_BH 122 select ARCH_INLINE_WRITE_UNLOCK_BH
123 select ARCH_INLINE_WRITE_UNLOCK_IRQ 123 select ARCH_INLINE_WRITE_UNLOCK_IRQ
124 select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE 124 select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE
125 select GENERIC_SMP_IDLE_THREAD
125 126
126config SCHED_OMIT_FRAME_POINTER 127config SCHED_OMIT_FRAME_POINTER
127 def_bool y 128 def_bool y
diff --git a/arch/s390/Makefile b/arch/s390/Makefile
index 0ad2f1e1ce9e..49e76e8b477d 100644
--- a/arch/s390/Makefile
+++ b/arch/s390/Makefile
@@ -91,7 +91,6 @@ OBJCOPYFLAGS := -O binary
91 91
92head-y := arch/s390/kernel/head.o 92head-y := arch/s390/kernel/head.o
93head-y += arch/s390/kernel/$(if $(CONFIG_64BIT),head64.o,head31.o) 93head-y += arch/s390/kernel/$(if $(CONFIG_64BIT),head64.o,head31.o)
94head-y += arch/s390/kernel/init_task.o
95 94
96# See arch/s390/Kbuild for content of core part of the kernel 95# See arch/s390/Kbuild for content of core part of the kernel
97core-y += arch/s390/ 96core-y += arch/s390/
diff --git a/arch/s390/include/asm/smp.h b/arch/s390/include/asm/smp.h
index c77c6de6f6c0..0b6f586c1383 100644
--- a/arch/s390/include/asm/smp.h
+++ b/arch/s390/include/asm/smp.h
@@ -16,7 +16,7 @@
16extern struct mutex smp_cpu_state_mutex; 16extern struct mutex smp_cpu_state_mutex;
17extern struct save_area *zfcpdump_save_areas[NR_CPUS + 1]; 17extern struct save_area *zfcpdump_save_areas[NR_CPUS + 1];
18 18
19extern int __cpu_up(unsigned int cpu); 19extern int __cpu_up(unsigned int cpu, struct task_struct *tidle);
20 20
21extern void arch_send_call_function_single_ipi(int cpu); 21extern void arch_send_call_function_single_ipi(int cpu);
22extern void arch_send_call_function_ipi_mask(const struct cpumask *mask); 22extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
index 884b18afc864..9733b3f0eb6d 100644
--- a/arch/s390/kernel/Makefile
+++ b/arch/s390/kernel/Makefile
@@ -28,7 +28,7 @@ obj-y := bitmap.o traps.o time.o process.o base.o early.o setup.o vtime.o \
28obj-y += $(if $(CONFIG_64BIT),entry64.o,entry.o) 28obj-y += $(if $(CONFIG_64BIT),entry64.o,entry.o)
29obj-y += $(if $(CONFIG_64BIT),reipl64.o,reipl.o) 29obj-y += $(if $(CONFIG_64BIT),reipl64.o,reipl.o)
30 30
31extra-y += head.o init_task.o vmlinux.lds 31extra-y += head.o vmlinux.lds
32extra-y += $(if $(CONFIG_64BIT),head64.o,head31.o) 32extra-y += $(if $(CONFIG_64BIT),head64.o,head31.o)
33 33
34obj-$(CONFIG_MODULES) += s390_ksyms.o module.o 34obj-$(CONFIG_MODULES) += s390_ksyms.o module.o
diff --git a/arch/s390/kernel/init_task.c b/arch/s390/kernel/init_task.c
deleted file mode 100644
index 4d1c9fb0b540..000000000000
--- a/arch/s390/kernel/init_task.c
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * arch/s390/kernel/init_task.c
3 *
4 * S390 version
5 *
6 * Derived from "arch/i386/kernel/init_task.c"
7 */
8
9#include <linux/mm.h>
10#include <linux/fs.h>
11#include <linux/module.h>
12#include <linux/sched.h>
13#include <linux/init_task.h>
14#include <linux/mqueue.h>
15
16#include <asm/uaccess.h>
17#include <asm/pgtable.h>
18
19static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
20static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
21/*
22 * Initial thread structure.
23 *
24 * We need to make sure that this is THREAD_SIZE aligned due to the
25 * way process stacks are handled. This is done by having a special
26 * "init_task" linker map entry..
27 */
28union thread_union init_thread_union __init_task_data =
29 { INIT_THREAD_INFO(init_task) };
30
31/*
32 * Initial task structure.
33 *
34 * All other task structs will be allocated on slabs in fork.c
35 */
36struct task_struct init_task = INIT_TASK(init_task);
37
38EXPORT_SYMBOL(init_task);
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index e505458c6899..647ba9425893 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -85,7 +85,6 @@ enum {
85 85
86struct pcpu { 86struct pcpu {
87 struct cpu cpu; 87 struct cpu cpu;
88 struct task_struct *idle; /* idle process for the cpu */
89 struct _lowcore *lowcore; /* lowcore page(s) for the cpu */ 88 struct _lowcore *lowcore; /* lowcore page(s) for the cpu */
90 unsigned long async_stack; /* async stack for the cpu */ 89 unsigned long async_stack; /* async stack for the cpu */
91 unsigned long panic_stack; /* panic stack for the cpu */ 90 unsigned long panic_stack; /* panic stack for the cpu */
@@ -725,26 +724,9 @@ static void __cpuinit smp_start_secondary(void *cpuvoid)
725 cpu_idle(); 724 cpu_idle();
726} 725}
727 726
728struct create_idle {
729 struct work_struct work;
730 struct task_struct *idle;
731 struct completion done;
732 int cpu;
733};
734
735static void __cpuinit smp_fork_idle(struct work_struct *work)
736{
737 struct create_idle *c_idle;
738
739 c_idle = container_of(work, struct create_idle, work);
740 c_idle->idle = fork_idle(c_idle->cpu);
741 complete(&c_idle->done);
742}
743
744/* Upping and downing of CPUs */ 727/* Upping and downing of CPUs */
745int __cpuinit __cpu_up(unsigned int cpu) 728int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
746{ 729{
747 struct create_idle c_idle;
748 struct pcpu *pcpu; 730 struct pcpu *pcpu;
749 int rc; 731 int rc;
750 732
@@ -754,22 +736,12 @@ int __cpuinit __cpu_up(unsigned int cpu)
754 if (pcpu_sigp_retry(pcpu, sigp_initial_cpu_reset, 0) != 736 if (pcpu_sigp_retry(pcpu, sigp_initial_cpu_reset, 0) !=
755 sigp_order_code_accepted) 737 sigp_order_code_accepted)
756 return -EIO; 738 return -EIO;
757 if (!pcpu->idle) { 739
758 c_idle.done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done);
759 INIT_WORK_ONSTACK(&c_idle.work, smp_fork_idle);
760 c_idle.cpu = cpu;
761 schedule_work(&c_idle.work);
762 wait_for_completion(&c_idle.done);
763 if (IS_ERR(c_idle.idle))
764 return PTR_ERR(c_idle.idle);
765 pcpu->idle = c_idle.idle;
766 }
767 init_idle(pcpu->idle, cpu);
768 rc = pcpu_alloc_lowcore(pcpu, cpu); 740 rc = pcpu_alloc_lowcore(pcpu, cpu);
769 if (rc) 741 if (rc)
770 return rc; 742 return rc;
771 pcpu_prepare_secondary(pcpu, cpu); 743 pcpu_prepare_secondary(pcpu, cpu);
772 pcpu_attach_task(pcpu, pcpu->idle); 744 pcpu_attach_task(pcpu, tidle);
773 pcpu_start_fn(pcpu, smp_start_secondary, NULL); 745 pcpu_start_fn(pcpu, smp_start_secondary, NULL);
774 while (!cpu_online(cpu)) 746 while (!cpu_online(cpu))
775 cpu_relax(); 747 cpu_relax();
@@ -856,7 +828,6 @@ void __init smp_prepare_boot_cpu(void)
856 struct pcpu *pcpu = pcpu_devices; 828 struct pcpu *pcpu = pcpu_devices;
857 829
858 boot_cpu_address = stap(); 830 boot_cpu_address = stap();
859 pcpu->idle = current;
860 pcpu->state = CPU_STATE_CONFIGURED; 831 pcpu->state = CPU_STATE_CONFIGURED;
861 pcpu->address = boot_cpu_address; 832 pcpu->address = boot_cpu_address;
862 pcpu->lowcore = (struct _lowcore *)(unsigned long) store_prefix(); 833 pcpu->lowcore = (struct _lowcore *)(unsigned long) store_prefix();
diff --git a/arch/score/include/asm/thread_info.h b/arch/score/include/asm/thread_info.h
index 2205c62284db..a18006e97f1c 100644
--- a/arch/score/include/asm/thread_info.h
+++ b/arch/score/include/asm/thread_info.h
@@ -11,10 +11,9 @@
11#include <linux/const.h> 11#include <linux/const.h>
12 12
13/* thread information allocation */ 13/* thread information allocation */
14#define THREAD_SIZE_ORDER (1) 14#define THREAD_SIZE_ORDER (1)
15#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) 15#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
16#define THREAD_MASK (THREAD_SIZE - _AC(1,UL)) 16#define THREAD_MASK (THREAD_SIZE - _AC(1,UL))
17#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
18 17
19#ifndef __ASSEMBLY__ 18#ifndef __ASSEMBLY__
20 19
@@ -71,9 +70,6 @@ struct thread_info {
71register struct thread_info *__current_thread_info __asm__("r28"); 70register struct thread_info *__current_thread_info __asm__("r28");
72#define current_thread_info() __current_thread_info 71#define current_thread_info() __current_thread_info
73 72
74#define alloc_thread_info_node(tsk, node) kmalloc_node(THREAD_SIZE, GFP_KERNEL, node)
75#define free_thread_info(info) kfree(info)
76
77#endif /* !__ASSEMBLY__ */ 73#endif /* !__ASSEMBLY__ */
78 74
79#define PREEMPT_ACTIVE 0x10000000 75#define PREEMPT_ACTIVE 0x10000000
diff --git a/arch/score/kernel/Makefile b/arch/score/kernel/Makefile
index f218673b5d3d..fb1802b3f542 100644
--- a/arch/score/kernel/Makefile
+++ b/arch/score/kernel/Makefile
@@ -4,7 +4,7 @@
4 4
5extra-y := head.o vmlinux.lds 5extra-y := head.o vmlinux.lds
6 6
7obj-y += entry.o init_task.o irq.o process.o ptrace.o \ 7obj-y += entry.o irq.o process.o ptrace.o \
8 setup.o signal.o sys_score.o time.o traps.o \ 8 setup.o signal.o sys_score.o time.o traps.o \
9 sys_call_table.o 9 sys_call_table.o
10 10
diff --git a/arch/score/kernel/init_task.c b/arch/score/kernel/init_task.c
deleted file mode 100644
index baa03ee217d1..000000000000
--- a/arch/score/kernel/init_task.c
+++ /dev/null
@@ -1,46 +0,0 @@
1/*
2 * arch/score/kernel/init_task.c
3 *
4 * Score Processor version.
5 *
6 * Copyright (C) 2009 Sunplus Core Technology Co., Ltd.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see the file COPYING, or write
20 * to the Free Software Foundation, Inc.,
21 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#include <linux/init_task.h>
25#include <linux/mqueue.h>
26
27static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
28static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
29
30/*
31 * Initial thread structure.
32 *
33 * We need to make sure that this is THREAD_SIZE aligned due to the
34 * way process stacks are handled. This is done by having a special
35 * "init_task" linker map entry..
36 */
37union thread_union init_thread_union __init_task_data =
38 { INIT_THREAD_INFO(init_task) };
39
40/*
41 * Initial task structure.
42 *
43 * All other task structs will be allocated on slabs in fork.c
44 */
45struct task_struct init_task = INIT_TASK(init_task);
46EXPORT_SYMBOL(init_task);
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index ff9e033ce626..04a8cb4700af 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -28,6 +28,7 @@ config SUPERH
28 select RTC_LIB 28 select RTC_LIB
29 select GENERIC_ATOMIC64 29 select GENERIC_ATOMIC64
30 select GENERIC_IRQ_SHOW 30 select GENERIC_IRQ_SHOW
31 select GENERIC_SMP_IDLE_THREAD
31 help 32 help
32 The SuperH is a RISC processor targeted for use in embedded systems 33 The SuperH is a RISC processor targeted for use in embedded systems
33 and consumer electronics; it was also used in the Sega Dreamcast 34 and consumer electronics; it was also used in the Sega Dreamcast
@@ -152,9 +153,6 @@ config ARCH_NO_VIRT_TO_BUS
152config ARCH_HAS_DEFAULT_IDLE 153config ARCH_HAS_DEFAULT_IDLE
153 def_bool y 154 def_bool y
154 155
155config ARCH_HAS_CPU_IDLE_WAIT
156 def_bool y
157
158config NO_IOPORT 156config NO_IOPORT
159 def_bool !PCI 157 def_bool !PCI
160 depends on !SH_CAYMAN && !SH_SH4202_MICRODEV && !SH_SHMIN 158 depends on !SH_CAYMAN && !SH_SH4202_MICRODEV && !SH_SHMIN
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 3fc0f413777c..e14a676a0c7d 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -124,7 +124,7 @@ endif
124 124
125export ld-bfd BITS 125export ld-bfd BITS
126 126
127head-y := arch/sh/kernel/init_task.o arch/sh/kernel/head_$(BITS).o 127head-y := arch/sh/kernel/head_$(BITS).o
128 128
129core-y += arch/sh/kernel/ arch/sh/mm/ arch/sh/boards/ 129core-y += arch/sh/kernel/ arch/sh/mm/ arch/sh/boards/
130core-$(CONFIG_SH_FPU_EMU) += arch/sh/math-emu/ 130core-$(CONFIG_SH_FPU_EMU) += arch/sh/math-emu/
diff --git a/arch/sh/include/asm/processor.h b/arch/sh/include/asm/processor.h
index a229c393826a..6dbc1be28a0f 100644
--- a/arch/sh/include/asm/processor.h
+++ b/arch/sh/include/asm/processor.h
@@ -85,10 +85,6 @@ struct sh_cpuinfo {
85 struct tlb_info itlb; 85 struct tlb_info itlb;
86 struct tlb_info dtlb; 86 struct tlb_info dtlb;
87 87
88#ifdef CONFIG_SMP
89 struct task_struct *idle;
90#endif
91
92 unsigned int phys_bits; 88 unsigned int phys_bits;
93 unsigned long flags; 89 unsigned long flags;
94} __attribute__ ((aligned(L1_CACHE_BYTES))); 90} __attribute__ ((aligned(L1_CACHE_BYTES)));
@@ -102,7 +98,6 @@ extern struct sh_cpuinfo cpu_data[];
102#define cpu_relax() barrier() 98#define cpu_relax() barrier()
103 99
104void default_idle(void); 100void default_idle(void);
105void cpu_idle_wait(void);
106void stop_this_cpu(void *); 101void stop_this_cpu(void *);
107 102
108/* Forward decl */ 103/* Forward decl */
diff --git a/arch/sh/include/asm/thread_info.h b/arch/sh/include/asm/thread_info.h
index 20ee40af16e9..b6902061d4dc 100644
--- a/arch/sh/include/asm/thread_info.h
+++ b/arch/sh/include/asm/thread_info.h
@@ -88,22 +88,13 @@ static inline struct thread_info *current_thread_info(void)
88 return ti; 88 return ti;
89} 89}
90 90
91/* thread information allocation */
92#if THREAD_SHIFT >= PAGE_SHIFT
93
94#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT) 91#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT)
95 92
96#endif
97
98extern struct thread_info *alloc_thread_info_node(struct task_struct *tsk, int node);
99extern void free_thread_info(struct thread_info *ti);
100extern void arch_task_cache_init(void); 93extern void arch_task_cache_init(void);
101#define arch_task_cache_init arch_task_cache_init
102extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src); 94extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
95extern void arch_release_task_struct(struct task_struct *tsk);
103extern void init_thread_xstate(void); 96extern void init_thread_xstate(void);
104 97
105#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
106
107#endif /* __ASSEMBLY__ */ 98#endif /* __ASSEMBLY__ */
108 99
109/* 100/*
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
index 77f7ae1d4647..88571ff8eeec 100644
--- a/arch/sh/kernel/Makefile
+++ b/arch/sh/kernel/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the Linux/SuperH kernel. 2# Makefile for the Linux/SuperH kernel.
3# 3#
4 4
5extra-y := head_$(BITS).o init_task.o vmlinux.lds 5extra-y := head_$(BITS).o vmlinux.lds
6 6
7ifdef CONFIG_FUNCTION_TRACER 7ifdef CONFIG_FUNCTION_TRACER
8# Do not profile debug and lowlevel utilities 8# Do not profile debug and lowlevel utilities
diff --git a/arch/sh/kernel/idle.c b/arch/sh/kernel/idle.c
index ee226e20c20c..0c910163caa3 100644
--- a/arch/sh/kernel/idle.c
+++ b/arch/sh/kernel/idle.c
@@ -132,10 +132,6 @@ void __init select_idle_routine(void)
132 pm_idle = poll_idle; 132 pm_idle = poll_idle;
133} 133}
134 134
135static void do_nothing(void *unused)
136{
137}
138
139void stop_this_cpu(void *unused) 135void stop_this_cpu(void *unused)
140{ 136{
141 local_irq_disable(); 137 local_irq_disable();
@@ -144,19 +140,3 @@ void stop_this_cpu(void *unused)
144 for (;;) 140 for (;;)
145 cpu_sleep(); 141 cpu_sleep();
146} 142}
147
148/*
149 * cpu_idle_wait - Used to ensure that all the CPUs discard old value of
150 * pm_idle and update to new pm_idle value. Required while changing pm_idle
151 * handler on SMP systems.
152 *
153 * Caller must have changed pm_idle to the new value before the call. Old
154 * pm_idle value will not be used by any CPU after the return of this function.
155 */
156void cpu_idle_wait(void)
157{
158 smp_mb();
159 /* kick all the CPUs so that they exit out of pm_idle */
160 smp_call_function(do_nothing, NULL, 1);
161}
162EXPORT_SYMBOL_GPL(cpu_idle_wait);
diff --git a/arch/sh/kernel/init_task.c b/arch/sh/kernel/init_task.c
deleted file mode 100644
index 11f2ea556a6b..000000000000
--- a/arch/sh/kernel/init_task.c
+++ /dev/null
@@ -1,30 +0,0 @@
1#include <linux/mm.h>
2#include <linux/module.h>
3#include <linux/sched.h>
4#include <linux/init_task.h>
5#include <linux/mqueue.h>
6#include <linux/fs.h>
7#include <asm/uaccess.h>
8#include <asm/pgtable.h>
9
10static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
11static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
12struct pt_regs fake_swapper_regs;
13/*
14 * Initial thread structure.
15 *
16 * We need to make sure that this is 8192-byte aligned due to the
17 * way process stacks are handled. This is done by having a special
18 * "init_task" linker map entry..
19 */
20union thread_union init_thread_union __init_task_data =
21 { INIT_THREAD_INFO(init_task) };
22
23/*
24 * Initial task structure.
25 *
26 * All other task structs will be allocated on slabs in fork.c
27 */
28struct task_struct init_task = INIT_TASK(init_task);
29
30EXPORT_SYMBOL(init_task);
diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index 325f98b1736d..f2621abdf01d 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -29,52 +29,10 @@ void free_thread_xstate(struct task_struct *tsk)
29 } 29 }
30} 30}
31 31
32#if THREAD_SHIFT < PAGE_SHIFT 32void arch_release_task_struct(struct task_struct *tsk)
33static struct kmem_cache *thread_info_cache;
34
35struct thread_info *alloc_thread_info_node(struct task_struct *tsk, int node)
36{
37 struct thread_info *ti;
38#ifdef CONFIG_DEBUG_STACK_USAGE
39 gfp_t mask = GFP_KERNEL | __GFP_ZERO;
40#else
41 gfp_t mask = GFP_KERNEL;
42#endif
43
44 ti = kmem_cache_alloc_node(thread_info_cache, mask, node);
45 return ti;
46}
47
48void free_thread_info(struct thread_info *ti)
49{
50 free_thread_xstate(ti->task);
51 kmem_cache_free(thread_info_cache, ti);
52}
53
54void thread_info_cache_init(void)
55{
56 thread_info_cache = kmem_cache_create("thread_info", THREAD_SIZE,
57 THREAD_SIZE, SLAB_PANIC, NULL);
58}
59#else
60struct thread_info *alloc_thread_info_node(struct task_struct *tsk, int node)
61{
62#ifdef CONFIG_DEBUG_STACK_USAGE
63 gfp_t mask = GFP_KERNEL | __GFP_ZERO;
64#else
65 gfp_t mask = GFP_KERNEL;
66#endif
67 struct page *page = alloc_pages_node(node, mask, THREAD_SIZE_ORDER);
68
69 return page ? page_address(page) : NULL;
70}
71
72void free_thread_info(struct thread_info *ti)
73{ 33{
74 free_thread_xstate(ti->task); 34 free_thread_xstate(tsk);
75 free_pages((unsigned long)ti, THREAD_SIZE_ORDER);
76} 35}
77#endif /* THREAD_SHIFT < PAGE_SHIFT */
78 36
79void arch_task_cache_init(void) 37void arch_task_cache_init(void)
80{ 38{
diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c
index eaebdf6a5c77..b86e9ca79455 100644
--- a/arch/sh/kernel/smp.c
+++ b/arch/sh/kernel/smp.c
@@ -220,22 +220,10 @@ extern struct {
220 void *thread_info; 220 void *thread_info;
221} stack_start; 221} stack_start;
222 222
223int __cpuinit __cpu_up(unsigned int cpu) 223int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tsk)
224{ 224{
225 struct task_struct *tsk;
226 unsigned long timeout; 225 unsigned long timeout;
227 226
228 tsk = cpu_data[cpu].idle;
229 if (!tsk) {
230 tsk = fork_idle(cpu);
231 if (IS_ERR(tsk)) {
232 pr_err("Failed forking idle task for cpu %d\n", cpu);
233 return PTR_ERR(tsk);
234 }
235
236 cpu_data[cpu].idle = tsk;
237 }
238
239 per_cpu(cpu_state, cpu) = CPU_UP_PREPARE; 227 per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
240 228
241 /* Fill in data in head.S for secondary cpus */ 229 /* Fill in data in head.S for secondary cpus */
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index d176c03274c5..b2b9daf59051 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -31,11 +31,13 @@ config SPARC
31 select GENERIC_PCI_IOMAP 31 select GENERIC_PCI_IOMAP
32 select HAVE_NMI_WATCHDOG if SPARC64 32 select HAVE_NMI_WATCHDOG if SPARC64
33 select HAVE_BPF_JIT 33 select HAVE_BPF_JIT
34 select GENERIC_SMP_IDLE_THREAD
34 35
35config SPARC32 36config SPARC32
36 def_bool !64BIT 37 def_bool !64BIT
37 select GENERIC_ATOMIC64 38 select GENERIC_ATOMIC64
38 select CLZ_TAB 39 select CLZ_TAB
40 select ARCH_THREAD_INFO_ALLOCATOR
39 41
40config SPARC64 42config SPARC64
41 def_bool 64BIT 43 def_bool 64BIT
diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
index b9a72e2b8acc..541b8b075c7d 100644
--- a/arch/sparc/Makefile
+++ b/arch/sparc/Makefile
@@ -50,7 +50,6 @@ endif
50endif 50endif
51 51
52head-y := arch/sparc/kernel/head_$(BITS).o 52head-y := arch/sparc/kernel/head_$(BITS).o
53head-y += arch/sparc/kernel/init_task.o
54 53
55# See arch/sparc/Kbuild for the core part of the kernel 54# See arch/sparc/Kbuild for the core part of the kernel
56core-y += arch/sparc/ 55core-y += arch/sparc/
diff --git a/arch/sparc/include/asm/leon.h b/arch/sparc/include/asm/leon.h
index 24f802beffb9..07659124c140 100644
--- a/arch/sparc/include/asm/leon.h
+++ b/arch/sparc/include/asm/leon.h
@@ -270,6 +270,7 @@ struct leon2_cacheregs {
270#include <linux/interrupt.h> 270#include <linux/interrupt.h>
271 271
272struct device_node; 272struct device_node;
273struct task_struct;
273extern unsigned int leon_build_device_irq(unsigned int real_irq, 274extern unsigned int leon_build_device_irq(unsigned int real_irq,
274 irq_flow_handler_t flow_handler, 275 irq_flow_handler_t flow_handler,
275 const char *name, int do_ack); 276 const char *name, int do_ack);
@@ -289,7 +290,7 @@ extern int leon_smp_nrcpus(void);
289extern void leon_clear_profile_irq(int cpu); 290extern void leon_clear_profile_irq(int cpu);
290extern void leon_smp_done(void); 291extern void leon_smp_done(void);
291extern void leon_boot_cpus(void); 292extern void leon_boot_cpus(void);
292extern int leon_boot_one_cpu(int i); 293extern int leon_boot_one_cpu(int i, struct task_struct *);
293void leon_init_smp(void); 294void leon_init_smp(void);
294extern void cpu_idle(void); 295extern void cpu_idle(void);
295extern void init_IRQ(void); 296extern void init_IRQ(void);
@@ -325,7 +326,7 @@ extern int leon_ipi_irq;
325#define init_leon() do {} while (0) 326#define init_leon() do {} while (0)
326#define leon_smp_done() do {} while (0) 327#define leon_smp_done() do {} while (0)
327#define leon_boot_cpus() do {} while (0) 328#define leon_boot_cpus() do {} while (0)
328#define leon_boot_one_cpu(i) 1 329#define leon_boot_one_cpu(i, t) 1
329#define leon_init_smp() do {} while (0) 330#define leon_init_smp() do {} while (0)
330 331
331#endif /* !defined(CONFIG_SPARC_LEON) */ 332#endif /* !defined(CONFIG_SPARC_LEON) */
diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
index cd0b2dc8fab9..21a38946541d 100644
--- a/arch/sparc/include/asm/thread_info_32.h
+++ b/arch/sparc/include/asm/thread_info_32.h
@@ -79,8 +79,6 @@ register struct thread_info *current_thread_info_reg asm("g6");
79 */ 79 */
80#define THREAD_INFO_ORDER 1 80#define THREAD_INFO_ORDER 1
81 81
82#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
83
84struct thread_info * alloc_thread_info_node(struct task_struct *tsk, int node); 82struct thread_info * alloc_thread_info_node(struct task_struct *tsk, int node);
85void free_thread_info(struct thread_info *); 83void free_thread_info(struct thread_info *);
86 84
diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
index 01d057fe6a3f..7f0981b09451 100644
--- a/arch/sparc/include/asm/thread_info_64.h
+++ b/arch/sparc/include/asm/thread_info_64.h
@@ -138,32 +138,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
138 138
139/* thread information allocation */ 139/* thread information allocation */
140#if PAGE_SHIFT == 13 140#if PAGE_SHIFT == 13
141#define __THREAD_INFO_ORDER 1 141#define THREAD_SIZE_ORDER 1
142#else /* PAGE_SHIFT == 13 */ 142#else /* PAGE_SHIFT == 13 */
143#define __THREAD_INFO_ORDER 0 143#define THREAD_SIZE_ORDER 0
144#endif /* PAGE_SHIFT == 13 */ 144#endif /* PAGE_SHIFT == 13 */
145 145
146#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
147
148#ifdef CONFIG_DEBUG_STACK_USAGE
149#define THREAD_FLAGS (GFP_KERNEL | __GFP_ZERO)
150#else
151#define THREAD_FLAGS (GFP_KERNEL)
152#endif
153
154#define alloc_thread_info_node(tsk, node) \
155({ \
156 struct page *page = alloc_pages_node(node, THREAD_FLAGS, \
157 __THREAD_INFO_ORDER); \
158 struct thread_info *ret; \
159 \
160 ret = page ? page_address(page) : NULL; \
161 ret; \
162})
163
164#define free_thread_info(ti) \
165 free_pages((unsigned long)(ti),__THREAD_INFO_ORDER)
166
167#define __thread_flag_byte_ptr(ti) \ 146#define __thread_flag_byte_ptr(ti) \
168 ((unsigned char *)(&((ti)->flags))) 147 ((unsigned char *)(&((ti)->flags)))
169#define __cur_thread_flag_byte_ptr __thread_flag_byte_ptr(current_thread_info()) 148#define __cur_thread_flag_byte_ptr __thread_flag_byte_ptr(current_thread_info())
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index c19dd022b9cb..72308f9b0096 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -6,7 +6,6 @@ asflags-y := -ansi
6ccflags-y := -Werror 6ccflags-y := -Werror
7 7
8extra-y := head_$(BITS).o 8extra-y := head_$(BITS).o
9extra-y += init_task.o
10 9
11# Undefine sparc when processing vmlinux.lds - it is used 10# Undefine sparc when processing vmlinux.lds - it is used
12# And teach CPP we are doing $(BITS) builds (for this case) 11# And teach CPP we are doing $(BITS) builds (for this case)
diff --git a/arch/sparc/kernel/init_task.c b/arch/sparc/kernel/init_task.c
deleted file mode 100644
index 35f141a9f506..000000000000
--- a/arch/sparc/kernel/init_task.c
+++ /dev/null
@@ -1,22 +0,0 @@
1#include <linux/mm.h>
2#include <linux/fs.h>
3#include <linux/module.h>
4#include <linux/sched.h>
5#include <linux/init_task.h>
6#include <linux/mqueue.h>
7
8#include <asm/pgtable.h>
9#include <asm/uaccess.h>
10
11static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
12static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
13struct task_struct init_task = INIT_TASK(init_task);
14EXPORT_SYMBOL(init_task);
15
16/* .text section in head.S is aligned at 8k boundary and this gets linked
17 * right after that so that the init_thread_union is aligned properly as well.
18 * If this is not aligned on a 8k boundary, then you should change code
19 * in etrap.S which assumes it.
20 */
21union thread_union init_thread_union __init_task_data =
22 { INIT_THREAD_INFO(init_task) };
diff --git a/arch/sparc/kernel/leon_smp.c b/arch/sparc/kernel/leon_smp.c
index 29325bacba6f..a469090faf9f 100644
--- a/arch/sparc/kernel/leon_smp.c
+++ b/arch/sparc/kernel/leon_smp.c
@@ -203,16 +203,11 @@ void __init leon_boot_cpus(void)
203 203
204} 204}
205 205
206int __cpuinit leon_boot_one_cpu(int i) 206int __cpuinit leon_boot_one_cpu(int i, struct task_struct *idle)
207{ 207{
208
209 struct task_struct *p;
210 int timeout; 208 int timeout;
211 209
212 /* Cook up an idler for this guy. */ 210 current_set[i] = task_thread_info(idle);
213 p = fork_idle(i);
214
215 current_set[i] = task_thread_info(p);
216 211
217 /* See trampoline.S:leon_smp_cpu_startup for details... 212 /* See trampoline.S:leon_smp_cpu_startup for details...
218 * Initialize the contexts table 213 * Initialize the contexts table
diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c
index 57713758079e..79db45e5134a 100644
--- a/arch/sparc/kernel/smp_32.c
+++ b/arch/sparc/kernel/smp_32.c
@@ -256,21 +256,21 @@ void __init smp_prepare_boot_cpu(void)
256 set_cpu_possible(cpuid, true); 256 set_cpu_possible(cpuid, true);
257} 257}
258 258
259int __cpuinit __cpu_up(unsigned int cpu) 259int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
260{ 260{
261 extern int __cpuinit smp4m_boot_one_cpu(int); 261 extern int __cpuinit smp4m_boot_one_cpu(int, struct task_struct *);
262 extern int __cpuinit smp4d_boot_one_cpu(int); 262 extern int __cpuinit smp4d_boot_one_cpu(int, struct task_struct *);
263 int ret=0; 263 int ret=0;
264 264
265 switch(sparc_cpu_model) { 265 switch(sparc_cpu_model) {
266 case sun4m: 266 case sun4m:
267 ret = smp4m_boot_one_cpu(cpu); 267 ret = smp4m_boot_one_cpu(cpu, tidle);
268 break; 268 break;
269 case sun4d: 269 case sun4d:
270 ret = smp4d_boot_one_cpu(cpu); 270 ret = smp4d_boot_one_cpu(cpu, tidle);
271 break; 271 break;
272 case sparc_leon: 272 case sparc_leon:
273 ret = leon_boot_one_cpu(cpu); 273 ret = leon_boot_one_cpu(cpu, tidle);
274 break; 274 break;
275 case sun4e: 275 case sun4e:
276 printk("SUN4E\n"); 276 printk("SUN4E\n");
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 3b1bd7c50164..f591598d92f6 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -343,21 +343,17 @@ extern unsigned long sparc64_cpu_startup;
343 */ 343 */
344static struct thread_info *cpu_new_thread = NULL; 344static struct thread_info *cpu_new_thread = NULL;
345 345
346static int __cpuinit smp_boot_one_cpu(unsigned int cpu) 346static int __cpuinit smp_boot_one_cpu(unsigned int cpu, struct task_struct *idle)
347{ 347{
348 unsigned long entry = 348 unsigned long entry =
349 (unsigned long)(&sparc64_cpu_startup); 349 (unsigned long)(&sparc64_cpu_startup);
350 unsigned long cookie = 350 unsigned long cookie =
351 (unsigned long)(&cpu_new_thread); 351 (unsigned long)(&cpu_new_thread);
352 struct task_struct *p;
353 void *descr = NULL; 352 void *descr = NULL;
354 int timeout, ret; 353 int timeout, ret;
355 354
356 p = fork_idle(cpu);
357 if (IS_ERR(p))
358 return PTR_ERR(p);
359 callin_flag = 0; 355 callin_flag = 0;
360 cpu_new_thread = task_thread_info(p); 356 cpu_new_thread = task_thread_info(idle);
361 357
362 if (tlb_type == hypervisor) { 358 if (tlb_type == hypervisor) {
363#if defined(CONFIG_SUN_LDOMS) && defined(CONFIG_HOTPLUG_CPU) 359#if defined(CONFIG_SUN_LDOMS) && defined(CONFIG_HOTPLUG_CPU)
@@ -1227,9 +1223,9 @@ void __devinit smp_fill_in_sib_core_maps(void)
1227 } 1223 }
1228} 1224}
1229 1225
1230int __cpuinit __cpu_up(unsigned int cpu) 1226int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
1231{ 1227{
1232 int ret = smp_boot_one_cpu(cpu); 1228 int ret = smp_boot_one_cpu(cpu, tidle);
1233 1229
1234 if (!ret) { 1230 if (!ret) {
1235 cpumask_set_cpu(cpu, &smp_commenced_mask); 1231 cpumask_set_cpu(cpu, &smp_commenced_mask);
diff --git a/arch/sparc/kernel/sun4d_smp.c b/arch/sparc/kernel/sun4d_smp.c
index f9a1a33cbb2c..ddaea31de586 100644
--- a/arch/sparc/kernel/sun4d_smp.c
+++ b/arch/sparc/kernel/sun4d_smp.c
@@ -129,18 +129,14 @@ void __init smp4d_boot_cpus(void)
129 local_ops->cache_all(); 129 local_ops->cache_all();
130} 130}
131 131
132int __cpuinit smp4d_boot_one_cpu(int i) 132int __cpuinit smp4d_boot_one_cpu(int i, struct task_struct *idle)
133{ 133{
134 unsigned long *entry = &sun4d_cpu_startup; 134 unsigned long *entry = &sun4d_cpu_startup;
135 struct task_struct *p;
136 int timeout; 135 int timeout;
137 int cpu_node; 136 int cpu_node;
138 137
139 cpu_find_by_instance(i, &cpu_node, NULL); 138 cpu_find_by_instance(i, &cpu_node, NULL);
140 /* Cook up an idler for this guy. */ 139 current_set[i] = task_thread_info(idle);
141 p = fork_idle(i);
142 current_set[i] = task_thread_info(p);
143
144 /* 140 /*
145 * Initialize the contexts table 141 * Initialize the contexts table
146 * Since the call to prom_startcpu() trashes the structure, 142 * Since the call to prom_startcpu() trashes the structure,
diff --git a/arch/sparc/kernel/sun4m_smp.c b/arch/sparc/kernel/sun4m_smp.c
index 960e8ab47b12..128af7304288 100644
--- a/arch/sparc/kernel/sun4m_smp.c
+++ b/arch/sparc/kernel/sun4m_smp.c
@@ -90,18 +90,15 @@ void __init smp4m_boot_cpus(void)
90 local_ops->cache_all(); 90 local_ops->cache_all();
91} 91}
92 92
93int __cpuinit smp4m_boot_one_cpu(int i) 93int __cpuinit smp4m_boot_one_cpu(int i, struct task_struct *idle)
94{ 94{
95 unsigned long *entry = &sun4m_cpu_startup; 95 unsigned long *entry = &sun4m_cpu_startup;
96 struct task_struct *p;
97 int timeout; 96 int timeout;
98 int cpu_node; 97 int cpu_node;
99 98
100 cpu_find_by_mid(i, &cpu_node); 99 cpu_find_by_mid(i, &cpu_node);
100 current_set[i] = task_thread_info(idle);
101 101
102 /* Cook up an idler for this guy. */
103 p = fork_idle(i);
104 current_set[i] = task_thread_info(p);
105 /* See trampoline.S for details... */ 102 /* See trampoline.S for details... */
106 entry += ((i - 1) * 3); 103 entry += ((i - 1) * 3);
107 104
diff --git a/arch/tile/include/asm/thread_info.h b/arch/tile/include/asm/thread_info.h
index 7594764d8a69..656c486e64fa 100644
--- a/arch/tile/include/asm/thread_info.h
+++ b/arch/tile/include/asm/thread_info.h
@@ -77,16 +77,14 @@ struct thread_info {
77 77
78#ifndef __ASSEMBLY__ 78#ifndef __ASSEMBLY__
79 79
80void arch_release_thread_info(struct thread_info *info);
81
80/* How to get the thread information struct from C. */ 82/* How to get the thread information struct from C. */
81register unsigned long stack_pointer __asm__("sp"); 83register unsigned long stack_pointer __asm__("sp");
82 84
83#define current_thread_info() \ 85#define current_thread_info() \
84 ((struct thread_info *)(stack_pointer & -THREAD_SIZE)) 86 ((struct thread_info *)(stack_pointer & -THREAD_SIZE))
85 87
86#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
87extern struct thread_info *alloc_thread_info_node(struct task_struct *task, int node);
88extern void free_thread_info(struct thread_info *info);
89
90/* Sit on a nap instruction until interrupted. */ 88/* Sit on a nap instruction until interrupted. */
91extern void smp_nap(void); 89extern void smp_nap(void);
92 90
diff --git a/arch/tile/kernel/Makefile b/arch/tile/kernel/Makefile
index b4dbc057baad..0d826faf8f35 100644
--- a/arch/tile/kernel/Makefile
+++ b/arch/tile/kernel/Makefile
@@ -3,7 +3,7 @@
3# 3#
4 4
5extra-y := vmlinux.lds head_$(BITS).o 5extra-y := vmlinux.lds head_$(BITS).o
6obj-y := backtrace.o entry.o init_task.o irq.o messaging.o \ 6obj-y := backtrace.o entry.o irq.o messaging.o \
7 pci-dma.o proc.o process.o ptrace.o reboot.o \ 7 pci-dma.o proc.o process.o ptrace.o reboot.o \
8 setup.o signal.o single_step.o stack.o sys.o sysfs.o time.o traps.o \ 8 setup.o signal.o single_step.o stack.o sys.o sysfs.o time.o traps.o \
9 intvec_$(BITS).o regs_$(BITS).o tile-desc_$(BITS).o 9 intvec_$(BITS).o regs_$(BITS).o tile-desc_$(BITS).o
diff --git a/arch/tile/kernel/init_task.c b/arch/tile/kernel/init_task.c
deleted file mode 100644
index 928b31870669..000000000000
--- a/arch/tile/kernel/init_task.c
+++ /dev/null
@@ -1,59 +0,0 @@
1/*
2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 */
14
15#include <linux/mm.h>
16#include <linux/fs.h>
17#include <linux/init_task.h>
18#include <linux/mqueue.h>
19#include <linux/module.h>
20#include <linux/start_kernel.h>
21#include <linux/uaccess.h>
22
23static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
24static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
25
26/*
27 * Initial thread structure.
28 *
29 * We need to make sure that this is THREAD_SIZE aligned due to the
30 * way process stacks are handled. This is done by having a special
31 * "init_task" linker map entry..
32 */
33union thread_union init_thread_union __init_task_data = {
34 INIT_THREAD_INFO(init_task)
35};
36
37/*
38 * Initial task structure.
39 *
40 * All other task structs will be allocated on slabs in fork.c
41 */
42struct task_struct init_task = INIT_TASK(init_task);
43EXPORT_SYMBOL(init_task);
44
45/*
46 * per-CPU stack and boot info.
47 */
48DEFINE_PER_CPU(unsigned long, boot_sp) =
49 (unsigned long)init_stack + THREAD_SIZE;
50
51#ifdef CONFIG_SMP
52DEFINE_PER_CPU(unsigned long, boot_pc) = (unsigned long)start_kernel;
53#else
54/*
55 * The variable must be __initdata since it references __init code.
56 * With CONFIG_SMP it is per-cpu data, which is exempt from validation.
57 */
58unsigned long __initdata boot_pc = (unsigned long)start_kernel;
59#endif
diff --git a/arch/tile/kernel/process.c b/arch/tile/kernel/process.c
index 54e6c64b85cc..f572c19c4082 100644
--- a/arch/tile/kernel/process.c
+++ b/arch/tile/kernel/process.c
@@ -114,27 +114,10 @@ void cpu_idle(void)
114 } 114 }
115} 115}
116 116
117struct thread_info *alloc_thread_info_node(struct task_struct *task, int node)
118{
119 struct page *page;
120 gfp_t flags = GFP_KERNEL;
121
122#ifdef CONFIG_DEBUG_STACK_USAGE
123 flags |= __GFP_ZERO;
124#endif
125
126 page = alloc_pages_node(node, flags, THREAD_SIZE_ORDER);
127 if (!page)
128 return NULL;
129
130 return (struct thread_info *)page_address(page);
131}
132
133/* 117/*
134 * Free a thread_info node, and all of its derivative 118 * Release a thread_info structure
135 * data structures.
136 */ 119 */
137void free_thread_info(struct thread_info *info) 120void arch_release_thread_info(struct thread_info *info)
138{ 121{
139 struct single_step_state *step_state = info->step_state; 122 struct single_step_state *step_state = info->step_state;
140 123
@@ -169,8 +152,6 @@ void free_thread_info(struct thread_info *info)
169 */ 152 */
170 kfree(step_state); 153 kfree(step_state);
171 } 154 }
172
173 free_pages((unsigned long)info, THREAD_SIZE_ORDER);
174} 155}
175 156
176static void save_arch_state(struct thread_struct *t); 157static void save_arch_state(struct thread_struct *t);
diff --git a/arch/tile/kernel/setup.c b/arch/tile/kernel/setup.c
index bff23f476110..98d80eb49ddb 100644
--- a/arch/tile/kernel/setup.c
+++ b/arch/tile/kernel/setup.c
@@ -61,6 +61,22 @@ unsigned long __initdata node_free_pfn[MAX_NUMNODES];
61 61
62static unsigned long __initdata node_percpu[MAX_NUMNODES]; 62static unsigned long __initdata node_percpu[MAX_NUMNODES];
63 63
64/*
65 * per-CPU stack and boot info.
66 */
67DEFINE_PER_CPU(unsigned long, boot_sp) =
68 (unsigned long)init_stack + THREAD_SIZE;
69
70#ifdef CONFIG_SMP
71DEFINE_PER_CPU(unsigned long, boot_pc) = (unsigned long)start_kernel;
72#else
73/*
74 * The variable must be __initdata since it references __init code.
75 * With CONFIG_SMP it is per-cpu data, which is exempt from validation.
76 */
77unsigned long __initdata boot_pc = (unsigned long)start_kernel;
78#endif
79
64#ifdef CONFIG_HIGHMEM 80#ifdef CONFIG_HIGHMEM
65/* Page frame index of end of lowmem on each controller. */ 81/* Page frame index of end of lowmem on each controller. */
66unsigned long __cpuinitdata node_lowmem_end_pfn[MAX_NUMNODES]; 82unsigned long __cpuinitdata node_lowmem_end_pfn[MAX_NUMNODES];
diff --git a/arch/tile/kernel/smpboot.c b/arch/tile/kernel/smpboot.c
index 172aef7d3159..84873fbe8f27 100644
--- a/arch/tile/kernel/smpboot.c
+++ b/arch/tile/kernel/smpboot.c
@@ -222,7 +222,7 @@ void __cpuinit online_secondary(void)
222 cpu_idle(); 222 cpu_idle();
223} 223}
224 224
225int __cpuinit __cpu_up(unsigned int cpu) 225int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
226{ 226{
227 /* Wait 5s total for all CPUs for them to come online */ 227 /* Wait 5s total for all CPUs for them to come online */
228 static int timeout; 228 static int timeout;
diff --git a/arch/um/include/asm/processor-generic.h b/arch/um/include/asm/processor-generic.h
index 98d01bc4fa92..7827394a5b6c 100644
--- a/arch/um/include/asm/processor-generic.h
+++ b/arch/um/include/asm/processor-generic.h
@@ -68,8 +68,6 @@ struct thread_struct {
68 .request = { 0 } \ 68 .request = { 0 } \
69} 69}
70 70
71extern struct task_struct *alloc_task_struct_node(int node);
72
73static inline void release_thread(struct task_struct *task) 71static inline void release_thread(struct task_struct *task)
74{ 72{
75} 73}
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile
index 65a1c3d690ea..babe21826e3e 100644
--- a/arch/um/kernel/Makefile
+++ b/arch/um/kernel/Makefile
@@ -10,7 +10,7 @@ CPPFLAGS_vmlinux.lds := -DSTART=$(LDS_START) \
10extra-y := vmlinux.lds 10extra-y := vmlinux.lds
11clean-files := 11clean-files :=
12 12
13obj-y = config.o exec.o exitcode.o init_task.o irq.o ksyms.o mem.o \ 13obj-y = config.o exec.o exitcode.o irq.o ksyms.o mem.o \
14 physmem.o process.o ptrace.o reboot.o sigio.o \ 14 physmem.o process.o ptrace.o reboot.o sigio.o \
15 signal.o smp.o syscall.o sysrq.o time.o tlb.o trap.o \ 15 signal.o smp.o syscall.o sysrq.o time.o tlb.o trap.o \
16 um_arch.o umid.o skas/ 16 um_arch.o umid.o skas/
diff --git a/arch/um/kernel/init_task.c b/arch/um/kernel/init_task.c
deleted file mode 100644
index ddc9698b66ed..000000000000
--- a/arch/um/kernel/init_task.c
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,intel.linux}.com)
3 * Licensed under the GPL
4 */
5
6#include "linux/sched.h"
7#include "linux/init_task.h"
8#include "linux/fs.h"
9#include "linux/module.h"
10#include "linux/mqueue.h"
11#include "asm/uaccess.h"
12
13static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
14static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
15/*
16 * Initial task structure.
17 *
18 * All other task structs will be allocated on slabs in fork.c
19 */
20
21struct task_struct init_task = INIT_TASK(init_task);
22
23EXPORT_SYMBOL(init_task);
24
25/*
26 * Initial thread structure.
27 *
28 * We need to make sure that this is aligned due to the
29 * way process stacks are handled. This is done by having a special
30 * "init_task" linker map entry..
31 */
32
33union thread_union init_thread_union __init_task_data =
34 { INIT_THREAD_INFO(init_task) };
35
36union thread_union cpu0_irqstack
37 __attribute__((__section__(".data..init_irqstack"))) =
38 { INIT_THREAD_INFO(init_task) };
diff --git a/arch/um/kernel/smp.c b/arch/um/kernel/smp.c
index 6f588e160fb0..a02b7e9e6b94 100644
--- a/arch/um/kernel/smp.c
+++ b/arch/um/kernel/smp.c
@@ -140,7 +140,7 @@ void smp_prepare_boot_cpu(void)
140 set_cpu_online(smp_processor_id(), true); 140 set_cpu_online(smp_processor_id(), true);
141} 141}
142 142
143int __cpu_up(unsigned int cpu) 143int __cpu_up(unsigned int cpu, struct task_struct *tidle)
144{ 144{
145 cpu_set(cpu, smp_commenced_mask); 145 cpu_set(cpu, smp_commenced_mask);
146 while (!cpu_online(cpu)) 146 while (!cpu_online(cpu))
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index ba00eae45aad..4db8770906ca 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -10,6 +10,7 @@
10#include <linux/seq_file.h> 10#include <linux/seq_file.h>
11#include <linux/string.h> 11#include <linux/string.h>
12#include <linux/utsname.h> 12#include <linux/utsname.h>
13#include <linux/sched.h>
13#include <asm/pgtable.h> 14#include <asm/pgtable.h>
14#include <asm/processor.h> 15#include <asm/processor.h>
15#include <asm/setup.h> 16#include <asm/setup.h>
@@ -47,6 +48,10 @@ struct cpuinfo_um boot_cpu_data = {
47 .ipi_pipe = { -1, -1 } 48 .ipi_pipe = { -1, -1 }
48}; 49};
49 50
51union thread_union cpu0_irqstack
52 __attribute__((__section__(".data..init_irqstack"))) =
53 { INIT_THREAD_INFO(init_task) };
54
50unsigned long thread_saved_pc(struct task_struct *task) 55unsigned long thread_saved_pc(struct task_struct *task)
51{ 56{
52 /* FIXME: Need to look up userspace_pid by cpu */ 57 /* FIXME: Need to look up userspace_pid by cpu */
diff --git a/arch/unicore32/Makefile b/arch/unicore32/Makefile
index 6af4bc415f2b..b6f5c4c1eaf9 100644
--- a/arch/unicore32/Makefile
+++ b/arch/unicore32/Makefile
@@ -33,7 +33,6 @@ endif
33CHECKFLAGS += -D__unicore32__ 33CHECKFLAGS += -D__unicore32__
34 34
35head-y := arch/unicore32/kernel/head.o 35head-y := arch/unicore32/kernel/head.o
36head-y += arch/unicore32/kernel/init_task.o
37 36
38core-y += arch/unicore32/kernel/ 37core-y += arch/unicore32/kernel/
39core-y += arch/unicore32/mm/ 38core-y += arch/unicore32/mm/
diff --git a/arch/unicore32/kernel/Makefile b/arch/unicore32/kernel/Makefile
index aeb0f181568e..324010156958 100644
--- a/arch/unicore32/kernel/Makefile
+++ b/arch/unicore32/kernel/Makefile
@@ -29,4 +29,4 @@ obj-$(CONFIG_PUV3_NB0916) += puv3-nb0916.o
29head-y := head.o 29head-y := head.o
30obj-$(CONFIG_DEBUG_LL) += debug.o 30obj-$(CONFIG_DEBUG_LL) += debug.o
31 31
32extra-y := $(head-y) init_task.o vmlinux.lds 32extra-y := $(head-y) vmlinux.lds
diff --git a/arch/unicore32/kernel/init_task.c b/arch/unicore32/kernel/init_task.c
deleted file mode 100644
index a35a1e50e4f4..000000000000
--- a/arch/unicore32/kernel/init_task.c
+++ /dev/null
@@ -1,44 +0,0 @@
1/*
2 * linux/arch/unicore32/kernel/init_task.c
3 *
4 * Code specific to PKUnity SoC and UniCore ISA
5 *
6 * Copyright (C) 2001-2010 GUAN Xue-tao
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#include <linux/mm.h>
13#include <linux/module.h>
14#include <linux/fs.h>
15#include <linux/sched.h>
16#include <linux/init.h>
17#include <linux/init_task.h>
18#include <linux/mqueue.h>
19#include <linux/uaccess.h>
20
21#include <asm/pgtable.h>
22
23static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
24static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
25/*
26 * Initial thread structure.
27 *
28 * We need to make sure that this is 8192-byte aligned due to the
29 * way process stacks are handled. This is done by making sure
30 * the linker maps this in the .text segment right after head.S,
31 * and making head.S ensure the proper alignment.
32 *
33 * The things we do for performance..
34 */
35union thread_union init_thread_union __init_task_data = {
36 INIT_THREAD_INFO(init_task) };
37
38/*
39 * Initial task structure.
40 *
41 * All other task structs will be allocated on slabs in fork.c
42 */
43struct task_struct init_task = INIT_TASK(init_task);
44EXPORT_SYMBOL(init_task);
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 25f87bccbf8f..c940cb6f0409 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -82,6 +82,7 @@ config X86
82 select ARCH_HAVE_NMI_SAFE_CMPXCHG 82 select ARCH_HAVE_NMI_SAFE_CMPXCHG
83 select GENERIC_IOMAP 83 select GENERIC_IOMAP
84 select DCACHE_WORD_ACCESS 84 select DCACHE_WORD_ACCESS
85 select GENERIC_SMP_IDLE_THREAD
85 86
86config INSTRUCTION_DECODER 87config INSTRUCTION_DECODER
87 def_bool (KPROBES || PERF_EVENTS) 88 def_bool (KPROBES || PERF_EVENTS)
@@ -160,9 +161,6 @@ config RWSEM_GENERIC_SPINLOCK
160config RWSEM_XCHGADD_ALGORITHM 161config RWSEM_XCHGADD_ALGORITHM
161 def_bool X86_XADD 162 def_bool X86_XADD
162 163
163config ARCH_HAS_CPU_IDLE_WAIT
164 def_bool y
165
166config GENERIC_CALIBRATE_DELAY 164config GENERIC_CALIBRATE_DELAY
167 def_bool y 165 def_bool y
168 166
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 94e91e401da9..277418ff8b52 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -149,7 +149,6 @@ archheaders:
149head-y := arch/x86/kernel/head_$(BITS).o 149head-y := arch/x86/kernel/head_$(BITS).o
150head-y += arch/x86/kernel/head$(BITS).o 150head-y += arch/x86/kernel/head$(BITS).o
151head-y += arch/x86/kernel/head.o 151head-y += arch/x86/kernel/head.o
152head-y += arch/x86/kernel/init_task.o
153 152
154libs-y += arch/x86/lib/ 153libs-y += arch/x86/lib/
155 154
diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
index 5e1a2eef3e7c..b13fe63bdc59 100644
--- a/arch/x86/include/asm/boot.h
+++ b/arch/x86/include/asm/boot.h
@@ -19,7 +19,7 @@
19#ifdef CONFIG_X86_64 19#ifdef CONFIG_X86_64
20#define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT 20#define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
21#else 21#else
22#define MIN_KERNEL_ALIGN_LG2 (PAGE_SHIFT + THREAD_ORDER) 22#define MIN_KERNEL_ALIGN_LG2 (PAGE_SHIFT + THREAD_SIZE_ORDER)
23#endif 23#endif
24#define MIN_KERNEL_ALIGN (_AC(1, UL) << MIN_KERNEL_ALIGN_LG2) 24#define MIN_KERNEL_ALIGN (_AC(1, UL) << MIN_KERNEL_ALIGN_LG2)
25 25
diff --git a/arch/x86/include/asm/page_32_types.h b/arch/x86/include/asm/page_32_types.h
index ade619ff9e2a..ef17af013475 100644
--- a/arch/x86/include/asm/page_32_types.h
+++ b/arch/x86/include/asm/page_32_types.h
@@ -15,8 +15,8 @@
15 */ 15 */
16#define __PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL) 16#define __PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL)
17 17
18#define THREAD_ORDER 1 18#define THREAD_SIZE_ORDER 1
19#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER) 19#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
20 20
21#define STACKFAULT_STACK 0 21#define STACKFAULT_STACK 0
22#define DOUBLEFAULT_STACK 1 22#define DOUBLEFAULT_STACK 1
diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
index 7639dbf5d223..320f7bb95f76 100644
--- a/arch/x86/include/asm/page_64_types.h
+++ b/arch/x86/include/asm/page_64_types.h
@@ -1,8 +1,8 @@
1#ifndef _ASM_X86_PAGE_64_DEFS_H 1#ifndef _ASM_X86_PAGE_64_DEFS_H
2#define _ASM_X86_PAGE_64_DEFS_H 2#define _ASM_X86_PAGE_64_DEFS_H
3 3
4#define THREAD_ORDER 1 4#define THREAD_SIZE_ORDER 1
5#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER) 5#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
6#define CURRENT_MASK (~(THREAD_SIZE - 1)) 6#define CURRENT_MASK (~(THREAD_SIZE - 1))
7 7
8#define EXCEPTION_STACK_ORDER 0 8#define EXCEPTION_STACK_ORDER 0
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 4fa7dcceb6c0..ccbb1ea99ccb 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -974,8 +974,6 @@ extern bool cpu_has_amd_erratum(const int *);
974#define cpu_has_amd_erratum(x) (false) 974#define cpu_has_amd_erratum(x) (false)
975#endif /* CONFIG_CPU_SUP_AMD */ 975#endif /* CONFIG_CPU_SUP_AMD */
976 976
977void cpu_idle_wait(void);
978
979extern unsigned long arch_align_stack(unsigned long sp); 977extern unsigned long arch_align_stack(unsigned long sp);
980extern void free_init_pages(char *what, unsigned long begin, unsigned long end); 978extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
981 979
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 0434c400287c..f8cbc6f20e31 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -62,6 +62,8 @@ DECLARE_EARLY_PER_CPU(int, x86_cpu_to_logical_apicid);
62/* Static state in head.S used to set up a CPU */ 62/* Static state in head.S used to set up a CPU */
63extern unsigned long stack_start; /* Initial stack pointer address */ 63extern unsigned long stack_start; /* Initial stack pointer address */
64 64
65struct task_struct;
66
65struct smp_ops { 67struct smp_ops {
66 void (*smp_prepare_boot_cpu)(void); 68 void (*smp_prepare_boot_cpu)(void);
67 void (*smp_prepare_cpus)(unsigned max_cpus); 69 void (*smp_prepare_cpus)(unsigned max_cpus);
@@ -70,7 +72,7 @@ struct smp_ops {
70 void (*stop_other_cpus)(int wait); 72 void (*stop_other_cpus)(int wait);
71 void (*smp_send_reschedule)(int cpu); 73 void (*smp_send_reschedule)(int cpu);
72 74
73 int (*cpu_up)(unsigned cpu); 75 int (*cpu_up)(unsigned cpu, struct task_struct *tidle);
74 int (*cpu_disable)(void); 76 int (*cpu_disable)(void);
75 void (*cpu_die)(unsigned int cpu); 77 void (*cpu_die)(unsigned int cpu);
76 void (*play_dead)(void); 78 void (*play_dead)(void);
@@ -113,9 +115,9 @@ static inline void smp_cpus_done(unsigned int max_cpus)
113 smp_ops.smp_cpus_done(max_cpus); 115 smp_ops.smp_cpus_done(max_cpus);
114} 116}
115 117
116static inline int __cpu_up(unsigned int cpu) 118static inline int __cpu_up(unsigned int cpu, struct task_struct *tidle)
117{ 119{
118 return smp_ops.cpu_up(cpu); 120 return smp_ops.cpu_up(cpu, tidle);
119} 121}
120 122
121static inline int __cpu_disable(void) 123static inline int __cpu_disable(void)
@@ -152,7 +154,7 @@ void cpu_disable_common(void);
152void native_smp_prepare_boot_cpu(void); 154void native_smp_prepare_boot_cpu(void);
153void native_smp_prepare_cpus(unsigned int max_cpus); 155void native_smp_prepare_cpus(unsigned int max_cpus);
154void native_smp_cpus_done(unsigned int max_cpus); 156void native_smp_cpus_done(unsigned int max_cpus);
155int native_cpu_up(unsigned int cpunum); 157int native_cpu_up(unsigned int cpunum, struct task_struct *tidle);
156int native_cpu_disable(void); 158int native_cpu_disable(void);
157void native_cpu_die(unsigned int cpu); 159void native_cpu_die(unsigned int cpu);
158void native_play_dead(void); 160void native_play_dead(void);
@@ -162,6 +164,7 @@ int wbinvd_on_all_cpus(void);
162 164
163void native_send_call_func_ipi(const struct cpumask *mask); 165void native_send_call_func_ipi(const struct cpumask *mask);
164void native_send_call_func_single_ipi(int cpu); 166void native_send_call_func_single_ipi(int cpu);
167void x86_idle_thread_init(unsigned int cpu, struct task_struct *idle);
165 168
166void smp_store_cpu_info(int id); 169void smp_store_cpu_info(int id);
167#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu) 170#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
index ad6df8ccd715..73cfe0d309c9 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -155,24 +155,6 @@ struct thread_info {
155 155
156#define PREEMPT_ACTIVE 0x10000000 156#define PREEMPT_ACTIVE 0x10000000
157 157
158/* thread information allocation */
159#ifdef CONFIG_DEBUG_STACK_USAGE
160#define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO)
161#else
162#define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK)
163#endif
164
165#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
166
167#define alloc_thread_info_node(tsk, node) \
168({ \
169 struct page *page = alloc_pages_node(node, THREAD_FLAGS, \
170 THREAD_ORDER); \
171 struct thread_info *ret = page ? page_address(page) : NULL; \
172 \
173 ret; \
174})
175
176#ifdef CONFIG_X86_32 158#ifdef CONFIG_X86_32
177 159
178#define STACK_WARN (THREAD_SIZE/8) 160#define STACK_WARN (THREAD_SIZE/8)
@@ -282,8 +264,7 @@ static inline bool is_ia32_task(void)
282 264
283#ifndef __ASSEMBLY__ 265#ifndef __ASSEMBLY__
284extern void arch_task_cache_init(void); 266extern void arch_task_cache_init(void);
285extern void free_thread_info(struct thread_info *ti);
286extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src); 267extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
287#define arch_task_cache_init arch_task_cache_init 268extern void arch_release_task_struct(struct task_struct *tsk);
288#endif 269#endif
289#endif /* _ASM_X86_THREAD_INFO_H */ 270#endif /* _ASM_X86_THREAD_INFO_H */
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 532d2e090e6f..56ebd1f98447 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the linux kernel. 2# Makefile for the linux kernel.
3# 3#
4 4
5extra-y := head_$(BITS).o head$(BITS).o head.o init_task.o vmlinux.lds 5extra-y := head_$(BITS).o head$(BITS).o head.o vmlinux.lds
6 6
7CPPFLAGS_vmlinux.lds += -U$(UTS_MACHINE) 7CPPFLAGS_vmlinux.lds += -U$(UTS_MACHINE)
8 8
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 459e78cbf61e..07b0c0db466c 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -2401,7 +2401,7 @@ static void __exit apm_exit(void)
2401 * (pm_idle), Wait for all processors to update cached/local 2401 * (pm_idle), Wait for all processors to update cached/local
2402 * copies of pm_idle before proceeding. 2402 * copies of pm_idle before proceeding.
2403 */ 2403 */
2404 cpu_idle_wait(); 2404 kick_all_cpus_sync();
2405 } 2405 }
2406 if (((apm_info.bios.flags & APM_BIOS_DISENGAGED) == 0) 2406 if (((apm_info.bios.flags & APM_BIOS_DISENGAGED) == 0)
2407 && (apm_info.connection_version > 0x0100)) { 2407 && (apm_info.connection_version > 0x0100)) {
diff --git a/arch/x86/kernel/init_task.c b/arch/x86/kernel/init_task.c
deleted file mode 100644
index 43e9ccf44947..000000000000
--- a/arch/x86/kernel/init_task.c
+++ /dev/null
@@ -1,42 +0,0 @@
1#include <linux/mm.h>
2#include <linux/module.h>
3#include <linux/sched.h>
4#include <linux/init.h>
5#include <linux/init_task.h>
6#include <linux/fs.h>
7#include <linux/mqueue.h>
8
9#include <asm/uaccess.h>
10#include <asm/pgtable.h>
11#include <asm/desc.h>
12
13static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
14static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
15
16/*
17 * Initial thread structure.
18 *
19 * We need to make sure that this is THREAD_SIZE aligned due to the
20 * way process stacks are handled. This is done by having a special
21 * "init_task" linker map entry..
22 */
23union thread_union init_thread_union __init_task_data =
24 { INIT_THREAD_INFO(init_task) };
25
26/*
27 * Initial task structure.
28 *
29 * All other task structs will be allocated on slabs in fork.c
30 */
31struct task_struct init_task = INIT_TASK(init_task);
32EXPORT_SYMBOL(init_task);
33
34/*
35 * per-CPU TSS segments. Threads are completely 'soft' on Linux,
36 * no more per-task TSS's. The TSS size is kept cacheline-aligned
37 * so they are allowed to end up in the .data..cacheline_aligned
38 * section. Since TSS's are completely CPU-local, we want them
39 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
40 */
41DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
42
diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
index 58b7f27cb3e9..344faf8d0d62 100644
--- a/arch/x86/kernel/irq_32.c
+++ b/arch/x86/kernel/irq_32.c
@@ -127,8 +127,8 @@ void __cpuinit irq_ctx_init(int cpu)
127 return; 127 return;
128 128
129 irqctx = page_address(alloc_pages_node(cpu_to_node(cpu), 129 irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
130 THREAD_FLAGS, 130 THREADINFO_GFP,
131 THREAD_ORDER)); 131 THREAD_SIZE_ORDER));
132 memset(&irqctx->tinfo, 0, sizeof(struct thread_info)); 132 memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
133 irqctx->tinfo.cpu = cpu; 133 irqctx->tinfo.cpu = cpu;
134 irqctx->tinfo.preempt_count = HARDIRQ_OFFSET; 134 irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
@@ -137,8 +137,8 @@ void __cpuinit irq_ctx_init(int cpu)
137 per_cpu(hardirq_ctx, cpu) = irqctx; 137 per_cpu(hardirq_ctx, cpu) = irqctx;
138 138
139 irqctx = page_address(alloc_pages_node(cpu_to_node(cpu), 139 irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
140 THREAD_FLAGS, 140 THREADINFO_GFP,
141 THREAD_ORDER)); 141 THREAD_SIZE_ORDER));
142 memset(&irqctx->tinfo, 0, sizeof(struct thread_info)); 142 memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
143 irqctx->tinfo.cpu = cpu; 143 irqctx->tinfo.cpu = cpu;
144 irqctx->tinfo.addr_limit = MAKE_MM_SEG(0); 144 irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 1d92a5ab6e8b..e8173154800d 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -27,6 +27,15 @@
27#include <asm/debugreg.h> 27#include <asm/debugreg.h>
28#include <asm/nmi.h> 28#include <asm/nmi.h>
29 29
30/*
31 * per-CPU TSS segments. Threads are completely 'soft' on Linux,
32 * no more per-task TSS's. The TSS size is kept cacheline-aligned
33 * so they are allowed to end up in the .data..cacheline_aligned
34 * section. Since TSS's are completely CPU-local, we want them
35 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
36 */
37DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
38
30#ifdef CONFIG_X86_64 39#ifdef CONFIG_X86_64
31static DEFINE_PER_CPU(unsigned char, is_idle); 40static DEFINE_PER_CPU(unsigned char, is_idle);
32static ATOMIC_NOTIFIER_HEAD(idle_notifier); 41static ATOMIC_NOTIFIER_HEAD(idle_notifier);
@@ -67,10 +76,9 @@ void free_thread_xstate(struct task_struct *tsk)
67 fpu_free(&tsk->thread.fpu); 76 fpu_free(&tsk->thread.fpu);
68} 77}
69 78
70void free_thread_info(struct thread_info *ti) 79void arch_release_task_struct(struct task_struct *tsk)
71{ 80{
72 free_thread_xstate(ti->task); 81 free_thread_xstate(tsk);
73 free_pages((unsigned long)ti, THREAD_ORDER);
74} 82}
75 83
76void arch_task_cache_init(void) 84void arch_task_cache_init(void)
@@ -516,26 +524,6 @@ void stop_this_cpu(void *dummy)
516 } 524 }
517} 525}
518 526
519static void do_nothing(void *unused)
520{
521}
522
523/*
524 * cpu_idle_wait - Used to ensure that all the CPUs discard old value of
525 * pm_idle and update to new pm_idle value. Required while changing pm_idle
526 * handler on SMP systems.
527 *
528 * Caller must have changed pm_idle to the new value before the call. Old
529 * pm_idle value will not be used by any CPU after the return of this function.
530 */
531void cpu_idle_wait(void)
532{
533 smp_mb();
534 /* kick all the CPUs so that they exit out of pm_idle */
535 smp_call_function(do_nothing, NULL, 1);
536}
537EXPORT_SYMBOL_GPL(cpu_idle_wait);
538
539/* Default MONITOR/MWAIT with no hints, used for default C1 state */ 527/* Default MONITOR/MWAIT with no hints, used for default C1 state */
540static void mwait_idle(void) 528static void mwait_idle(void)
541{ 529{
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 6e1e406038c2..3acaf51dfddb 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -76,20 +76,8 @@
76/* State of each CPU */ 76/* State of each CPU */
77DEFINE_PER_CPU(int, cpu_state) = { 0 }; 77DEFINE_PER_CPU(int, cpu_state) = { 0 };
78 78
79/* Store all idle threads, this can be reused instead of creating
80* a new thread. Also avoids complicated thread destroy functionality
81* for idle threads.
82*/
83#ifdef CONFIG_HOTPLUG_CPU 79#ifdef CONFIG_HOTPLUG_CPU
84/* 80/*
85 * Needed only for CONFIG_HOTPLUG_CPU because __cpuinitdata is
86 * removed after init for !CONFIG_HOTPLUG_CPU.
87 */
88static DEFINE_PER_CPU(struct task_struct *, idle_thread_array);
89#define get_idle_for_cpu(x) (per_cpu(idle_thread_array, x))
90#define set_idle_for_cpu(x, p) (per_cpu(idle_thread_array, x) = (p))
91
92/*
93 * We need this for trampoline_base protection from concurrent accesses when 81 * We need this for trampoline_base protection from concurrent accesses when
94 * off- and onlining cores wildly. 82 * off- and onlining cores wildly.
95 */ 83 */
@@ -97,20 +85,16 @@ static DEFINE_MUTEX(x86_cpu_hotplug_driver_mutex);
97 85
98void cpu_hotplug_driver_lock(void) 86void cpu_hotplug_driver_lock(void)
99{ 87{
100 mutex_lock(&x86_cpu_hotplug_driver_mutex); 88 mutex_lock(&x86_cpu_hotplug_driver_mutex);
101} 89}
102 90
103void cpu_hotplug_driver_unlock(void) 91void cpu_hotplug_driver_unlock(void)
104{ 92{
105 mutex_unlock(&x86_cpu_hotplug_driver_mutex); 93 mutex_unlock(&x86_cpu_hotplug_driver_mutex);
106} 94}
107 95
108ssize_t arch_cpu_probe(const char *buf, size_t count) { return -1; } 96ssize_t arch_cpu_probe(const char *buf, size_t count) { return -1; }
109ssize_t arch_cpu_release(const char *buf, size_t count) { return -1; } 97ssize_t arch_cpu_release(const char *buf, size_t count) { return -1; }
110#else
111static struct task_struct *idle_thread_array[NR_CPUS] __cpuinitdata ;
112#define get_idle_for_cpu(x) (idle_thread_array[(x)])
113#define set_idle_for_cpu(x, p) (idle_thread_array[(x)] = (p))
114#endif 98#endif
115 99
116/* Number of siblings per CPU package */ 100/* Number of siblings per CPU package */
@@ -618,22 +602,6 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
618 return (send_status | accept_status); 602 return (send_status | accept_status);
619} 603}
620 604
621struct create_idle {
622 struct work_struct work;
623 struct task_struct *idle;
624 struct completion done;
625 int cpu;
626};
627
628static void __cpuinit do_fork_idle(struct work_struct *work)
629{
630 struct create_idle *c_idle =
631 container_of(work, struct create_idle, work);
632
633 c_idle->idle = fork_idle(c_idle->cpu);
634 complete(&c_idle->done);
635}
636
637/* reduce the number of lines printed when booting a large cpu count system */ 605/* reduce the number of lines printed when booting a large cpu count system */
638static void __cpuinit announce_cpu(int cpu, int apicid) 606static void __cpuinit announce_cpu(int cpu, int apicid)
639{ 607{
@@ -660,58 +628,31 @@ static void __cpuinit announce_cpu(int cpu, int apicid)
660 * Returns zero if CPU booted OK, else error code from 628 * Returns zero if CPU booted OK, else error code from
661 * ->wakeup_secondary_cpu. 629 * ->wakeup_secondary_cpu.
662 */ 630 */
663static int __cpuinit do_boot_cpu(int apicid, int cpu) 631static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
664{ 632{
665 unsigned long boot_error = 0; 633 unsigned long boot_error = 0;
666 unsigned long start_ip; 634 unsigned long start_ip;
667 int timeout; 635 int timeout;
668 struct create_idle c_idle = {
669 .cpu = cpu,
670 .done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done),
671 };
672
673 INIT_WORK_ONSTACK(&c_idle.work, do_fork_idle);
674 636
675 alternatives_smp_switch(1); 637 alternatives_smp_switch(1);
676 638
677 c_idle.idle = get_idle_for_cpu(cpu); 639 idle->thread.sp = (unsigned long) (((struct pt_regs *)
678 640 (THREAD_SIZE + task_stack_page(idle))) - 1);
679 /* 641 per_cpu(current_task, cpu) = idle;
680 * We can't use kernel_thread since we must avoid to
681 * reschedule the child.
682 */
683 if (c_idle.idle) {
684 c_idle.idle->thread.sp = (unsigned long) (((struct pt_regs *)
685 (THREAD_SIZE + task_stack_page(c_idle.idle))) - 1);
686 init_idle(c_idle.idle, cpu);
687 goto do_rest;
688 }
689 642
690 schedule_work(&c_idle.work);
691 wait_for_completion(&c_idle.done);
692
693 if (IS_ERR(c_idle.idle)) {
694 printk("failed fork for CPU %d\n", cpu);
695 destroy_work_on_stack(&c_idle.work);
696 return PTR_ERR(c_idle.idle);
697 }
698
699 set_idle_for_cpu(cpu, c_idle.idle);
700do_rest:
701 per_cpu(current_task, cpu) = c_idle.idle;
702#ifdef CONFIG_X86_32 643#ifdef CONFIG_X86_32
703 /* Stack for startup_32 can be just as for start_secondary onwards */ 644 /* Stack for startup_32 can be just as for start_secondary onwards */
704 irq_ctx_init(cpu); 645 irq_ctx_init(cpu);
705#else 646#else
706 clear_tsk_thread_flag(c_idle.idle, TIF_FORK); 647 clear_tsk_thread_flag(idle, TIF_FORK);
707 initial_gs = per_cpu_offset(cpu); 648 initial_gs = per_cpu_offset(cpu);
708 per_cpu(kernel_stack, cpu) = 649 per_cpu(kernel_stack, cpu) =
709 (unsigned long)task_stack_page(c_idle.idle) - 650 (unsigned long)task_stack_page(idle) -
710 KERNEL_STACK_OFFSET + THREAD_SIZE; 651 KERNEL_STACK_OFFSET + THREAD_SIZE;
711#endif 652#endif
712 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu); 653 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
713 initial_code = (unsigned long)start_secondary; 654 initial_code = (unsigned long)start_secondary;
714 stack_start = c_idle.idle->thread.sp; 655 stack_start = idle->thread.sp;
715 656
716 /* start_ip had better be page-aligned! */ 657 /* start_ip had better be page-aligned! */
717 start_ip = trampoline_address(); 658 start_ip = trampoline_address();
@@ -813,12 +754,10 @@ do_rest:
813 */ 754 */
814 smpboot_restore_warm_reset_vector(); 755 smpboot_restore_warm_reset_vector();
815 } 756 }
816
817 destroy_work_on_stack(&c_idle.work);
818 return boot_error; 757 return boot_error;
819} 758}
820 759
821int __cpuinit native_cpu_up(unsigned int cpu) 760int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
822{ 761{
823 int apicid = apic->cpu_present_to_apicid(cpu); 762 int apicid = apic->cpu_present_to_apicid(cpu);
824 unsigned long flags; 763 unsigned long flags;
@@ -851,7 +790,7 @@ int __cpuinit native_cpu_up(unsigned int cpu)
851 790
852 per_cpu(cpu_state, cpu) = CPU_UP_PREPARE; 791 per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
853 792
854 err = do_boot_cpu(apicid, cpu); 793 err = do_boot_cpu(apicid, cpu, tidle);
855 if (err) { 794 if (err) {
856 pr_debug("do_boot_cpu failed %d\n", err); 795 pr_debug("do_boot_cpu failed %d\n", err);
857 return -EIO; 796 return -EIO;
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index 0503c0c493a9..3700945ed0d5 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -265,18 +265,8 @@ static void __init xen_smp_prepare_cpus(unsigned int max_cpus)
265 set_cpu_possible(cpu, false); 265 set_cpu_possible(cpu, false);
266 } 266 }
267 267
268 for_each_possible_cpu (cpu) { 268 for_each_possible_cpu(cpu)
269 struct task_struct *idle;
270
271 if (cpu == 0)
272 continue;
273
274 idle = fork_idle(cpu);
275 if (IS_ERR(idle))
276 panic("failed fork for CPU %d", cpu);
277
278 set_cpu_present(cpu, true); 269 set_cpu_present(cpu, true);
279 }
280} 270}
281 271
282static int __cpuinit 272static int __cpuinit
@@ -346,9 +336,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
346 return 0; 336 return 0;
347} 337}
348 338
349static int __cpuinit xen_cpu_up(unsigned int cpu) 339static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
350{ 340{
351 struct task_struct *idle = idle_task(cpu);
352 int rc; 341 int rc;
353 342
354 per_cpu(current_task, cpu) = idle; 343 per_cpu(current_task, cpu) = idle;
@@ -562,10 +551,10 @@ static void __init xen_hvm_smp_prepare_cpus(unsigned int max_cpus)
562 xen_init_lock_cpu(0); 551 xen_init_lock_cpu(0);
563} 552}
564 553
565static int __cpuinit xen_hvm_cpu_up(unsigned int cpu) 554static int __cpuinit xen_hvm_cpu_up(unsigned int cpu, struct task_struct *tidle)
566{ 555{
567 int rc; 556 int rc;
568 rc = native_cpu_up(cpu); 557 rc = native_cpu_up(cpu, tidle);
569 WARN_ON (xen_smp_intr_init(cpu)); 558 WARN_ON (xen_smp_intr_init(cpu));
570 return rc; 559 return rc;
571} 560}
diff --git a/arch/xtensa/kernel/Makefile b/arch/xtensa/kernel/Makefile
index 2d2728b3e862..59fc3fe15572 100644
--- a/arch/xtensa/kernel/Makefile
+++ b/arch/xtensa/kernel/Makefile
@@ -6,7 +6,7 @@ extra-y := head.o vmlinux.lds
6 6
7obj-y := align.o entry.o irq.o coprocessor.o process.o ptrace.o \ 7obj-y := align.o entry.o irq.o coprocessor.o process.o ptrace.o \
8 setup.o signal.o syscall.o time.o traps.o vectors.o platform.o \ 8 setup.o signal.o syscall.o time.o traps.o vectors.o platform.o \
9 pci-dma.o init_task.o io.o 9 pci-dma.o io.o
10 10
11obj-$(CONFIG_KGDB) += xtensa-stub.o 11obj-$(CONFIG_KGDB) += xtensa-stub.o
12obj-$(CONFIG_PCI) += pci.o 12obj-$(CONFIG_PCI) += pci.o
diff --git a/arch/xtensa/kernel/init_task.c b/arch/xtensa/kernel/init_task.c
deleted file mode 100644
index cd122fb7e48a..000000000000
--- a/arch/xtensa/kernel/init_task.c
+++ /dev/null
@@ -1,31 +0,0 @@
1/*
2 * arch/xtensa/kernel/init_task.c
3 *
4 * Xtensa Processor version.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 *
10 * Copyright (C) 2007 Tensilica Inc.
11 *
12 * Chris Zankel <chris@zankel.net>
13 */
14
15#include <linux/mm.h>
16#include <linux/fs.h>
17#include <linux/init.h>
18#include <linux/init_task.h>
19#include <linux/module.h>
20#include <linux/mqueue.h>
21
22#include <asm/uaccess.h>
23
24static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
25static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
26union thread_union init_thread_union __init_task_data =
27 { INIT_THREAD_INFO(init_task) };
28
29struct task_struct init_task = INIT_TASK(init_task);
30
31EXPORT_SYMBOL(init_task);
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 2f0083a51a9a..d90519cec880 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -40,17 +40,6 @@ void disable_cpuidle(void)
40 off = 1; 40 off = 1;
41} 41}
42 42
43#if defined(CONFIG_ARCH_HAS_CPU_IDLE_WAIT)
44static void cpuidle_kick_cpus(void)
45{
46 cpu_idle_wait();
47}
48#elif defined(CONFIG_SMP)
49# error "Arch needs cpu_idle_wait() equivalent here"
50#else /* !CONFIG_ARCH_HAS_CPU_IDLE_WAIT && !CONFIG_SMP */
51static void cpuidle_kick_cpus(void) {}
52#endif
53
54static int __cpuidle_register_device(struct cpuidle_device *dev); 43static int __cpuidle_register_device(struct cpuidle_device *dev);
55 44
56static inline int cpuidle_enter(struct cpuidle_device *dev, 45static inline int cpuidle_enter(struct cpuidle_device *dev,
@@ -186,7 +175,7 @@ void cpuidle_uninstall_idle_handler(void)
186{ 175{
187 if (enabled_devices) { 176 if (enabled_devices) {
188 initialized = 0; 177 initialized = 0;
189 cpuidle_kick_cpus(); 178 kick_all_cpus_sync();
190 } 179 }
191} 180}
192 181
diff --git a/include/linux/smp.h b/include/linux/smp.h
index 10530d92c04b..717fb746c9a8 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -61,7 +61,7 @@ extern void smp_prepare_cpus(unsigned int max_cpus);
61/* 61/*
62 * Bring a CPU up 62 * Bring a CPU up
63 */ 63 */
64extern int __cpu_up(unsigned int cpunum); 64extern int __cpu_up(unsigned int cpunum, struct task_struct *tidle);
65 65
66/* 66/*
67 * Final polishing of CPUs 67 * Final polishing of CPUs
@@ -81,6 +81,8 @@ void __smp_call_function_single(int cpuid, struct call_single_data *data,
81int smp_call_function_any(const struct cpumask *mask, 81int smp_call_function_any(const struct cpumask *mask,
82 smp_call_func_t func, void *info, int wait); 82 smp_call_func_t func, void *info, int wait);
83 83
84void kick_all_cpus_sync(void);
85
84/* 86/*
85 * Generic and arch helpers 87 * Generic and arch helpers
86 */ 88 */
@@ -192,6 +194,8 @@ smp_call_function_any(const struct cpumask *mask, smp_call_func_t func,
192 return smp_call_function_single(0, func, info, wait); 194 return smp_call_function_single(0, func, info, wait);
193} 195}
194 196
197static inline void kick_all_cpus_sync(void) { }
198
195#endif /* !SMP */ 199#endif /* !SMP */
196 200
197/* 201/*
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index 8d03f079688c..db78775eff3b 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -54,6 +54,12 @@ extern long do_no_restart_syscall(struct restart_block *parm);
54 54
55#ifdef __KERNEL__ 55#ifdef __KERNEL__
56 56
57#ifdef CONFIG_DEBUG_STACK_USAGE
58# define THREADINFO_GFP (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO)
59#else
60# define THREADINFO_GFP (GFP_KERNEL | __GFP_NOTRACK)
61#endif
62
57/* 63/*
58 * flag set/clear/test wrappers 64 * flag set/clear/test wrappers
59 * - pass TIF_xxxx constants to these functions 65 * - pass TIF_xxxx constants to these functions
diff --git a/init/Makefile b/init/Makefile
index 0bf677aa0872..7bc47ee31c36 100644
--- a/init/Makefile
+++ b/init/Makefile
@@ -10,6 +10,10 @@ obj-$(CONFIG_BLK_DEV_INITRD) += initramfs.o
10endif 10endif
11obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o 11obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o
12 12
13ifneq ($(CONFIG_ARCH_INIT_TASK),y)
14obj-y += init_task.o
15endif
16
13mounts-y := do_mounts.o 17mounts-y := do_mounts.o
14mounts-$(CONFIG_BLK_DEV_RAM) += do_mounts_rd.o 18mounts-$(CONFIG_BLK_DEV_RAM) += do_mounts_rd.o
15mounts-$(CONFIG_BLK_DEV_INITRD) += do_mounts_initrd.o 19mounts-$(CONFIG_BLK_DEV_INITRD) += do_mounts_initrd.o
diff --git a/arch/alpha/kernel/init_task.c b/init/init_task.c
index 6f80ca4f9766..8b2f3996b035 100644
--- a/arch/alpha/kernel/init_task.c
+++ b/init/init_task.c
@@ -1,17 +1,24 @@
1#include <linux/mm.h> 1#include <linux/init_task.h>
2#include <linux/module.h> 2#include <linux/export.h>
3#include <linux/mqueue.h>
3#include <linux/sched.h> 4#include <linux/sched.h>
4#include <linux/init.h> 5#include <linux/init.h>
5#include <linux/init_task.h>
6#include <linux/fs.h> 6#include <linux/fs.h>
7#include <linux/mqueue.h> 7#include <linux/mm.h>
8#include <asm/uaccess.h>
9 8
9#include <asm/pgtable.h>
10#include <asm/uaccess.h>
10 11
11static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 12static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
12static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 13static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
14
15/* Initial task structure */
13struct task_struct init_task = INIT_TASK(init_task); 16struct task_struct init_task = INIT_TASK(init_task);
14EXPORT_SYMBOL(init_task); 17EXPORT_SYMBOL(init_task);
15 18
19/*
20 * Initial thread structure. Alignment of this is handled by a special
21 * linker map entry.
22 */
16union thread_union init_thread_union __init_task_data = 23union thread_union init_thread_union __init_task_data =
17 { INIT_THREAD_INFO(init_task) }; 24 { INIT_THREAD_INFO(init_task) };
diff --git a/kernel/Makefile b/kernel/Makefile
index cb41b9547c9f..6c07f30fa9b7 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -43,6 +43,7 @@ obj-$(CONFIG_DEBUG_RT_MUTEXES) += rtmutex-debug.o
43obj-$(CONFIG_RT_MUTEX_TESTER) += rtmutex-tester.o 43obj-$(CONFIG_RT_MUTEX_TESTER) += rtmutex-tester.o
44obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o 44obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
45obj-$(CONFIG_SMP) += smp.o 45obj-$(CONFIG_SMP) += smp.o
46obj-$(CONFIG_SMP) += smpboot.o
46ifneq ($(CONFIG_SMP),y) 47ifneq ($(CONFIG_SMP),y)
47obj-y += up.o 48obj-y += up.o
48endif 49endif
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 2060c6e57027..0e6353cf147a 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -17,6 +17,8 @@
17#include <linux/gfp.h> 17#include <linux/gfp.h>
18#include <linux/suspend.h> 18#include <linux/suspend.h>
19 19
20#include "smpboot.h"
21
20#ifdef CONFIG_SMP 22#ifdef CONFIG_SMP
21/* Serializes the updates to cpu_online_mask, cpu_present_mask */ 23/* Serializes the updates to cpu_online_mask, cpu_present_mask */
22static DEFINE_MUTEX(cpu_add_remove_lock); 24static DEFINE_MUTEX(cpu_add_remove_lock);
@@ -295,11 +297,19 @@ static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen)
295 int ret, nr_calls = 0; 297 int ret, nr_calls = 0;
296 void *hcpu = (void *)(long)cpu; 298 void *hcpu = (void *)(long)cpu;
297 unsigned long mod = tasks_frozen ? CPU_TASKS_FROZEN : 0; 299 unsigned long mod = tasks_frozen ? CPU_TASKS_FROZEN : 0;
300 struct task_struct *idle;
298 301
299 if (cpu_online(cpu) || !cpu_present(cpu)) 302 if (cpu_online(cpu) || !cpu_present(cpu))
300 return -EINVAL; 303 return -EINVAL;
301 304
302 cpu_hotplug_begin(); 305 cpu_hotplug_begin();
306
307 idle = idle_thread_get(cpu);
308 if (IS_ERR(idle)) {
309 ret = PTR_ERR(idle);
310 goto out;
311 }
312
303 ret = __cpu_notify(CPU_UP_PREPARE | mod, hcpu, -1, &nr_calls); 313 ret = __cpu_notify(CPU_UP_PREPARE | mod, hcpu, -1, &nr_calls);
304 if (ret) { 314 if (ret) {
305 nr_calls--; 315 nr_calls--;
@@ -309,7 +319,7 @@ static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen)
309 } 319 }
310 320
311 /* Arch-specific enabling code. */ 321 /* Arch-specific enabling code. */
312 ret = __cpu_up(cpu); 322 ret = __cpu_up(cpu, idle);
313 if (ret != 0) 323 if (ret != 0)
314 goto out_notify; 324 goto out_notify;
315 BUG_ON(!cpu_online(cpu)); 325 BUG_ON(!cpu_online(cpu));
@@ -320,6 +330,7 @@ static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen)
320out_notify: 330out_notify:
321 if (ret != 0) 331 if (ret != 0)
322 __cpu_notify(CPU_UP_CANCELED | mod, hcpu, nr_calls, NULL); 332 __cpu_notify(CPU_UP_CANCELED | mod, hcpu, nr_calls, NULL);
333out:
323 cpu_hotplug_done(); 334 cpu_hotplug_done();
324 335
325 return ret; 336 return ret;
diff --git a/kernel/fork.c b/kernel/fork.c
index 687a15d56243..9f9b296fa6df 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -112,32 +112,67 @@ int nr_processes(void)
112 return total; 112 return total;
113} 113}
114 114
115#ifndef __HAVE_ARCH_TASK_STRUCT_ALLOCATOR 115#ifndef CONFIG_ARCH_TASK_STRUCT_ALLOCATOR
116# define alloc_task_struct_node(node) \
117 kmem_cache_alloc_node(task_struct_cachep, GFP_KERNEL, node)
118# define free_task_struct(tsk) \
119 kmem_cache_free(task_struct_cachep, (tsk))
120static struct kmem_cache *task_struct_cachep; 116static struct kmem_cache *task_struct_cachep;
117
118static inline struct task_struct *alloc_task_struct_node(int node)
119{
120 return kmem_cache_alloc_node(task_struct_cachep, GFP_KERNEL, node);
121}
122
123void __weak arch_release_task_struct(struct task_struct *tsk) { }
124
125static inline void free_task_struct(struct task_struct *tsk)
126{
127 arch_release_task_struct(tsk);
128 kmem_cache_free(task_struct_cachep, tsk);
129}
121#endif 130#endif
122 131
123#ifndef __HAVE_ARCH_THREAD_INFO_ALLOCATOR 132#ifndef CONFIG_ARCH_THREAD_INFO_ALLOCATOR
133void __weak arch_release_thread_info(struct thread_info *ti) { }
134
135/*
136 * Allocate pages if THREAD_SIZE is >= PAGE_SIZE, otherwise use a
137 * kmemcache based allocator.
138 */
139# if THREAD_SIZE >= PAGE_SIZE
124static struct thread_info *alloc_thread_info_node(struct task_struct *tsk, 140static struct thread_info *alloc_thread_info_node(struct task_struct *tsk,
125 int node) 141 int node)
126{ 142{
127#ifdef CONFIG_DEBUG_STACK_USAGE 143 struct page *page = alloc_pages_node(node, THREADINFO_GFP,
128 gfp_t mask = GFP_KERNEL | __GFP_ZERO; 144 THREAD_SIZE_ORDER);
129#else
130 gfp_t mask = GFP_KERNEL;
131#endif
132 struct page *page = alloc_pages_node(node, mask, THREAD_SIZE_ORDER);
133 145
134 return page ? page_address(page) : NULL; 146 return page ? page_address(page) : NULL;
135} 147}
136 148
137static inline void free_thread_info(struct thread_info *ti) 149static inline void free_thread_info(struct thread_info *ti)
138{ 150{
151 arch_release_thread_info(ti);
139 free_pages((unsigned long)ti, THREAD_SIZE_ORDER); 152 free_pages((unsigned long)ti, THREAD_SIZE_ORDER);
140} 153}
154# else
155static struct kmem_cache *thread_info_cache;
156
157static struct thread_info *alloc_thread_info_node(struct task_struct *tsk,
158 int node)
159{
160 return kmem_cache_alloc_node(thread_info_cache, THREADINFO_GFP, node);
161}
162
163static void free_thread_info(struct thread_info *ti)
164{
165 arch_release_thread_info(ti);
166 kmem_cache_free(thread_info_cache, ti);
167}
168
169void thread_info_cache_init(void)
170{
171 thread_info_cache = kmem_cache_create("thread_info", THREAD_SIZE,
172 THREAD_SIZE, 0, NULL);
173 BUG_ON(thread_info_cache == NULL);
174}
175# endif
141#endif 176#endif
142 177
143/* SLAB cache for signal_struct structures (tsk->signal) */ 178/* SLAB cache for signal_struct structures (tsk->signal) */
@@ -204,17 +239,11 @@ void __put_task_struct(struct task_struct *tsk)
204} 239}
205EXPORT_SYMBOL_GPL(__put_task_struct); 240EXPORT_SYMBOL_GPL(__put_task_struct);
206 241
207/* 242void __init __weak arch_task_cache_init(void) { }
208 * macro override instead of weak attribute alias, to workaround
209 * gcc 4.1.0 and 4.1.1 bugs with weak attribute and empty functions.
210 */
211#ifndef arch_task_cache_init
212#define arch_task_cache_init()
213#endif
214 243
215void __init fork_init(unsigned long mempages) 244void __init fork_init(unsigned long mempages)
216{ 245{
217#ifndef __HAVE_ARCH_TASK_STRUCT_ALLOCATOR 246#ifndef CONFIG_ARCH_TASK_STRUCT_ALLOCATOR
218#ifndef ARCH_MIN_TASKALIGN 247#ifndef ARCH_MIN_TASKALIGN
219#define ARCH_MIN_TASKALIGN L1_CACHE_BYTES 248#define ARCH_MIN_TASKALIGN L1_CACHE_BYTES
220#endif 249#endif
diff --git a/kernel/sched/Makefile b/kernel/sched/Makefile
index 9a7dd35102a3..173ea52f3af0 100644
--- a/kernel/sched/Makefile
+++ b/kernel/sched/Makefile
@@ -16,5 +16,3 @@ obj-$(CONFIG_SMP) += cpupri.o
16obj-$(CONFIG_SCHED_AUTOGROUP) += auto_group.o 16obj-$(CONFIG_SCHED_AUTOGROUP) += auto_group.o
17obj-$(CONFIG_SCHEDSTATS) += stats.o 17obj-$(CONFIG_SCHEDSTATS) += stats.o
18obj-$(CONFIG_SCHED_DEBUG) += debug.o 18obj-$(CONFIG_SCHED_DEBUG) += debug.o
19
20
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index eb4131b8ad60..ea8a4769fea5 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -83,6 +83,7 @@
83 83
84#include "sched.h" 84#include "sched.h"
85#include "../workqueue_sched.h" 85#include "../workqueue_sched.h"
86#include "../smpboot.h"
86 87
87#define CREATE_TRACE_POINTS 88#define CREATE_TRACE_POINTS
88#include <trace/events/sched.h> 89#include <trace/events/sched.h>
@@ -7062,6 +7063,7 @@ void __init sched_init(void)
7062 /* May be allocated at isolcpus cmdline parse time */ 7063 /* May be allocated at isolcpus cmdline parse time */
7063 if (cpu_isolated_map == NULL) 7064 if (cpu_isolated_map == NULL)
7064 zalloc_cpumask_var(&cpu_isolated_map, GFP_NOWAIT); 7065 zalloc_cpumask_var(&cpu_isolated_map, GFP_NOWAIT);
7066 idle_thread_set_boot_cpu();
7065#endif 7067#endif
7066 init_sched_fair_class(); 7068 init_sched_fair_class();
7067 7069
diff --git a/kernel/smp.c b/kernel/smp.c
index 2f8b10ecf759..d0ae5b24875e 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -13,6 +13,8 @@
13#include <linux/smp.h> 13#include <linux/smp.h>
14#include <linux/cpu.h> 14#include <linux/cpu.h>
15 15
16#include "smpboot.h"
17
16#ifdef CONFIG_USE_GENERIC_SMP_HELPERS 18#ifdef CONFIG_USE_GENERIC_SMP_HELPERS
17static struct { 19static struct {
18 struct list_head queue; 20 struct list_head queue;
@@ -669,6 +671,8 @@ void __init smp_init(void)
669{ 671{
670 unsigned int cpu; 672 unsigned int cpu;
671 673
674 idle_threads_init();
675
672 /* FIXME: This should be done in userspace --RR */ 676 /* FIXME: This should be done in userspace --RR */
673 for_each_present_cpu(cpu) { 677 for_each_present_cpu(cpu) {
674 if (num_online_cpus() >= setup_max_cpus) 678 if (num_online_cpus() >= setup_max_cpus)
@@ -791,3 +795,26 @@ void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info),
791 } 795 }
792} 796}
793EXPORT_SYMBOL(on_each_cpu_cond); 797EXPORT_SYMBOL(on_each_cpu_cond);
798
799static void do_nothing(void *unused)
800{
801}
802
803/**
804 * kick_all_cpus_sync - Force all cpus out of idle
805 *
806 * Used to synchronize the update of pm_idle function pointer. It's
807 * called after the pointer is updated and returns after the dummy
808 * callback function has been executed on all cpus. The execution of
809 * the function can only happen on the remote cpus after they have
810 * left the idle function which had been called via pm_idle function
811 * pointer. So it's guaranteed that nothing uses the previous pointer
812 * anymore.
813 */
814void kick_all_cpus_sync(void)
815{
816 /* Make sure the change is visible before we kick the cpus */
817 smp_mb();
818 smp_call_function(do_nothing, NULL, 1);
819}
820EXPORT_SYMBOL_GPL(kick_all_cpus_sync);
diff --git a/kernel/smpboot.c b/kernel/smpboot.c
new file mode 100644
index 000000000000..e1a797e028a3
--- /dev/null
+++ b/kernel/smpboot.c
@@ -0,0 +1,62 @@
1/*
2 * Common SMP CPU bringup/teardown functions
3 */
4#include <linux/err.h>
5#include <linux/smp.h>
6#include <linux/init.h>
7#include <linux/sched.h>
8#include <linux/percpu.h>
9
10#include "smpboot.h"
11
12#ifdef CONFIG_GENERIC_SMP_IDLE_THREAD
13/*
14 * For the hotplug case we keep the task structs around and reuse
15 * them.
16 */
17static DEFINE_PER_CPU(struct task_struct *, idle_threads);
18
19struct task_struct * __cpuinit idle_thread_get(unsigned int cpu)
20{
21 struct task_struct *tsk = per_cpu(idle_threads, cpu);
22
23 if (!tsk)
24 return ERR_PTR(-ENOMEM);
25 init_idle(tsk, cpu);
26 return tsk;
27}
28
29void __init idle_thread_set_boot_cpu(void)
30{
31 per_cpu(idle_threads, smp_processor_id()) = current;
32}
33
34static inline void idle_init(unsigned int cpu)
35{
36 struct task_struct *tsk = per_cpu(idle_threads, cpu);
37
38 if (!tsk) {
39 tsk = fork_idle(cpu);
40 if (IS_ERR(tsk))
41 pr_err("SMP: fork_idle() failed for CPU %u\n", cpu);
42 else
43 per_cpu(idle_threads, cpu) = tsk;
44 }
45}
46
47/**
48 * idle_thread_init - Initialize the idle thread for a cpu
49 * @cpu: The cpu for which the idle thread should be initialized
50 *
51 * Creates the thread if it does not exist.
52 */
53void __init idle_threads_init(void)
54{
55 unsigned int cpu;
56
57 for_each_possible_cpu(cpu) {
58 if (cpu != smp_processor_id())
59 idle_init(cpu);
60 }
61}
62#endif
diff --git a/kernel/smpboot.h b/kernel/smpboot.h
new file mode 100644
index 000000000000..80c0acfb8472
--- /dev/null
+++ b/kernel/smpboot.h
@@ -0,0 +1,18 @@
1#ifndef SMPBOOT_H
2#define SMPBOOT_H
3
4struct task_struct;
5
6int smpboot_prepare(unsigned int cpu);
7
8#ifdef CONFIG_GENERIC_SMP_IDLE_THREAD
9struct task_struct *idle_thread_get(unsigned int cpu);
10void idle_thread_set_boot_cpu(void);
11void idle_threads_init(void);
12#else
13static inline struct task_struct *idle_thread_get(unsigned int cpu) { return NULL; }
14static inline void idle_thread_set_boot_cpu(void) { }
15static inline void idle_threads_init(void) { }
16#endif
17
18#endif