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

[POWERPC] Define and use TLF_RESTORE_SIGMASK

Replace TIF_RESTORE_SIGMASK with TLF_RESTORE_SIGMASK and define
our own set_restore_sigmask() function. This saves the costly
SMP-safe set_bit operation, which we do not need for the sigmask
flag since TIF_SIGPENDING always has to be set too.

Signed-off-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

Roland McGrath and committed by
Paul Mackerras
7a10174e 140b932f

+24 -15
+2 -2
arch/powerpc/kernel/entry_32.S
··· 668 668 /* Check current_thread_info()->flags */ 669 669 rlwinm r9,r1,0,0,(31-THREAD_SHIFT) 670 670 lwz r9,TI_FLAGS(r9) 671 - andi. r0,r9,(_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK|_TIF_NEED_RESCHED) 671 + andi. r0,r9,_TIF_USER_WORK_MASK 672 672 bne do_work 673 673 674 674 restore_user: ··· 925 925 lwz r9,TI_FLAGS(r9) 926 926 andi. r0,r9,_TIF_NEED_RESCHED 927 927 bne- do_resched 928 - andi. r0,r9,_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK 928 + andi. r0,r9,_TIF_USER_WORK_MASK 929 929 beq restore_user 930 930 do_user_signal: /* r10 contains MSR_KERNEL here */ 931 931 ori r10,r10,MSR_EE
+6 -6
arch/powerpc/kernel/signal.c
··· 120 120 int ret; 121 121 int is32 = is_32bit_task(); 122 122 123 - if (test_thread_flag(TIF_RESTORE_SIGMASK)) 123 + if (current_thread_info()->local_flags & _TLF_RESTORE_SIGMASK) 124 124 oldset = &current->saved_sigmask; 125 125 else if (!oldset) 126 126 oldset = &current->blocked; ··· 131 131 check_syscall_restart(regs, &ka, signr > 0); 132 132 133 133 if (signr <= 0) { 134 + struct thread_info *ti = current_thread_info(); 134 135 /* No signal to deliver -- put the saved sigmask back */ 135 - if (test_thread_flag(TIF_RESTORE_SIGMASK)) { 136 - clear_thread_flag(TIF_RESTORE_SIGMASK); 136 + if (ti->local_flags & _TLF_RESTORE_SIGMASK) { 137 + ti->local_flags &= ~_TLF_RESTORE_SIGMASK; 137 138 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL); 138 139 } 139 140 return 0; /* no signals delivered */ ··· 170 169 171 170 /* 172 171 * A signal was successfully delivered; the saved sigmask is in 173 - * its frame, and we can clear the TIF_RESTORE_SIGMASK flag. 172 + * its frame, and we can clear the TLF_RESTORE_SIGMASK flag. 174 173 */ 175 - if (test_thread_flag(TIF_RESTORE_SIGMASK)) 176 - clear_thread_flag(TIF_RESTORE_SIGMASK); 174 + current_thread_info()->local_flags &= ~_TLF_RESTORE_SIGMASK; 177 175 } 178 176 179 177 return ret;
+1 -1
arch/powerpc/kernel/signal_32.c
··· 243 243 244 244 current->state = TASK_INTERRUPTIBLE; 245 245 schedule(); 246 - set_thread_flag(TIF_RESTORE_SIGMASK); 246 + set_restore_sigmask(); 247 247 return -ERESTARTNOHAND; 248 248 } 249 249
+2 -2
arch/ppc/kernel/entry.S
··· 647 647 /* Check current_thread_info()->flags */ 648 648 rlwinm r9,r1,0,0,18 649 649 lwz r9,TI_FLAGS(r9) 650 - andi. r0,r9,(_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK|_TIF_NEED_RESCHED) 650 + andi. r0,r9,_TIF_USER_WORK_MASK 651 651 bne do_work 652 652 653 653 restore_user: ··· 898 898 lwz r9,TI_FLAGS(r9) 899 899 andi. r0,r9,_TIF_NEED_RESCHED 900 900 bne- do_resched 901 - andi. r0,r9,_TIF_SIGPENDING 901 + andi. r0,r9,_TIF_USER_WORK_MASK 902 902 beq restore_user 903 903 do_user_signal: /* r10 contains MSR_KERNEL here */ 904 904 ori r10,r10,MSR_EE
+13 -4
include/asm-powerpc/thread_info.h
··· 116 116 #define TIF_SECCOMP 10 /* secure computing */ 117 117 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */ 118 118 #define TIF_NOERROR 12 /* Force successful syscall return */ 119 - #define TIF_RESTORE_SIGMASK 13 /* Restore signal mask in do_signal */ 120 119 #define TIF_FREEZE 14 /* Freezing for suspend */ 121 120 #define TIF_RUNLATCH 15 /* Is the runlatch enabled? */ 122 121 #define TIF_ABI_PENDING 16 /* 32/64 bit switch needed */ ··· 133 134 #define _TIF_SECCOMP (1<<TIF_SECCOMP) 134 135 #define _TIF_RESTOREALL (1<<TIF_RESTOREALL) 135 136 #define _TIF_NOERROR (1<<TIF_NOERROR) 136 - #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 137 137 #define _TIF_FREEZE (1<<TIF_FREEZE) 138 138 #define _TIF_RUNLATCH (1<<TIF_RUNLATCH) 139 139 #define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) 140 140 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP) 141 141 142 - #define _TIF_USER_WORK_MASK ( _TIF_SIGPENDING | \ 143 - _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK) 142 + #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED) 144 143 #define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR) 145 144 146 145 /* Bits in local_flags */ 147 146 /* Don't move TLF_NAPPING without adjusting the code in entry_32.S */ 148 147 #define TLF_NAPPING 0 /* idle thread enabled NAP mode */ 148 + #define TLF_RESTORE_SIGMASK 1 /* Restore signal mask in do_signal */ 149 149 150 150 #define _TLF_NAPPING (1 << TLF_NAPPING) 151 + #define _TLF_RESTORE_SIGMASK (1 << TLF_RESTORE_SIGMASK) 152 + 153 + #ifndef __ASSEMBLY__ 154 + #define HAVE_SET_RESTORE_SIGMASK 1 155 + static inline void set_restore_sigmask(void) 156 + { 157 + struct thread_info *ti = current_thread_info(); 158 + ti->local_flags |= _TLF_RESTORE_SIGMASK; 159 + set_bit(TIF_SIGPENDING, &ti->flags); 160 + } 161 + #endif /* !__ASSEMBLY__ */ 151 162 152 163 #endif /* __KERNEL__ */ 153 164