Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kernel: exit: cleanup release_thread()

Only x86 has own release_thread(), introduce a new weak release_thread()
function to clean empty definitions in other ARCHs.

Link: https://lkml.kernel.org/r/20220819014406.32266-1-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Acked-by: Guo Ren <guoren@kernel.org> [csky]
Acked-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Brian Cain <bcain@quicinc.com>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> [powerpc]
Acked-by: Stafford Horne <shorne@gmail.com> [openrisc]
Acked-by: Catalin Marinas <catalin.marinas@arm.com> [arm64]
Acked-by: Huacai Chen <chenhuacai@kernel.org> [LoongArch]
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Chris Zankel <chris@zankel.net>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: Guo Ren <guoren@kernel.org> [csky]
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Rich Felker <dalias@libc.org>
Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vineet Gupta <vgupta@kernel.org>
Cc: Will Deacon <will@kernel.org>
Cc: Xuerui Wang <kernel@xen0n.name>
Cc: Yoshinori Sato <ysato@users.osdn.me>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kefeng Wang and committed by
Andrew Morton
2be9880d f4068af3

+7 -118
-2
arch/alpha/include/asm/processor.h
··· 36 36 37 37 /* Free all resources held by a thread. */ 38 38 struct task_struct; 39 - extern void release_thread(struct task_struct *); 40 - 41 39 unsigned long __get_wchan(struct task_struct *p); 42 40 43 41 #define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
-5
arch/alpha/kernel/process.c
··· 225 225 current_thread_info()->pcb.unique = 0; 226 226 } 227 227 228 - void 229 - release_thread(struct task_struct *dead_task) 230 - { 231 - } 232 - 233 228 /* 234 229 * Copy architecture-specific thread state 235 230 */
-3
arch/arc/include/asm/processor.h
··· 43 43 #define task_pt_regs(p) \ 44 44 ((struct pt_regs *)(THREAD_SIZE + (void *)task_stack_page(p)) - 1) 45 45 46 - /* Free all resources held by a thread */ 47 - #define release_thread(thread) do { } while (0) 48 - 49 46 /* 50 47 * A lot of busy-wait loops in SMP are based off of non-volatile data otherwise 51 48 * get optimised away by gcc
-3
arch/arm/include/asm/processor.h
··· 81 81 /* Forward declaration, a strange C thing */ 82 82 struct task_struct; 83 83 84 - /* Free all resources held by a thread. */ 85 - extern void release_thread(struct task_struct *); 86 - 87 84 unsigned long __get_wchan(struct task_struct *p); 88 85 89 86 #define task_pt_regs(p) \
-4
arch/arm/kernel/process.c
··· 232 232 thread_notify(THREAD_NOTIFY_FLUSH, thread); 233 233 } 234 234 235 - void release_thread(struct task_struct *dead_task) 236 - { 237 - } 238 - 239 235 asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); 240 236 241 237 int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
-3
arch/arm64/include/asm/processor.h
··· 323 323 /* Forward declaration, a strange C thing */ 324 324 struct task_struct; 325 325 326 - /* Free all resources held by a thread. */ 327 - extern void release_thread(struct task_struct *); 328 - 329 326 unsigned long __get_wchan(struct task_struct *p); 330 327 331 328 void update_sctlr_el1(u64 sctlr);
-4
arch/arm64/kernel/process.c
··· 279 279 flush_tagged_addr_state(); 280 280 } 281 281 282 - void release_thread(struct task_struct *dead_task) 283 - { 284 - } 285 - 286 282 void arch_release_task_struct(struct task_struct *tsk) 287 283 { 288 284 fpsimd_release_task(tsk);
-5
arch/csky/include/asm/processor.h
··· 69 69 /* Forward declaration, a strange C thing */ 70 70 struct task_struct; 71 71 72 - /* Free all resources held by a thread. */ 73 - static inline void release_thread(struct task_struct *dead_task) 74 - { 75 - } 76 - 77 72 /* Prepare to copy thread state - unlazy all lazy status */ 78 73 #define prepare_to_copy(tsk) do { } while (0) 79 74
-4
arch/hexagon/include/asm/processor.h
··· 60 60 #define KSTK_EIP(tsk) (pt_elr(task_pt_regs(tsk))) 61 61 #define KSTK_ESP(tsk) (pt_psp(task_pt_regs(tsk))) 62 62 63 - /* Free all resources held by a thread; defined in process.c */ 64 - extern void release_thread(struct task_struct *dead_task); 65 - 66 - /* Get wait channel for task P. */ 67 63 extern unsigned long __get_wchan(struct task_struct *p); 68 64 69 65 /* The following stuff is pretty HEXAGON specific. */
-7
arch/hexagon/kernel/process.c
··· 113 113 } 114 114 115 115 /* 116 - * Release any architecture-specific resources locked by thread 117 - */ 118 - void release_thread(struct task_struct *dead_task) 119 - { 120 - } 121 - 122 - /* 123 116 * Some archs flush debug and FPU info here 124 117 */ 125 118 void flush_thread(void)
-7
arch/ia64/include/asm/processor.h
··· 318 318 struct mm_struct; 319 319 struct task_struct; 320 320 321 - /* 322 - * Free all resources held by a thread. This is called after the 323 - * parent of DEAD_TASK has collected the exit status of the task via 324 - * wait(). 325 - */ 326 - #define release_thread(dead_task) 327 - 328 321 /* Get wait channel for task P. */ 329 322 extern unsigned long __get_wchan (struct task_struct *p); 330 323
-3
arch/loongarch/include/asm/processor.h
··· 176 176 177 177 struct task_struct; 178 178 179 - /* Free all resources held by a thread. */ 180 - #define release_thread(thread) do { } while (0) 181 - 182 179 enum idle_boot_override {IDLE_NO_OVERRIDE = 0, IDLE_HALT, IDLE_NOMWAIT, IDLE_POLL}; 183 180 184 181 extern unsigned long boot_option_idle_override;
-5
arch/m68k/include/asm/processor.h
··· 145 145 /* Forward declaration, a strange C thing */ 146 146 struct task_struct; 147 147 148 - /* Free all resources held by a thread. */ 149 - static inline void release_thread(struct task_struct *dead_task) 150 - { 151 - } 152 - 153 148 unsigned long __get_wchan(struct task_struct *p); 154 149 void show_registers(struct pt_regs *regs); 155 150
-5
arch/microblaze/include/asm/processor.h
··· 63 63 .pgdir = swapper_pg_dir, \ 64 64 } 65 65 66 - /* Free all resources held by a thread. */ 67 - static inline void release_thread(struct task_struct *dead_task) 68 - { 69 - } 70 - 71 66 unsigned long __get_wchan(struct task_struct *p); 72 67 73 68 /* The size allocated for kernel stacks. This _must_ be a power of two! */
-3
arch/mips/include/asm/processor.h
··· 344 344 345 345 struct task_struct; 346 346 347 - /* Free all resources held by a thread. */ 348 - #define release_thread(thread) do { } while(0) 349 - 350 347 /* 351 348 * Do necessary setup to start up a newly executed thread. 352 349 */
-5
arch/nios2/include/asm/processor.h
··· 64 64 65 65 struct task_struct; 66 66 67 - /* Free all resources held by a thread. */ 68 - static inline void release_thread(struct task_struct *dead_task) 69 - { 70 - } 71 - 72 67 extern unsigned long __get_wchan(struct task_struct *p); 73 68 74 69 #define task_pt_regs(p) \
-1
arch/openrisc/include/asm/processor.h
··· 72 72 73 73 74 74 void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp); 75 - void release_thread(struct task_struct *); 76 75 unsigned long __get_wchan(struct task_struct *p); 77 76 78 77 #define cpu_relax() barrier()
-4
arch/openrisc/kernel/process.c
··· 125 125 show_registers(regs); 126 126 } 127 127 128 - void release_thread(struct task_struct *dead_task) 129 - { 130 - } 131 - 132 128 /* 133 129 * Copy the thread-specific (arch specific) info from the current 134 130 * process to the new one p
-3
arch/parisc/include/asm/processor.h
··· 266 266 267 267 struct mm_struct; 268 268 269 - /* Free all resources held by a thread. */ 270 - extern void release_thread(struct task_struct *); 271 - 272 269 extern unsigned long __get_wchan(struct task_struct *p); 273 270 274 271 #define KSTK_EIP(tsk) ((tsk)->thread.regs.iaoq[0])
-4
arch/parisc/kernel/process.c
··· 146 146 */ 147 147 } 148 148 149 - void release_thread(struct task_struct *dead_task) 150 - { 151 - } 152 - 153 149 /* 154 150 * Idle thread support 155 151 *
-1
arch/powerpc/include/asm/processor.h
··· 75 75 76 76 struct task_struct; 77 77 void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp); 78 - void release_thread(struct task_struct *); 79 78 80 79 #define TS_FPR(i) fp_state.fpr[i][TS_FPROFFSET] 81 80 #define TS_CKFPR(i) ckfp_state.fpr[i][TS_FPROFFSET]
-5
arch/powerpc/kernel/process.c
··· 1655 1655 1656 1656 #endif /* CONFIG_PPC64 */ 1657 1657 1658 - void 1659 - release_thread(struct task_struct *t) 1660 - { 1661 - } 1662 - 1663 1658 /* 1664 1659 * this gets called so that we can store coprocessor state into memory and 1665 1660 * copy the current task into the new thread.
-5
arch/riscv/include/asm/processor.h
··· 65 65 extern void start_thread(struct pt_regs *regs, 66 66 unsigned long pc, unsigned long sp); 67 67 68 - /* Free all resources held by a thread. */ 69 - static inline void release_thread(struct task_struct *dead_task) 70 - { 71 - } 72 - 73 68 extern unsigned long __get_wchan(struct task_struct *p); 74 69 75 70
-3
arch/s390/include/asm/processor.h
··· 186 186 void show_registers(struct pt_regs *regs); 187 187 void show_cacheinfo(struct seq_file *m); 188 188 189 - /* Free all resources held by a thread. */ 190 - static inline void release_thread(struct task_struct *tsk) { } 191 - 192 189 /* Free guarded storage control block */ 193 190 void guarded_storage_release(struct task_struct *tsk); 194 191 void gs_load_bc_cb(struct pt_regs *regs);
-3
arch/sh/include/asm/processor_32.h
··· 127 127 128 128 extern void start_thread(struct pt_regs *regs, unsigned long new_pc, unsigned long new_sp); 129 129 130 - /* Free all resources held by a thread. */ 131 - extern void release_thread(struct task_struct *); 132 - 133 130 /* 134 131 * FPU lazy state save handling. 135 132 */
-5
arch/sh/kernel/process_32.c
··· 84 84 #endif 85 85 } 86 86 87 - void release_thread(struct task_struct *dead_task) 88 - { 89 - /* do nothing */ 90 - } 91 - 92 87 asmlinkage void ret_from_fork(void); 93 88 asmlinkage void ret_from_kernel_thread(void); 94 89
-3
arch/sparc/include/asm/processor_32.h
··· 80 80 : "memory"); 81 81 } 82 82 83 - /* Free all resources held by a thread. */ 84 - #define release_thread(tsk) do { } while(0) 85 - 86 83 unsigned long __get_wchan(struct task_struct *); 87 84 88 85 #define task_pt_regs(tsk) ((tsk)->thread.kregs)
-3
arch/sparc/include/asm/processor_64.h
··· 176 176 regs->tstate &= ~TSTATE_PEF; \ 177 177 } while (0) 178 178 179 - /* Free all resources held by a thread. */ 180 - #define release_thread(tsk) do { } while (0) 181 - 182 179 unsigned long __get_wchan(struct task_struct *task); 183 180 184 181 #define task_pt_regs(tsk) (task_thread_info(tsk)->kregs)
-4
arch/um/include/asm/processor-generic.h
··· 55 55 .request = { 0 } \ 56 56 } 57 57 58 - static inline void release_thread(struct task_struct *task) 59 - { 60 - } 61 - 62 58 /* 63 59 * User space process size: 3GB (default). 64 60 */
-3
arch/x86/include/asm/processor.h
··· 587 587 588 588 #endif /* CONFIG_PARAVIRT_XXL */ 589 589 590 - /* Free all resources held by a thread. */ 591 - extern void release_thread(struct task_struct *); 592 - 593 590 unsigned long __get_wchan(struct task_struct *p); 594 591 595 592 /*
-3
arch/xtensa/include/asm/processor.h
··· 221 221 struct task_struct; 222 222 struct mm_struct; 223 223 224 - /* Free all resources held by a thread. */ 225 - #define release_thread(thread) do { } while(0) 226 - 227 224 extern unsigned long __get_wchan(struct task_struct *p); 228 225 229 226 #define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
+3
include/linux/sched/task.h
··· 127 127 128 128 void put_task_struct_rcu_user(struct task_struct *task); 129 129 130 + /* Free all architecture-specific resources held by a thread. */ 131 + void release_thread(struct task_struct *dead_task); 132 + 130 133 #ifdef CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT 131 134 extern int arch_task_struct_size __read_mostly; 132 135 #else
+4
kernel/exit.c
··· 183 183 call_rcu(&task->rcu, delayed_put_task_struct); 184 184 } 185 185 186 + void __weak release_thread(struct task_struct *dead_task) 187 + { 188 + } 189 + 186 190 void release_task(struct task_struct *p) 187 191 { 188 192 struct task_struct *leader;