* [PATCH] powerpc TLF_RESTORE_SIGMASK
@ 2008-04-03 21:08 Roland McGrath
2008-04-10 6:51 ` Andrew Morton
2008-04-23 5:04 ` Paul Mackerras
0 siblings, 2 replies; 9+ messages in thread
From: Roland McGrath @ 2008-04-03 21:08 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev, linux-kernel
This requires the earlier HAVE_SET_RESTORE_SIGMASK patch series.
This does the same for powerpc that I posted the x86 change for.
---
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>
---
arch/powerpc/kernel/entry_32.S | 4 ++--
arch/powerpc/kernel/signal.c | 12 ++++++------
arch/powerpc/kernel/signal_32.c | 2 +-
include/asm-powerpc/thread_info.h | 17 +++++++++++++----
4 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 69a91bd..646daf4 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -661,7 +661,7 @@ user_exc_return: /* r10 contains MSR_KERNEL here */
/* Check current_thread_info()->flags */
rlwinm r9,r1,0,0,(31-THREAD_SHIFT)
lwz r9,TI_FLAGS(r9)
- andi. r0,r9,(_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK|_TIF_NEED_RESCHED)
+ andi. r0,r9,(_TIF_SIGPENDING|_TIF_NEED_RESCHED)
bne do_work
restore_user:
@@ -912,7 +912,7 @@ recheck:
lwz r9,TI_FLAGS(r9)
andi. r0,r9,_TIF_NEED_RESCHED
bne- do_resched
- andi. r0,r9,_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK
+ andi. r0,r9,_TIF_SIGPENDING
beq restore_user
do_user_signal: /* r10 contains MSR_KERNEL here */
ori r10,r10,MSR_EE
diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
index a65a44f..ad55488 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)
int ret;
int is32 = is_32bit_task();
- if (test_thread_flag(TIF_RESTORE_SIGMASK))
+ if (current_thread_info()->local_flags & _TLF_RESTORE_SIGMASK)
oldset = ¤t->saved_sigmask;
else if (!oldset)
oldset = ¤t->blocked;
@@ -131,9 +131,10 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
check_syscall_restart(regs, &ka, signr > 0);
if (signr <= 0) {
+ struct thread_info *ti = current_thread_info();
/* No signal to deliver -- put the saved sigmask back */
- if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
- clear_thread_flag(TIF_RESTORE_SIGMASK);
+ if (ti->local_flags & _TLF_RESTORE_SIGMASK) {
+ ti->local_flags &= ~_TLF_RESTORE_SIGMASK;
sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL);
}
return 0; /* no signals delivered */
@@ -169,10 +170,9 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
/*
* A signal was successfully delivered; the saved sigmask is in
- * its frame, and we can clear the TIF_RESTORE_SIGMASK flag.
+ * its frame, and we can clear the TLF_RESTORE_SIGMASK flag.
*/
- if (test_thread_flag(TIF_RESTORE_SIGMASK))
- clear_thread_flag(TIF_RESTORE_SIGMASK);
+ current_thread_info()->local_flags &= ~_TLF_RESTORE_SIGMASK;
}
return ret;
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index ad69434..4ae16d1 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)
current->state = TASK_INTERRUPTIBLE;
schedule();
- set_thread_flag(TIF_RESTORE_SIGMASK);
+ set_restore_sigmask();
return -ERESTARTNOHAND;
}
diff --git a/include/asm-powerpc/thread_info.h b/include/asm-powerpc/thread_info.h
index 40d5f98..3b9271b 100644
--- a/include/asm-powerpc/thread_info.h
+++ b/include/asm-powerpc/thread_info.h
@@ -120,7 +120,6 @@ static inline struct thread_info *current_thread_info(void)
#define TIF_SECCOMP 10 /* secure computing */
#define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
#define TIF_NOERROR 12 /* Force successful syscall return */
-#define TIF_RESTORE_SIGMASK 13 /* Restore signal mask in do_signal */
#define TIF_FREEZE 14 /* Freezing for suspend */
#define TIF_RUNLATCH 15 /* Is the runlatch enabled? */
#define TIF_ABI_PENDING 16 /* 32/64 bit switch needed */
@@ -138,21 +137,31 @@ static inline struct thread_info *current_thread_info(void)
#define _TIF_SECCOMP (1<<TIF_SECCOMP)
#define _TIF_RESTOREALL (1<<TIF_RESTOREALL)
#define _TIF_NOERROR (1<<TIF_NOERROR)
-#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
#define _TIF_FREEZE (1<<TIF_FREEZE)
#define _TIF_RUNLATCH (1<<TIF_RUNLATCH)
#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
-#define _TIF_USER_WORK_MASK ( _TIF_SIGPENDING | \
- _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
+#define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED)
#define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR)
/* Bits in local_flags */
/* Don't move TLF_NAPPING without adjusting the code in entry_32.S */
#define TLF_NAPPING 0 /* idle thread enabled NAP mode */
+#define TLF_RESTORE_SIGMASK 1 /* Restore signal mask in do_signal */
#define _TLF_NAPPING (1 << TLF_NAPPING)
+#define _TLF_RESTORE_SIGMASK (1 << TLF_RESTORE_SIGMASK)
+
+#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;
+ set_bit(TIF_SIGPENDING, &ti->flags);
+}
+#endif /* !__ASSEMBLY__ */
#endif /* __KERNEL__ */
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc TLF_RESTORE_SIGMASK
2008-04-03 21:08 [PATCH] powerpc TLF_RESTORE_SIGMASK Roland McGrath
@ 2008-04-10 6:51 ` Andrew Morton
2008-04-11 1:36 ` Roland McGrath
2008-04-23 5:04 ` Paul Mackerras
1 sibling, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2008-04-10 6:51 UTC (permalink / raw)
To: Roland McGrath; +Cc: linuxppc-dev, Paul Mackerras, linux-kernel
On Thu, 3 Apr 2008 14:08:42 -0700 (PDT) Roland McGrath <roland@redhat.com> wrote:
> This requires the earlier HAVE_SET_RESTORE_SIGMASK patch series.
> This does the same for powerpc that I posted the x86 change for.
>
> ---
> 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>
> ---
> arch/powerpc/kernel/entry_32.S | 4 ++--
> arch/powerpc/kernel/signal.c | 12 ++++++------
> arch/powerpc/kernel/signal_32.c | 2 +-
> include/asm-powerpc/thread_info.h | 17 +++++++++++++----
> 4 files changed, 22 insertions(+), 13 deletions(-)
This crashes my powerpc mac g5.
EXT3-fs: INFO: recovery required on readonly filesystem.
EXT3-fs: write access will be enabled during recovery.
kjournald starting. Commit interval 5 seconds
EXT3-fs: recovery complete.
EXT3-fs: mounted filesystem with ordered data mode.
Unable to handle kernel paging request for data at address 0x0000003d
Faulting instruction address: 0xc0000000000dbc3c
Oops: Kernel access of bad area, sig: 11 [#1]
SMP NR_CPUS=4 PowerMac
Modules linked in: autofs
NIP: c0000000000dbc3c LR: c0000000000dbda8 CTR: c0000000000dbd40
REGS: c000000178607a70 TRAP: 0300 Not tainted (2.6.25-rc8-mm2)
MSR: 9000000000009032 <EE,ME,IR,DR> CR: 42284448 XER: 20000000
DAR: 000000000000003d, DSISR: 0000000040000000
TASK = c000000178f792e0[2488] 'zsh' THREAD: c000000178604000 CPU: 0
GPR00: c0000000000dbda8 c000000178607cf0 c0000000006df7e8 000000000000000d
GPR04: 0000000000000000 0000000000000001 00000000ffb46c08 0000000000000001
GPR08: 00000000f7ff8000 c000000178607ea0 c0000000000dbd40 000000000000000d
GPR12: 100000000000d032 c000000000622e80 0000000010090000 0000000000000000
GPR16: 0000000000000001 0000000010090000 0000000010092ff8 00000000100ac34c
GPR20: 0000000000000000 0000000000000001 0000000000000000 0000000000000001
GPR24: 0000000000000000 00000000ffb46c08 000000000000000d 0000000000000000
GPR28: 0000000000000000 0000000000000001 c00000000068ff50 ffffffffffffffea
NIP [c0000000000dbc3c] .vfs_llseek+0x1c/0x84
LR [c0000000000dbda8] .sys_llseek+0x68/0xf0
Call Trace:
[c000000178607cf0] [c00000000009e210] .audit_syscall_exit+0x3fc/0x40c (unreliable)
[c000000178607d70] [c0000000000dbda8] .sys_llseek+0x68/0xf0
[c000000178607e30] [c00000000000872c] syscall_exit+0x0/0x40
Instruction dump:
e93c0018 e9690010 e80b0068 7fff0214 4bffff94 7c0802a6 fbc1fff0 ebc2abe8
7c6b1b78 f8010010 f821ff81 60000000 <80030030> 7809f7e3 e93e8000 41820024
It happens after the boot, during the first login-over-ssh.
This is with most of the rest of the -mm poopile applied. i386 and x86_64
seem OK.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc TLF_RESTORE_SIGMASK
2008-04-10 6:51 ` Andrew Morton
@ 2008-04-11 1:36 ` Roland McGrath
2008-04-11 1:50 ` Andrew Morton
0 siblings, 1 reply; 9+ messages in thread
From: Roland McGrath @ 2008-04-11 1:36 UTC (permalink / raw)
To: Andrew Morton; +Cc: linuxppc-dev, Paul Mackerras, linux-kernel
> This crashes my powerpc mac g5.
It worked fine on mine.
> It happens after the boot, during the first login-over-ssh.
Mine did lots of stuff fine.
> This is with most of the rest of the -mm poopile applied. i386 and x86_64
> seem OK.
I had only tested with Linus's tree plus the small handful of post-2.6.25
cleanup patches I've posted in the last few weeks. To be precise it was
9597362d354f8655ece324b01d0c640a0e99c077 plus several of my cleanup patches
(that are probably all in -mm, but I'm not sure off hand).
I'd rebased my tree today to 783e391b7b5b273cd20856d8f6f4878da8ec31b3
anyway. I just tried the new kernel with the sigmask cleanups and only
a few other patches, and have no problems.
The details of your crash make it look pretty unrelated to this code.
Off hand I would guess that it's some other bug from other -mm patches
that just happens only to bite you on powerpc. If the crash is not
intermittent and you bisected it to this one change, then I am at a
loss to see what might be happening. I'd have to leave it to Paul et
al to figure out if there is some strange powerpc juju going on.
Thanks,
Roland
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc TLF_RESTORE_SIGMASK
2008-04-11 1:36 ` Roland McGrath
@ 2008-04-11 1:50 ` Andrew Morton
0 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2008-04-11 1:50 UTC (permalink / raw)
To: Roland McGrath; +Cc: linuxppc-dev, Paul Mackerras, linux-kernel
On Thu, 10 Apr 2008 18:36:35 -0700 (PDT) Roland McGrath <roland@redhat.com> wrote:
> > This crashes my powerpc mac g5.
>
> It worked fine on mine.
>
> > It happens after the boot, during the first login-over-ssh.
>
> Mine did lots of stuff fine.
>
> > This is with most of the rest of the -mm poopile applied. i386 and x86_64
> > seem OK.
>
> I had only tested with Linus's tree plus the small handful of post-2.6.25
> cleanup patches I've posted in the last few weeks. To be precise it was
> 9597362d354f8655ece324b01d0c640a0e99c077 plus several of my cleanup patches
> (that are probably all in -mm, but I'm not sure off hand).
>
> I'd rebased my tree today to 783e391b7b5b273cd20856d8f6f4878da8ec31b3
> anyway. I just tried the new kernel with the sigmask cleanups and only
> a few other patches, and have no problems.
>
> The details of your crash make it look pretty unrelated to this code.
> Off hand I would guess that it's some other bug from other -mm patches
> that just happens only to bite you on powerpc. If the crash is not
> intermittent and you bisected it to this one change, then I am at a
> loss to see what might be happening. I'd have to leave it to Paul et
> al to figure out if there is some strange powerpc juju going on.
It's 100% repeatable and I bisected it to this change.
I expect you could repeat it by applying it to
http://userweb.kernel.org/~akpm/mmotm/ (or to -rc6-mm2, if I ever manage to
get it to boot on something) and using
http://userweb.kernel.org/~akpm/config-g5.txt
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc TLF_RESTORE_SIGMASK
2008-04-03 21:08 [PATCH] powerpc TLF_RESTORE_SIGMASK Roland McGrath
2008-04-10 6:51 ` Andrew Morton
@ 2008-04-23 5:04 ` Paul Mackerras
2008-04-23 6:37 ` Roland McGrath
1 sibling, 1 reply; 9+ messages in thread
From: Paul Mackerras @ 2008-04-23 5:04 UTC (permalink / raw)
To: Roland McGrath; +Cc: linuxppc-dev, akpm, linux-kernel
Roland McGrath writes:
> This requires the earlier HAVE_SET_RESTORE_SIGMASK patch series.
> This does the same for powerpc that I posted the x86 change for.
...
> +static inline void set_restore_sigmask(void)
> +{
> + struct thread_info *ti = current_thread_info();
> + ti->local_flags |= TLF_RESTORE_SIGMASK;
This should be _TLF_RESTORE_SIGMASK (leading '_'), I think.
Paul.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc TLF_RESTORE_SIGMASK
2008-04-23 5:04 ` Paul Mackerras
@ 2008-04-23 6:37 ` Roland McGrath
2008-04-24 6:31 ` Paul Mackerras
2008-04-24 6:34 ` Paul Mackerras
0 siblings, 2 replies; 9+ messages in thread
From: Roland McGrath @ 2008-04-23 6:37 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev, akpm, linux-kernel
> Roland McGrath writes:
>
> > This requires the earlier HAVE_SET_RESTORE_SIGMASK patch series.
> > This does the same for powerpc that I posted the x86 change for.
>
> ...
>
> > +static inline void set_restore_sigmask(void)
> > +{
> > + struct thread_info *ti = current_thread_info();
> > + ti->local_flags |= TLF_RESTORE_SIGMASK;
>
> This should be _TLF_RESTORE_SIGMASK (leading '_'), I think.
Indeed so. Here's a replacement patch.
Thanks,
Roland
---
[PATCH] powerpc 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>
---
arch/powerpc/kernel/entry_32.S | 4 ++--
arch/powerpc/kernel/signal.c | 12 ++++++------
arch/powerpc/kernel/signal_32.c | 2 +-
include/asm-powerpc/thread_info.h | 17 +++++++++++++----
4 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 84c8686..f056b3c 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -667,7 +667,7 @@ user_exc_return: /* r10 contains MSR_KERNEL here */
/* Check current_thread_info()->flags */
rlwinm r9,r1,0,0,(31-THREAD_SHIFT)
lwz r9,TI_FLAGS(r9)
- andi. r0,r9,(_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK|_TIF_NEED_RESCHED)
+ andi. r0,r9,(_TIF_SIGPENDING|_TIF_NEED_RESCHED)
bne do_work
restore_user:
@@ -924,7 +924,7 @@ recheck:
lwz r9,TI_FLAGS(r9)
andi. r0,r9,_TIF_NEED_RESCHED
bne- do_resched
- andi. r0,r9,_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK
+ andi. r0,r9,_TIF_SIGPENDING
beq restore_user
do_user_signal: /* r10 contains MSR_KERNEL here */
ori r10,r10,MSR_EE
diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
index a65a44f..ad55488 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)
int ret;
int is32 = is_32bit_task();
- if (test_thread_flag(TIF_RESTORE_SIGMASK))
+ if (current_thread_info()->local_flags & _TLF_RESTORE_SIGMASK)
oldset = ¤t->saved_sigmask;
else if (!oldset)
oldset = ¤t->blocked;
@@ -131,9 +131,10 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
check_syscall_restart(regs, &ka, signr > 0);
if (signr <= 0) {
+ struct thread_info *ti = current_thread_info();
/* No signal to deliver -- put the saved sigmask back */
- if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
- clear_thread_flag(TIF_RESTORE_SIGMASK);
+ if (ti->local_flags & _TLF_RESTORE_SIGMASK) {
+ ti->local_flags &= ~_TLF_RESTORE_SIGMASK;
sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL);
}
return 0; /* no signals delivered */
@@ -169,10 +170,9 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
/*
* A signal was successfully delivered; the saved sigmask is in
- * its frame, and we can clear the TIF_RESTORE_SIGMASK flag.
+ * its frame, and we can clear the TLF_RESTORE_SIGMASK flag.
*/
- if (test_thread_flag(TIF_RESTORE_SIGMASK))
- clear_thread_flag(TIF_RESTORE_SIGMASK);
+ current_thread_info()->local_flags &= ~_TLF_RESTORE_SIGMASK;
}
return ret;
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index ad69434..4ae16d1 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)
current->state = TASK_INTERRUPTIBLE;
schedule();
- set_thread_flag(TIF_RESTORE_SIGMASK);
+ set_restore_sigmask();
return -ERESTARTNOHAND;
}
diff --git a/include/asm-powerpc/thread_info.h b/include/asm-powerpc/thread_info.h
index 40d5f98..07d5106 100644
--- a/include/asm-powerpc/thread_info.h
+++ b/include/asm-powerpc/thread_info.h
@@ -120,7 +120,6 @@ static inline struct thread_info *current_thread_info(void)
#define TIF_SECCOMP 10 /* secure computing */
#define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
#define TIF_NOERROR 12 /* Force successful syscall return */
-#define TIF_RESTORE_SIGMASK 13 /* Restore signal mask in do_signal */
#define TIF_FREEZE 14 /* Freezing for suspend */
#define TIF_RUNLATCH 15 /* Is the runlatch enabled? */
#define TIF_ABI_PENDING 16 /* 32/64 bit switch needed */
@@ -138,21 +137,31 @@ static inline struct thread_info *current_thread_info(void)
#define _TIF_SECCOMP (1<<TIF_SECCOMP)
#define _TIF_RESTOREALL (1<<TIF_RESTOREALL)
#define _TIF_NOERROR (1<<TIF_NOERROR)
-#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
#define _TIF_FREEZE (1<<TIF_FREEZE)
#define _TIF_RUNLATCH (1<<TIF_RUNLATCH)
#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
-#define _TIF_USER_WORK_MASK ( _TIF_SIGPENDING | \
- _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
+#define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED)
#define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR)
/* Bits in local_flags */
/* Don't move TLF_NAPPING without adjusting the code in entry_32.S */
#define TLF_NAPPING 0 /* idle thread enabled NAP mode */
+#define TLF_RESTORE_SIGMASK 1 /* Restore signal mask in do_signal */
#define _TLF_NAPPING (1 << TLF_NAPPING)
+#define _TLF_RESTORE_SIGMASK (1 << TLF_RESTORE_SIGMASK)
+
+#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;
+ set_bit(TIF_SIGPENDING, &ti->flags);
+}
+#endif /* !__ASSEMBLY__ */
#endif /* __KERNEL__ */
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc TLF_RESTORE_SIGMASK
2008-04-23 6:37 ` Roland McGrath
@ 2008-04-24 6:31 ` Paul Mackerras
2008-04-28 7:30 ` Roland McGrath
2008-04-24 6:34 ` Paul Mackerras
1 sibling, 1 reply; 9+ messages in thread
From: Paul Mackerras @ 2008-04-24 6:31 UTC (permalink / raw)
To: Roland McGrath; +Cc: linuxppc-dev, akpm, linux-kernel
Roland McGrath writes:
> > This should be _TLF_RESTORE_SIGMASK (leading '_'), I think.
>
> Indeed so. Here's a replacement patch.
Thanks. That can't go in until some generic changes have gone in
first, right? So are you going to push the lot in one go via Andrew,
or should I wait until the generic part is upstream and then push the
powerpc bit?
Paul.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc TLF_RESTORE_SIGMASK
2008-04-23 6:37 ` Roland McGrath
2008-04-24 6:31 ` Paul Mackerras
@ 2008-04-24 6:34 ` Paul Mackerras
1 sibling, 0 replies; 9+ messages in thread
From: Paul Mackerras @ 2008-04-24 6:34 UTC (permalink / raw)
To: Roland McGrath; +Cc: linuxppc-dev, akpm, linux-kernel
Roland McGrath writes:
> Indeed so. Here's a replacement patch.
Oh, and could you please also fix the occurrence of
TIF_RESTORE_SIGMASK in arch/ppc/kernel/entry.S when this stuff goes
in?
Thanks,
Paul.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc TLF_RESTORE_SIGMASK
2008-04-24 6:31 ` Paul Mackerras
@ 2008-04-28 7:30 ` Roland McGrath
0 siblings, 0 replies; 9+ messages in thread
From: Roland McGrath @ 2008-04-28 7:30 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev, akpm, linux-kernel
> Thanks. That can't go in until some generic changes have gone in
> first, right? So are you going to push the lot in one go via Andrew,
> or should I wait until the generic part is upstream and then push the
> powerpc bit?
>From what I can see, the related patches are in -mm now, but the powerpc
patch is not. Linus already said he approved of the patches, so I hope
they can be merged in real soon. That will simplify the juggling for arch
patches. That said, there is really no hurry for this change for powerpc;
it's a small optimization.
> Oh, and could you please also fix the occurrence of
> TIF_RESTORE_SIGMASK in arch/ppc/kernel/entry.S when this stuff goes
> in?
Oh, I didn't realize that file was in use (or existed).
Third time's the charm (or is this the fifth time?).
Thanks,
Roland
---
[PATCH] powerpc 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>
---
arch/powerpc/kernel/entry_32.S | 4 ++--
arch/powerpc/kernel/signal.c | 12 ++++++------
arch/powerpc/kernel/signal_32.c | 2 +-
arch/ppc/kernel/entry.S | 4 ++--
include/asm-powerpc/thread_info.h | 17 +++++++++++++----
5 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 84c8686..7e2ecf0 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -667,7 +667,7 @@ user_exc_return: /* r10 contains MSR_KERNEL here */
/* Check current_thread_info()->flags */
rlwinm r9,r1,0,0,(31-THREAD_SHIFT)
lwz r9,TI_FLAGS(r9)
- andi. r0,r9,(_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK|_TIF_NEED_RESCHED)
+ andi. r0,r9,_TIF_USER_WORK_MASK
bne do_work
restore_user:
@@ -924,7 +924,7 @@ recheck:
lwz r9,TI_FLAGS(r9)
andi. r0,r9,_TIF_NEED_RESCHED
bne- do_resched
- andi. r0,r9,_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK
+ andi. r0,r9,_TIF_USER_WORK_MASK
beq restore_user
do_user_signal: /* r10 contains MSR_KERNEL here */
ori r10,r10,MSR_EE
diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
index a65a44f..ad55488 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)
int ret;
int is32 = is_32bit_task();
- if (test_thread_flag(TIF_RESTORE_SIGMASK))
+ if (current_thread_info()->local_flags & _TLF_RESTORE_SIGMASK)
oldset = ¤t->saved_sigmask;
else if (!oldset)
oldset = ¤t->blocked;
@@ -131,9 +131,10 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
check_syscall_restart(regs, &ka, signr > 0);
if (signr <= 0) {
+ struct thread_info *ti = current_thread_info();
/* No signal to deliver -- put the saved sigmask back */
- if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
- clear_thread_flag(TIF_RESTORE_SIGMASK);
+ if (ti->local_flags & _TLF_RESTORE_SIGMASK) {
+ ti->local_flags &= ~_TLF_RESTORE_SIGMASK;
sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL);
}
return 0; /* no signals delivered */
@@ -169,10 +170,9 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
/*
* A signal was successfully delivered; the saved sigmask is in
- * its frame, and we can clear the TIF_RESTORE_SIGMASK flag.
+ * its frame, and we can clear the TLF_RESTORE_SIGMASK flag.
*/
- if (test_thread_flag(TIF_RESTORE_SIGMASK))
- clear_thread_flag(TIF_RESTORE_SIGMASK);
+ current_thread_info()->local_flags &= ~_TLF_RESTORE_SIGMASK;
}
return ret;
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index ad69434..4ae16d1 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)
current->state = TASK_INTERRUPTIBLE;
schedule();
- set_thread_flag(TIF_RESTORE_SIGMASK);
+ set_restore_sigmask();
return -ERESTARTNOHAND;
}
diff --git a/arch/ppc/kernel/entry.S b/arch/ppc/kernel/entry.S
index 5f3a5d0..fcd830a 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 */
/* Check current_thread_info()->flags */
rlwinm r9,r1,0,0,18
lwz r9,TI_FLAGS(r9)
- andi. r0,r9,(_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK|_TIF_NEED_RESCHED)
+ andi. r0,r9,_TIF_USER_WORK_MASK
bne do_work
restore_user:
@@ -898,7 +898,7 @@ recheck:
lwz r9,TI_FLAGS(r9)
andi. r0,r9,_TIF_NEED_RESCHED
bne- do_resched
- andi. r0,r9,_TIF_SIGPENDING
+ andi. r0,r9,_TIF_USER_WORK_MASK
beq restore_user
do_user_signal: /* r10 contains MSR_KERNEL here */
ori r10,r10,MSR_EE
diff --git a/include/asm-powerpc/thread_info.h b/include/asm-powerpc/thread_info.h
index d030f5c..e079e81 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)
#define TIF_SECCOMP 10 /* secure computing */
#define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
#define TIF_NOERROR 12 /* Force successful syscall return */
-#define TIF_RESTORE_SIGMASK 13 /* Restore signal mask in do_signal */
#define TIF_FREEZE 14 /* Freezing for suspend */
#define TIF_RUNLATCH 15 /* Is the runlatch enabled? */
#define TIF_ABI_PENDING 16 /* 32/64 bit switch needed */
@@ -134,21 +133,31 @@ static inline struct thread_info *current_thread_info(void)
#define _TIF_SECCOMP (1<<TIF_SECCOMP)
#define _TIF_RESTOREALL (1<<TIF_RESTOREALL)
#define _TIF_NOERROR (1<<TIF_NOERROR)
-#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
#define _TIF_FREEZE (1<<TIF_FREEZE)
#define _TIF_RUNLATCH (1<<TIF_RUNLATCH)
#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
-#define _TIF_USER_WORK_MASK ( _TIF_SIGPENDING | \
- _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
+#define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED)
#define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR)
/* Bits in local_flags */
/* Don't move TLF_NAPPING without adjusting the code in entry_32.S */
#define TLF_NAPPING 0 /* idle thread enabled NAP mode */
+#define TLF_RESTORE_SIGMASK 1 /* Restore signal mask in do_signal */
#define _TLF_NAPPING (1 << TLF_NAPPING)
+#define _TLF_RESTORE_SIGMASK (1 << TLF_RESTORE_SIGMASK)
+
+#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;
+ set_bit(TIF_SIGPENDING, &ti->flags);
+}
+#endif /* !__ASSEMBLY__ */
#endif /* __KERNEL__ */
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-04-28 7:30 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-03 21:08 [PATCH] powerpc TLF_RESTORE_SIGMASK Roland McGrath
2008-04-10 6:51 ` Andrew Morton
2008-04-11 1:36 ` Roland McGrath
2008-04-11 1:50 ` Andrew Morton
2008-04-23 5:04 ` Paul Mackerras
2008-04-23 6:37 ` Roland McGrath
2008-04-24 6:31 ` Paul Mackerras
2008-04-28 7:30 ` Roland McGrath
2008-04-24 6:34 ` Paul Mackerras
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).