signal: Consolidate {TS,TLF}_RESTORE_SIGMASK code
PATCH 1/1 signal: Consolidate {TS,TLF}_RESTORE_SIGMASK code
In general, there's no need for the "restore sigmask" flag to live in ti->flags. alpha, ia64, microblaze, powerpc, sh, sparc (64-bit only), tile, and x86 use essentially identical alternative implementations, placing the flag in ti->status.
Replace those optimized implementations with an equally good common implementation that stores it in a bitfield in struct task_struct and drop the custom implementations.
Additional architectures can opt in by removing their TIF_RESTORE_SIGMASK defines.
---
Hi Andrew-
This is a part of my virtually mapped stack series, but I think it makes sense on its own and it's cross-arch. Could you take it for 4.8? If so, the final virtually mapped stack work can base off 4.8-rc1 without needing to worry about this patch.
Changes since virtually mapped stacks v5: none (offset only)
arch/alpha/include/asm/thread_info.h | 27 -------------
arch/ia64/include/asm/thread_info.h | 28 -------------- arch/microblaze/include/asm/thread_info.h | 27 ------------- arch/powerpc/include/asm/thread_info.h | 25 ------------ arch/sh/include/asm/thread_info.h | 26 ------------- arch/sparc/include/asm/thread_info_64.h | 24 ------------ arch/tile/include/asm/thread_info.h | 27 ------------- arch/x86/include/asm/thread_info.h | 24 ------------ include/linux/sched.h | 63 +++++++++++++++++++++++++++++++ include/linux/thread_info.h | 41 -------------------- 10 files changed, 63 insertions(+), 249 deletions(-)
arch/alpha/include/asm/thread_info.h +0 -27
@@ -86,33 +86,6 @@ register struct thread_info *__current_thread_info __asm__("$8");#define TS_UAC_NOPRINT 0x0001/* ! Preserve the following three */ #define TS_UAC_NOFIX 0x0002/* ! flags as they match */ #define TS_UAC_SIGBUS 0x0004/* ! userspace part of 'osf_sysinfo' */ -#define TS_RESTORE_SIGMASK 0x0008/* restore signal mask in do_signal() */ - -#ifndef __ASSEMBLY__ -#define HAVE_SET_RESTORE_SIGMASK 1 -static inline void set_restore_sigmask (void ) -{ -struct thread_info *ti =current_thread_info (); - ti->status |=TS_RESTORE_SIGMASK ; -WARN_ON (!test_bit (TIF_SIGPENDING , (unsigned long *)&ti->flags)); -} -static inline void clear_restore_sigmask (void ) -{ -current_thread_info ()->status &= ~TS_RESTORE_SIGMASK ; -} -static inline bool test_restore_sigmask (void ) -{ -return current_thread_info ()->status &TS_RESTORE_SIGMASK ; -} -static inline bool test_and_clear_restore_sigmask (void ) -{ -struct thread_info *ti =current_thread_info (); -if (!(ti->status &TS_RESTORE_SIGMASK )) -return false; - ti->status &= ~TS_RESTORE_SIGMASK ; -return true; -} -#endif #define SET_UNALIGN_CTL (task,value) ({ \ __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \
arch/ia64/include/asm/thread_info.h +0 -28
@@ -121,32 +121,4 @@ struct thread_info {/* like TIF_ALLWORK_BITS but sans TIF_SYSCALL_TRACE or TIF_SYSCALL_AUDIT */ #define TIF_WORK_MASK (TIF_ALLWORK_MASK&~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)) -#define TS_RESTORE_SIGMASK 2/* restore signal mask in do_signal() */ - -#ifndef __ASSEMBLY__ -#define HAVE_SET_RESTORE_SIGMASK 1 -static inline void set_restore_sigmask (void ) -{ -struct thread_info *ti =current_thread_info (); - ti->status |=TS_RESTORE_SIGMASK ; -WARN_ON (!test_bit (TIF_SIGPENDING , &ti->flags)); -} -static inline void clear_restore_sigmask (void ) -{ -current_thread_info ()->status &= ~TS_RESTORE_SIGMASK ; -} -static inline bool test_restore_sigmask (void ) -{ -return current_thread_info ()->status &TS_RESTORE_SIGMASK ; -} -static inline bool test_and_clear_restore_sigmask (void ) -{ -struct thread_info *ti =current_thread_info (); -if (!(ti->status &TS_RESTORE_SIGMASK )) -return false; - ti->status &= ~TS_RESTORE_SIGMASK ; -return true; -} -#endif /* !__ASSEMBLY__ */ -#endif /* _ASM_IA64_THREAD_INFO_H */
arch/microblaze/include/asm/thread_info.h +0 -27
@@ -148,33 +148,6 @@ static inline struct thread_info *current_thread_info(void)*/ /* FPU was used by this task this quantum (SMP) */ #define TS_USEDFPU 0x0001 -#define TS_RESTORE_SIGMASK 0x0002 - -#ifndef __ASSEMBLY__ -#define HAVE_SET_RESTORE_SIGMASK 1 -static inline void set_restore_sigmask (void ) -{ -struct thread_info *ti =current_thread_info (); - ti->status |=TS_RESTORE_SIGMASK ; -WARN_ON (!test_bit (TIF_SIGPENDING , (unsigned long *)&ti->flags)); -} -static inline void clear_restore_sigmask (void ) -{ -current_thread_info ()->status &= ~TS_RESTORE_SIGMASK ; -} -static inline bool test_restore_sigmask (void ) -{ -return current_thread_info ()->status &TS_RESTORE_SIGMASK ; -} -static inline bool test_and_clear_restore_sigmask (void ) -{ -struct thread_info *ti =current_thread_info (); -if (!(ti->status &TS_RESTORE_SIGMASK )) -return false; - ti->status &= ~TS_RESTORE_SIGMASK ; -return true; -} -#endif #endif /* __KERNEL__ */ #endif /* _ASM_MICROBLAZE_THREAD_INFO_H */
arch/powerpc/include/asm/thread_info.h +0 -25
@@ -134,40 +134,15 @@ static inline struct thread_info *current_thread_info(void)/* Don't move TLF_NAPPING without adjusting the code in entry_32.S */ #define TLF_NAPPING 0/* idle thread enabled NAP mode */ #define TLF_SLEEPING 1/* suspend code enabled SLEEP mode */ -#define TLF_RESTORE_SIGMASK 2/* Restore signal mask in do_signal */ #define TLF_LAZY_MMU 3/* tlb_batch is active */ #define TLF_RUNLATCH 4/* Is the runlatch enabled? */ #define _TLF_NAPPING (1 << TLF_NAPPING)#define _TLF_SLEEPING (1 << TLF_SLEEPING) -#define _TLF_RESTORE_SIGMASK (1 << TLF_RESTORE_SIGMASK)#define _TLF_LAZY_MMU (1 << TLF_LAZY_MMU)#define _TLF_RUNLATCH (1 << TLF_RUNLATCH)#ifndef __ASSEMBLY__ -#define HAVE_SET_RESTORE_SIGMASK 1 -static inline void set_restore_sigmask (void ) -{ -struct thread_info *ti =current_thread_info (); - ti->local_flags |= _TLF_RESTORE_SIGMASK; -WARN_ON (!test_bit (TIF_SIGPENDING , &ti->flags)); -} -static inline void clear_restore_sigmask (void ) -{ -current_thread_info ()->local_flags &= ~_TLF_RESTORE_SIGMASK; -} -static inline bool test_restore_sigmask (void ) -{ -return current_thread_info ()->local_flags & _TLF_RESTORE_SIGMASK; -} -static inline bool test_and_clear_restore_sigmask (void ) -{ -struct thread_info *ti =current_thread_info (); -if (!(ti->local_flags & _TLF_RESTORE_SIGMASK)) -return false; - ti->local_flags &= ~_TLF_RESTORE_SIGMASK; -return true; -}static inline bool test_thread_local_flags (unsigned int flags) {
arch/sh/include/asm/thread_info.h +0 -26
@@ -151,19 +151,10 @@ extern void init_thread_xstate(void);* ever touches our thread-synchronous status, so we don't * have to worry about atomic accesses. */ -#define TS_RESTORE_SIGMASK 0x0001/* restore signal mask in do_signal() */ #define TS_USEDFPU 0x0002/* FPU used by this task this quantum */ #ifndef __ASSEMBLY__ -#define HAVE_SET_RESTORE_SIGMASK 1 -static inline void set_restore_sigmask (void ) -{ -struct thread_info *ti =current_thread_info (); - ti->status |=TS_RESTORE_SIGMASK ; -WARN_ON (!test_bit (TIF_SIGPENDING , (unsigned long *)&ti->flags)); -} -#define TI_FLAG_FAULT_CODE_SHIFT 24/*
@@ -182,23 +173,6 @@ static inline unsigned int get_thread_fault_code(void)return ti->flags >>TI_FLAG_FAULT_CODE_SHIFT ; } -static inline void clear_restore_sigmask (void ) -{ -current_thread_info ()->status &= ~TS_RESTORE_SIGMASK ; -} -static inline bool test_restore_sigmask (void ) -{ -return current_thread_info ()->status &TS_RESTORE_SIGMASK ; -} -static inline bool test_and_clear_restore_sigmask (void ) -{ -struct thread_info *ti =current_thread_info (); -if (!(ti->status &TS_RESTORE_SIGMASK )) -return false; - ti->status &= ~TS_RESTORE_SIGMASK ; -return true; -} -#endif /* !__ASSEMBLY__ */ #endif /* __KERNEL__ */
arch/sparc/include/asm/thread_info_64.h +0 -24
@@ -222,32 +222,8 @@ register struct thread_info *current_thread_info_reg asm("g6");* * Note that there are only 8 bits available. */ -#define TS_RESTORE_SIGMASK 0x0001/* restore signal mask in do_signal() */ #ifndef __ASSEMBLY__ -#define HAVE_SET_RESTORE_SIGMASK 1 -static inline void set_restore_sigmask (void ) -{ -struct thread_info *ti =current_thread_info (); - ti->status |=TS_RESTORE_SIGMASK ; -WARN_ON (!test_bit (TIF_SIGPENDING , &ti->flags)); -} -static inline void clear_restore_sigmask (void ) -{ -current_thread_info ()->status &= ~TS_RESTORE_SIGMASK ; -} -static inline bool test_restore_sigmask (void ) -{ -return current_thread_info ()->status &TS_RESTORE_SIGMASK ; -} -static inline bool test_and_clear_restore_sigmask (void ) -{ -struct thread_info *ti =current_thread_info (); -if (!(ti->status &TS_RESTORE_SIGMASK )) -return false; - ti->status &= ~TS_RESTORE_SIGMASK ; -return true; -}#define thread32_stack_is_64bit (__SP) (((__SP) & 0x1) != 0)#define test_thread_64bit_stack (__SP) \
arch/tile/include/asm/thread_info.h +0 -27
@@ -166,32 +166,5 @@ extern void _cpu_idle(void);#ifdef __tilegx__#define TS_COMPAT 0x0001/* 32-bit compatibility mode */ #endif -#define TS_RESTORE_SIGMASK 0x0008/* restore signal mask in do_signal */ - -#ifndef __ASSEMBLY__ -#define HAVE_SET_RESTORE_SIGMASK 1 -static inline void set_restore_sigmask (void ) -{ -struct thread_info *ti =current_thread_info (); - ti->status |=TS_RESTORE_SIGMASK ; -WARN_ON (!test_bit (TIF_SIGPENDING , &ti->flags)); -} -static inline void clear_restore_sigmask (void ) -{ -current_thread_info ()->status &= ~TS_RESTORE_SIGMASK ; -} -static inline bool test_restore_sigmask (void ) -{ -return current_thread_info ()->status &TS_RESTORE_SIGMASK ; -} -static inline bool test_and_clear_restore_sigmask (void ) -{ -struct thread_info *ti =current_thread_info (); -if (!(ti->status &TS_RESTORE_SIGMASK )) -return false; - ti->status &= ~TS_RESTORE_SIGMASK ; -return true; -} -#endif /* !__ASSEMBLY__ */ #endif /* _ASM_TILE_THREAD_INFO_H */
arch/x86/include/asm/thread_info.h +0 -24
@@ -228,32 +228,8 @@ static inline unsigned long current_stack_pointer(void)* have to worry about atomic accesses. */ #define TS_COMPAT 0x0002/* 32bit syscall active (64BIT)*/ -#define TS_RESTORE_SIGMASK 0x0008/* restore signal mask in do_signal() */ #ifndef __ASSEMBLY__ -#define HAVE_SET_RESTORE_SIGMASK 1 -static inline void set_restore_sigmask (void ) -{ -struct thread_info *ti =current_thread_info (); - ti->status |=TS_RESTORE_SIGMASK ; -WARN_ON (!test_bit (TIF_SIGPENDING , (unsigned long *)&ti->flags)); -} -static inline void clear_restore_sigmask (void ) -{ -current_thread_info ()->status &= ~TS_RESTORE_SIGMASK ; -} -static inline bool test_restore_sigmask (void ) -{ -return current_thread_info ()->status &TS_RESTORE_SIGMASK ; -} -static inline bool test_and_clear_restore_sigmask (void ) -{ -struct thread_info *ti =current_thread_info (); -if (!(ti->status &TS_RESTORE_SIGMASK )) -return false; - ti->status &= ~TS_RESTORE_SIGMASK ; -return true; -}static inline bool in_ia32_syscall (void ) {
include/linux/sched.h +63 -0
75 lines not on this page · raw message
include/linux/thread_info.h +0 -41
47 lines not on this page · raw message
Signature · 1 line
2.7.4