aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2008-04-28 03:30:37 -0400
committerPaul Mackerras <paulus@samba.org>2008-05-14 08:31:33 -0400
commit7a10174eeafe737f3ccfcece5bdff749c3b044e0 (patch)
tree96d3139ed19153e3369683d6b71cd74852fd1ef5
parent140b932f8cb6cced10b96860651a198b1b89cbb9 (diff)
[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>
-rw-r--r--arch/powerpc/kernel/entry_32.S4
-rw-r--r--arch/powerpc/kernel/signal.c12
-rw-r--r--arch/powerpc/kernel/signal_32.c2
-rw-r--r--arch/ppc/kernel/entry.S4
-rw-r--r--include/asm-powerpc/thread_info.h17
5 files changed, 24 insertions, 15 deletions
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 0c8614d9875c..3a05e9f93d42 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -668,7 +668,7 @@ user_exc_return: /* r10 contains MSR_KERNEL here */
668 /* Check current_thread_info()->flags */ 668 /* Check current_thread_info()->flags */
669 rlwinm r9,r1,0,0,(31-THREAD_SHIFT) 669 rlwinm r9,r1,0,0,(31-THREAD_SHIFT)
670 lwz r9,TI_FLAGS(r9) 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 bne do_work 672 bne do_work
673 673
674restore_user: 674restore_user:
@@ -925,7 +925,7 @@ recheck:
925 lwz r9,TI_FLAGS(r9) 925 lwz r9,TI_FLAGS(r9)
926 andi. r0,r9,_TIF_NEED_RESCHED 926 andi. r0,r9,_TIF_NEED_RESCHED
927 bne- do_resched 927 bne- do_resched
928 andi. r0,r9,_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK 928 andi. r0,r9,_TIF_USER_WORK_MASK
929 beq restore_user 929 beq restore_user
930do_user_signal: /* r10 contains MSR_KERNEL here */ 930do_user_signal: /* r10 contains MSR_KERNEL here */
931 ori r10,r10,MSR_EE 931 ori r10,r10,MSR_EE
diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
index a65a44fbe523..ad55488939c3 100644
--- a/arch/powerpc/kernel/signal.c
+++ b/arch/powerpc/kernel/signal.c
@@ -120,7 +120,7 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
120 int ret; 120 int ret;
121 int is32 = is_32bit_task(); 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 oldset = &current->saved_sigmask; 124 oldset = &current->saved_sigmask;
125 else if (!oldset) 125 else if (!oldset)
126 oldset = &current->blocked; 126 oldset = &current->blocked;
@@ -131,9 +131,10 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
131 check_syscall_restart(regs, &ka, signr > 0); 131 check_syscall_restart(regs, &ka, signr > 0);
132 132
133 if (signr <= 0) { 133 if (signr <= 0) {
134 struct thread_info *ti = current_thread_info();
134 /* No signal to deliver -- put the saved sigmask back */ 135 /* No signal to deliver -- put the saved sigmask back */
135 if (test_thread_flag(TIF_RESTORE_SIGMASK)) { 136 if (ti->local_flags & _TLF_RESTORE_SIGMASK) {
136 clear_thread_flag(TIF_RESTORE_SIGMASK); 137 ti->local_flags &= ~_TLF_RESTORE_SIGMASK;
137 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL); 138 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
138 } 139 }
139 return 0; /* no signals delivered */ 140 return 0; /* no signals delivered */
@@ -169,10 +170,9 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
169 170
170 /* 171 /*
171 * A signal was successfully delivered; the saved sigmask is in 172 * A signal was successfully delivered; the saved sigmask is in
172 * its frame, and we can clear the TIF_RESTORE_SIGMASK flag. 173 * its frame, and we can clear the TLF_RESTORE_SIGMASK flag.
173 */ 174 */
174 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 175 current_thread_info()->local_flags &= ~_TLF_RESTORE_SIGMASK;
175 clear_thread_flag(TIF_RESTORE_SIGMASK);
176 } 176 }
177 177
178 return ret; 178 return ret;
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index ad6943468ee9..4ae16d179803 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -243,7 +243,7 @@ long sys_sigsuspend(old_sigset_t mask)
243 243
244 current->state = TASK_INTERRUPTIBLE; 244 current->state = TASK_INTERRUPTIBLE;
245 schedule(); 245 schedule();
246 set_thread_flag(TIF_RESTORE_SIGMASK); 246 set_restore_sigmask();
247 return -ERESTARTNOHAND; 247 return -ERESTARTNOHAND;
248} 248}
249 249
diff --git a/arch/ppc/kernel/entry.S b/arch/ppc/kernel/entry.S
index 5f3a5d068a5c..fcd830a292e2 100644
--- a/arch/ppc/kernel/entry.S
+++ b/arch/ppc/kernel/entry.S
@@ -647,7 +647,7 @@ user_exc_return: /* r10 contains MSR_KERNEL here */
647 /* Check current_thread_info()->flags */ 647 /* Check current_thread_info()->flags */
648 rlwinm r9,r1,0,0,18 648 rlwinm r9,r1,0,0,18
649 lwz r9,TI_FLAGS(r9) 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 bne do_work 651 bne do_work
652 652
653restore_user: 653restore_user:
@@ -898,7 +898,7 @@ recheck:
898 lwz r9,TI_FLAGS(r9) 898 lwz r9,TI_FLAGS(r9)
899 andi. r0,r9,_TIF_NEED_RESCHED 899 andi. r0,r9,_TIF_NEED_RESCHED
900 bne- do_resched 900 bne- do_resched
901 andi. r0,r9,_TIF_SIGPENDING 901 andi. r0,r9,_TIF_USER_WORK_MASK
902 beq restore_user 902 beq restore_user
903do_user_signal: /* r10 contains MSR_KERNEL here */ 903do_user_signal: /* r10 contains MSR_KERNEL here */
904 ori r10,r10,MSR_EE 904 ori r10,r10,MSR_EE
diff --git a/include/asm-powerpc/thread_info.h b/include/asm-powerpc/thread_info.h
index d030f5ce39ad..e079e81051fd 100644
--- a/include/asm-powerpc/thread_info.h
+++ b/include/asm-powerpc/thread_info.h
@@ -116,7 +116,6 @@ static inline struct thread_info *current_thread_info(void)
116#define TIF_SECCOMP 10 /* secure computing */ 116#define TIF_SECCOMP 10 /* secure computing */
117#define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */ 117#define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
118#define TIF_NOERROR 12 /* Force successful syscall return */ 118#define TIF_NOERROR 12 /* Force successful syscall return */
119#define TIF_RESTORE_SIGMASK 13 /* Restore signal mask in do_signal */
120#define TIF_FREEZE 14 /* Freezing for suspend */ 119#define TIF_FREEZE 14 /* Freezing for suspend */
121#define TIF_RUNLATCH 15 /* Is the runlatch enabled? */ 120#define TIF_RUNLATCH 15 /* Is the runlatch enabled? */
122#define TIF_ABI_PENDING 16 /* 32/64 bit switch needed */ 121#define TIF_ABI_PENDING 16 /* 32/64 bit switch needed */
@@ -134,21 +133,31 @@ static inline struct thread_info *current_thread_info(void)
134#define _TIF_SECCOMP (1<<TIF_SECCOMP) 133#define _TIF_SECCOMP (1<<TIF_SECCOMP)
135#define _TIF_RESTOREALL (1<<TIF_RESTOREALL) 134#define _TIF_RESTOREALL (1<<TIF_RESTOREALL)
136#define _TIF_NOERROR (1<<TIF_NOERROR) 135#define _TIF_NOERROR (1<<TIF_NOERROR)
137#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
138#define _TIF_FREEZE (1<<TIF_FREEZE) 136#define _TIF_FREEZE (1<<TIF_FREEZE)
139#define _TIF_RUNLATCH (1<<TIF_RUNLATCH) 137#define _TIF_RUNLATCH (1<<TIF_RUNLATCH)
140#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) 138#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
141#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP) 139#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
142 140
143#define _TIF_USER_WORK_MASK ( _TIF_SIGPENDING | \ 141#define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED)
144 _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
145#define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR) 142#define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR)
146 143
147/* Bits in local_flags */ 144/* Bits in local_flags */
148/* Don't move TLF_NAPPING without adjusting the code in entry_32.S */ 145/* Don't move TLF_NAPPING without adjusting the code in entry_32.S */
149#define TLF_NAPPING 0 /* idle thread enabled NAP mode */ 146#define TLF_NAPPING 0 /* idle thread enabled NAP mode */
147#define TLF_RESTORE_SIGMASK 1 /* Restore signal mask in do_signal */
150 148
151#define _TLF_NAPPING (1 << TLF_NAPPING) 149#define _TLF_NAPPING (1 << TLF_NAPPING)
150#define _TLF_RESTORE_SIGMASK (1 << TLF_RESTORE_SIGMASK)
151
152#ifndef __ASSEMBLY__
153#define HAVE_SET_RESTORE_SIGMASK 1
154static inline void set_restore_sigmask(void)
155{
156 struct thread_info *ti = current_thread_info();
157 ti->local_flags |= _TLF_RESTORE_SIGMASK;
158 set_bit(TIF_SIGPENDING, &ti->flags);
159}
160#endif /* !__ASSEMBLY__ */
152 161
153#endif /* __KERNEL__ */ 162#endif /* __KERNEL__ */
154 163