summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2016-05-20 20:00:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-20 20:58:30 -0400
commite64646946ed32902fd597fa6e514b1da84642de3 (patch)
tree6e3d618e6e81619f82f809eb9857e2974a3734b8
parent5f56a5dfdb9bcb3bca03df59980d4d2f012cbb53 (diff)
exit_thread: accept a task parameter to be exited
We need to call exit_thread from copy_process in a fail path. So make it accept task_struct as a parameter. [v2] * s390: exit_thread_runtime_instr doesn't make sense to be called for non-current tasks. * arm: fix the comment in vfp_thread_copy * change 'me' to 'tsk' for task_struct * now we can change only archs that actually have exit_thread [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: "David S. Miller" <davem@davemloft.net> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: "James E.J. Bottomley" <jejb@parisc-linux.org> Cc: Aurelien Jacquiot <a-jacquiot@ti.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Chen Liqin <liqin.linux@gmail.com> Cc: Chris Metcalf <cmetcalf@mellanox.com> Cc: Chris Zankel <chris@zankel.net> Cc: David Howells <dhowells@redhat.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Guan Xuetao <gxt@mprc.pku.edu.cn> Cc: Haavard Skinnemoen <hskinnemoen@gmail.com> Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Helge Deller <deller@gmx.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: James Hogan <james.hogan@imgtec.com> Cc: Jeff Dike <jdike@addtoit.com> Cc: Jesper Nilsson <jesper.nilsson@axis.com> Cc: Jiri Slaby <jslaby@suse.cz> Cc: Jonas Bonn <jonas@southpole.se> Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com> Cc: Lennox Wu <lennox.wu@gmail.com> Cc: Ley Foon Tan <lftan@altera.com> Cc: Mark Salter <msalter@redhat.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Matt Turner <mattst88@gmail.com> Cc: Max Filippov <jcmvbkbc@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Simek <monstr@monstr.eu> Cc: Mikael Starvik <starvik@axis.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Rich Felker <dalias@libc.org> Cc: Richard Henderson <rth@twiddle.net> Cc: Richard Kuo <rkuo@codeaurora.org> Cc: Richard Weinberger <richard@nod.at> Cc: Russell King <linux@arm.linux.org.uk> Cc: Steven Miao <realmz6@gmail.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tony Luck <tony.luck@intel.com> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/arm/kernel/process.c4
-rw-r--r--arch/arm/vfp/vfpmodule.c4
-rw-r--r--arch/avr32/kernel/process.c4
-rw-r--r--arch/cris/arch-v32/kernel/process.c4
-rw-r--r--arch/ia64/kernel/perfmon.c4
-rw-r--r--arch/ia64/kernel/process.c14
-rw-r--r--arch/metag/kernel/process.c6
-rw-r--r--arch/mn10300/kernel/process.c4
-rw-r--r--arch/s390/kernel/process.c5
-rw-r--r--arch/sh/kernel/process_64.c5
-rw-r--r--arch/sparc/kernel/process_32.c12
-rw-r--r--arch/sparc/kernel/process_64.c4
-rw-r--r--arch/tile/kernel/process.c4
-rw-r--r--arch/x86/kernel/process.c5
-rw-r--r--arch/xtensa/kernel/process.c4
-rw-r--r--include/linux/sched.h4
-rw-r--r--kernel/exit.c2
17 files changed, 42 insertions, 47 deletions
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 4adfb46e3ee9..a647d6642f3e 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -193,9 +193,9 @@ EXPORT_SYMBOL_GPL(thread_notify_head);
193/* 193/*
194 * Free current thread data structures etc.. 194 * Free current thread data structures etc..
195 */ 195 */
196void exit_thread(void) 196void exit_thread(struct task_struct *tsk)
197{ 197{
198 thread_notify(THREAD_NOTIFY_EXIT, current_thread_info()); 198 thread_notify(THREAD_NOTIFY_EXIT, task_thread_info(tsk));
199} 199}
200 200
201void flush_thread(void) 201void flush_thread(void)
diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index 2a61e4b04600..73085d3482ed 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -156,10 +156,6 @@ static void vfp_thread_copy(struct thread_info *thread)
156 * - we could be preempted if tree preempt rcu is enabled, so 156 * - we could be preempted if tree preempt rcu is enabled, so
157 * it is unsafe to use thread->cpu. 157 * it is unsafe to use thread->cpu.
158 * THREAD_NOTIFY_EXIT 158 * THREAD_NOTIFY_EXIT
159 * - the thread (v) will be running on the local CPU, so
160 * v === current_thread_info()
161 * - thread->cpu is the local CPU number at the time it is accessed,
162 * but may change at any time.
163 * - we could be preempted if tree preempt rcu is enabled, so 159 * - we could be preempted if tree preempt rcu is enabled, so
164 * it is unsafe to use thread->cpu. 160 * it is unsafe to use thread->cpu.
165 */ 161 */
diff --git a/arch/avr32/kernel/process.c b/arch/avr32/kernel/process.c
index 42a53e740a7e..68e5b9dac059 100644
--- a/arch/avr32/kernel/process.c
+++ b/arch/avr32/kernel/process.c
@@ -62,9 +62,9 @@ void machine_restart(char *cmd)
62/* 62/*
63 * Free current thread data structures etc 63 * Free current thread data structures etc
64 */ 64 */
65void exit_thread(void) 65void exit_thread(struct task_struct *tsk)
66{ 66{
67 ocd_disable(current); 67 ocd_disable(tsk);
68} 68}
69 69
70void flush_thread(void) 70void flush_thread(void)
diff --git a/arch/cris/arch-v32/kernel/process.c b/arch/cris/arch-v32/kernel/process.c
index c7ce784a393c..4d1afa9f9fd3 100644
--- a/arch/cris/arch-v32/kernel/process.c
+++ b/arch/cris/arch-v32/kernel/process.c
@@ -33,9 +33,9 @@ void default_idle(void)
33 */ 33 */
34 34
35extern void deconfigure_bp(long pid); 35extern void deconfigure_bp(long pid);
36void exit_thread(void) 36void exit_thread(struct task_struct *tsk)
37{ 37{
38 deconfigure_bp(current->pid); 38 deconfigure_bp(tsk->pid);
39} 39}
40 40
41/* 41/*
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 9cd607b06964..2436ad5f92c1 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -4542,8 +4542,8 @@ pfm_context_unload(pfm_context_t *ctx, void *arg, int count, struct pt_regs *reg
4542 4542
4543 4543
4544/* 4544/*
4545 * called only from exit_thread(): task == current 4545 * called only from exit_thread()
4546 * we come here only if current has a context attached (loaded or masked) 4546 * we come here only if the task has a context attached (loaded or masked)
4547 */ 4547 */
4548void 4548void
4549pfm_exit_thread(struct task_struct *task) 4549pfm_exit_thread(struct task_struct *task)
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index b51514957620..aae6c4dc7ae7 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -570,22 +570,22 @@ flush_thread (void)
570} 570}
571 571
572/* 572/*
573 * Clean up state associated with current thread. This is called when 573 * Clean up state associated with a thread. This is called when
574 * the thread calls exit(). 574 * the thread calls exit().
575 */ 575 */
576void 576void
577exit_thread (void) 577exit_thread (struct task_struct *tsk)
578{ 578{
579 579
580 ia64_drop_fpu(current); 580 ia64_drop_fpu(tsk);
581#ifdef CONFIG_PERFMON 581#ifdef CONFIG_PERFMON
582 /* if needed, stop monitoring and flush state to perfmon context */ 582 /* if needed, stop monitoring and flush state to perfmon context */
583 if (current->thread.pfm_context) 583 if (tsk->thread.pfm_context)
584 pfm_exit_thread(current); 584 pfm_exit_thread(tsk);
585 585
586 /* free debug register resources */ 586 /* free debug register resources */
587 if (current->thread.flags & IA64_THREAD_DBG_VALID) 587 if (tsk->thread.flags & IA64_THREAD_DBG_VALID)
588 pfm_release_debug_registers(current); 588 pfm_release_debug_registers(tsk);
589#endif 589#endif
590} 590}
591 591
diff --git a/arch/metag/kernel/process.c b/arch/metag/kernel/process.c
index 7f546183a0f0..35062796edf2 100644
--- a/arch/metag/kernel/process.c
+++ b/arch/metag/kernel/process.c
@@ -345,10 +345,10 @@ void flush_thread(void)
345/* 345/*
346 * Free current thread data structures etc. 346 * Free current thread data structures etc.
347 */ 347 */
348void exit_thread(void) 348void exit_thread(struct task_struct *tsk)
349{ 349{
350 clear_fpu(&current->thread); 350 clear_fpu(&tsk->thread);
351 clear_dsp(&current->thread); 351 clear_dsp(&tsk->thread);
352} 352}
353 353
354/* TODO: figure out how to unwind the kernel stack here to figure out 354/* TODO: figure out how to unwind the kernel stack here to figure out
diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c
index 74a96ccf7451..cbede4e88dee 100644
--- a/arch/mn10300/kernel/process.c
+++ b/arch/mn10300/kernel/process.c
@@ -103,9 +103,9 @@ void show_regs(struct pt_regs *regs)
103/* 103/*
104 * free current thread data structures etc.. 104 * free current thread data structures etc..
105 */ 105 */
106void exit_thread(void) 106void exit_thread(struct task_struct *tsk)
107{ 107{
108 exit_fpu(current); 108 exit_fpu(tsk);
109} 109}
110 110
111void flush_thread(void) 111void flush_thread(void)
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index 481d7a83efc6..bba4fa74b321 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -68,9 +68,10 @@ extern void kernel_thread_starter(void);
68/* 68/*
69 * Free current thread data structures etc.. 69 * Free current thread data structures etc..
70 */ 70 */
71void exit_thread(void) 71void exit_thread(struct task_struct *tsk)
72{ 72{
73 exit_thread_runtime_instr(); 73 if (tsk == current)
74 exit_thread_runtime_instr();
74} 75}
75 76
76void flush_thread(void) 77void flush_thread(void)
diff --git a/arch/sh/kernel/process_64.c b/arch/sh/kernel/process_64.c
index e2062e643341..9d3e9916555d 100644
--- a/arch/sh/kernel/process_64.c
+++ b/arch/sh/kernel/process_64.c
@@ -288,7 +288,7 @@ void show_regs(struct pt_regs *regs)
288/* 288/*
289 * Free current thread data structures etc.. 289 * Free current thread data structures etc..
290 */ 290 */
291void exit_thread(void) 291void exit_thread(struct task_struct *tsk)
292{ 292{
293 /* 293 /*
294 * See arch/sparc/kernel/process.c for the precedent for doing 294 * See arch/sparc/kernel/process.c for the precedent for doing
@@ -307,9 +307,8 @@ void exit_thread(void)
307 * which it would get safely nulled. 307 * which it would get safely nulled.
308 */ 308 */
309#ifdef CONFIG_SH_FPU 309#ifdef CONFIG_SH_FPU
310 if (last_task_used_math == current) { 310 if (last_task_used_math == tsk)
311 last_task_used_math = NULL; 311 last_task_used_math = NULL;
312 }
313#endif 312#endif
314} 313}
315 314
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
index c5113c7ce2fd..b7780a5bef11 100644
--- a/arch/sparc/kernel/process_32.c
+++ b/arch/sparc/kernel/process_32.c
@@ -184,21 +184,21 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
184/* 184/*
185 * Free current thread data structures etc.. 185 * Free current thread data structures etc..
186 */ 186 */
187void exit_thread(void) 187void exit_thread(struct task_struct *tsk)
188{ 188{
189#ifndef CONFIG_SMP 189#ifndef CONFIG_SMP
190 if(last_task_used_math == current) { 190 if (last_task_used_math == tsk) {
191#else 191#else
192 if (test_thread_flag(TIF_USEDFPU)) { 192 if (test_ti_thread_flag(task_thread_info(tsk), TIF_USEDFPU)) {
193#endif 193#endif
194 /* Keep process from leaving FPU in a bogon state. */ 194 /* Keep process from leaving FPU in a bogon state. */
195 put_psr(get_psr() | PSR_EF); 195 put_psr(get_psr() | PSR_EF);
196 fpsave(&current->thread.float_regs[0], &current->thread.fsr, 196 fpsave(&tsk->thread.float_regs[0], &tsk->thread.fsr,
197 &current->thread.fpqueue[0], &current->thread.fpqdepth); 197 &tsk->thread.fpqueue[0], &tsk->thread.fpqdepth);
198#ifndef CONFIG_SMP 198#ifndef CONFIG_SMP
199 last_task_used_math = NULL; 199 last_task_used_math = NULL;
200#else 200#else
201 clear_thread_flag(TIF_USEDFPU); 201 clear_ti_thread_flag(task_thread_info(tsk), TIF_USEDFPU);
202#endif 202#endif
203 } 203 }
204} 204}
diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
index c16ef1af1843..fa14402b33f9 100644
--- a/arch/sparc/kernel/process_64.c
+++ b/arch/sparc/kernel/process_64.c
@@ -417,9 +417,9 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
417} 417}
418 418
419/* Free current thread data structures etc.. */ 419/* Free current thread data structures etc.. */
420void exit_thread(void) 420void exit_thread(struct task_struct *tsk)
421{ 421{
422 struct thread_info *t = current_thread_info(); 422 struct thread_info *t = task_thread_info(tsk);
423 423
424 if (t->utraps) { 424 if (t->utraps) {
425 if (t->utraps[0] < 2) 425 if (t->utraps[0] < 2)
diff --git a/arch/tile/kernel/process.c b/arch/tile/kernel/process.c
index b5f30d376ce1..6b705ccc9cc1 100644
--- a/arch/tile/kernel/process.c
+++ b/arch/tile/kernel/process.c
@@ -541,7 +541,7 @@ void flush_thread(void)
541/* 541/*
542 * Free current thread data structures etc.. 542 * Free current thread data structures etc..
543 */ 543 */
544void exit_thread(void) 544void exit_thread(struct task_struct *tsk)
545{ 545{
546#ifdef CONFIG_HARDWALL 546#ifdef CONFIG_HARDWALL
547 /* 547 /*
@@ -550,7 +550,7 @@ void exit_thread(void)
550 * the last reference to a hardwall fd, it would already have 550 * the last reference to a hardwall fd, it would already have
551 * been released and deactivated at this point.) 551 * been released and deactivated at this point.)
552 */ 552 */
553 hardwall_deactivate_all(current); 553 hardwall_deactivate_all(tsk);
554#endif 554#endif
555} 555}
556 556
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 2915d54e9dd5..96becbbb52e0 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -97,10 +97,9 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
97/* 97/*
98 * Free current thread data structures etc.. 98 * Free current thread data structures etc..
99 */ 99 */
100void exit_thread(void) 100void exit_thread(struct task_struct *tsk)
101{ 101{
102 struct task_struct *me = current; 102 struct thread_struct *t = &tsk->thread;
103 struct thread_struct *t = &me->thread;
104 unsigned long *bp = t->io_bitmap_ptr; 103 unsigned long *bp = t->io_bitmap_ptr;
105 struct fpu *fpu = &t->fpu; 104 struct fpu *fpu = &t->fpu;
106 105
diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c
index 5bbfed81c97b..e0ded48561db 100644
--- a/arch/xtensa/kernel/process.c
+++ b/arch/xtensa/kernel/process.c
@@ -115,10 +115,10 @@ void arch_cpu_idle(void)
115/* 115/*
116 * This is called when the thread calls exit(). 116 * This is called when the thread calls exit().
117 */ 117 */
118void exit_thread(void) 118void exit_thread(struct task_struct *tsk)
119{ 119{
120#if XTENSA_HAVE_COPROCESSORS 120#if XTENSA_HAVE_COPROCESSORS
121 coprocessor_release_all(current_thread_info()); 121 coprocessor_release_all(task_thread_info(tsk));
122#endif 122#endif
123} 123}
124 124
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 167c0d4bf3fa..02bdab4d6db7 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2771,9 +2771,9 @@ static inline int copy_thread_tls(
2771extern void flush_thread(void); 2771extern void flush_thread(void);
2772 2772
2773#ifdef CONFIG_HAVE_EXIT_THREAD 2773#ifdef CONFIG_HAVE_EXIT_THREAD
2774extern void exit_thread(void); 2774extern void exit_thread(struct task_struct *tsk);
2775#else 2775#else
2776static inline void exit_thread(void) 2776static inline void exit_thread(struct task_struct *tsk)
2777{ 2777{
2778} 2778}
2779#endif 2779#endif
diff --git a/kernel/exit.c b/kernel/exit.c
index fd90195667e1..75b34fe835b2 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -746,7 +746,7 @@ void do_exit(long code)
746 disassociate_ctty(1); 746 disassociate_ctty(1);
747 exit_task_namespaces(tsk); 747 exit_task_namespaces(tsk);
748 exit_task_work(tsk); 748 exit_task_work(tsk);
749 exit_thread(); 749 exit_thread(tsk);
750 750
751 /* 751 /*
752 * Flush inherited counters to the parent - before the parent 752 * Flush inherited counters to the parent - before the parent