Commit f6b76d4f authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

get_signal_to_deliver: use the cached ->signal/sighand values

Cache the values of current->signal/sighand.  Shrinks .text a bit and makes
the code more readable.  Also, remove "sigset_t *mask", it is pointless
because in fact we save the constant offset.
Signed-off-by: default avatarOleg Nesterov <oleg@tv-sign.ru>
Cc: Roland McGrath <roland@redhat.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ad16a460
...@@ -1753,8 +1753,9 @@ static int ptrace_signal(int signr, siginfo_t *info, ...@@ -1753,8 +1753,9 @@ static int ptrace_signal(int signr, siginfo_t *info,
int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
struct pt_regs *regs, void *cookie) struct pt_regs *regs, void *cookie)
{ {
sigset_t *mask = &current->blocked; struct sighand_struct *sighand = current->sighand;
int signr = 0; struct signal_struct *signal = current->signal;
int signr;
relock: relock:
/* /*
...@@ -1765,13 +1766,13 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, ...@@ -1765,13 +1766,13 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
*/ */
try_to_freeze(); try_to_freeze();
spin_lock_irq(&current->sighand->siglock); spin_lock_irq(&sighand->siglock);
if (unlikely(current->signal->flags & SIGNAL_CLD_MASK)) { if (unlikely(signal->flags & SIGNAL_CLD_MASK)) {
int why = (current->signal->flags & SIGNAL_STOP_CONTINUED) int why = (signal->flags & SIGNAL_STOP_CONTINUED)
? CLD_CONTINUED : CLD_STOPPED; ? CLD_CONTINUED : CLD_STOPPED;
current->signal->flags &= ~SIGNAL_CLD_MASK; signal->flags &= ~SIGNAL_CLD_MASK;
spin_unlock_irq(&current->sighand->siglock); spin_unlock_irq(&sighand->siglock);
read_lock(&tasklist_lock); read_lock(&tasklist_lock);
do_notify_parent_cldstop(current->group_leader, why); do_notify_parent_cldstop(current->group_leader, why);
...@@ -1782,12 +1783,11 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, ...@@ -1782,12 +1783,11 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
for (;;) { for (;;) {
struct k_sigaction *ka; struct k_sigaction *ka;
if (unlikely(current->signal->group_stop_count > 0) && if (unlikely(signal->group_stop_count > 0) &&
do_signal_stop(0)) do_signal_stop(0))
goto relock; goto relock;
signr = dequeue_signal(current, mask, info); signr = dequeue_signal(current, &current->blocked, info);
if (!signr) if (!signr)
break; /* will return 0 */ break; /* will return 0 */
...@@ -1797,7 +1797,7 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, ...@@ -1797,7 +1797,7 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
continue; continue;
} }
ka = &current->sighand->action[signr-1]; ka = &sighand->action[signr-1];
if (ka->sa.sa_handler == SIG_IGN) /* Do nothing. */ if (ka->sa.sa_handler == SIG_IGN) /* Do nothing. */
continue; continue;
if (ka->sa.sa_handler != SIG_DFL) { if (ka->sa.sa_handler != SIG_DFL) {
...@@ -1834,14 +1834,14 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, ...@@ -1834,14 +1834,14 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
* We need to check for that and bail out if necessary. * We need to check for that and bail out if necessary.
*/ */
if (signr != SIGSTOP) { if (signr != SIGSTOP) {
spin_unlock_irq(&current->sighand->siglock); spin_unlock_irq(&sighand->siglock);
/* signals can be posted during this window */ /* signals can be posted during this window */
if (is_current_pgrp_orphaned()) if (is_current_pgrp_orphaned())
goto relock; goto relock;
spin_lock_irq(&current->sighand->siglock); spin_lock_irq(&sighand->siglock);
} }
if (likely(do_signal_stop(signr))) { if (likely(do_signal_stop(signr))) {
...@@ -1856,7 +1856,7 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, ...@@ -1856,7 +1856,7 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
continue; continue;
} }
spin_unlock_irq(&current->sighand->siglock); spin_unlock_irq(&sighand->siglock);
/* /*
* Anything else is fatal, maybe with a core dump. * Anything else is fatal, maybe with a core dump.
...@@ -1882,7 +1882,7 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, ...@@ -1882,7 +1882,7 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
do_group_exit(signr); do_group_exit(signr);
/* NOTREACHED */ /* NOTREACHED */
} }
spin_unlock_irq(&current->sighand->siglock); spin_unlock_irq(&sighand->siglock);
return signr; return signr;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment