Skip to content

Commit 88531f7

Browse files
Oleg NesterovLinus Torvalds
authored andcommitted
[PATCH] do_sigaction: don't take tasklist_lock
do_sigaction() does not need tasklist_lock anymore, we can simplify the code. Signed-off-by: Oleg Nesterov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent aacc909 commit 88531f7

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

kernel/signal.c

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,8 +2301,7 @@ sys_rt_sigqueueinfo(int pid, int sig, siginfo_t __user *uinfo)
23012301
return kill_proc_info(sig, &info, pid);
23022302
}
23032303

2304-
int
2305-
do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
2304+
int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
23062305
{
23072306
struct k_sigaction *k;
23082307
sigset_t mask;
@@ -2328,6 +2327,7 @@ do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
23282327
if (act) {
23292328
sigdelsetmask(&act->sa.sa_mask,
23302329
sigmask(SIGKILL) | sigmask(SIGSTOP));
2330+
*k = *act;
23312331
/*
23322332
* POSIX 3.3.1.3:
23332333
* "Setting a signal action to SIG_IGN for a signal that is
@@ -2340,19 +2340,8 @@ do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
23402340
* be discarded, whether or not it is blocked"
23412341
*/
23422342
if (act->sa.sa_handler == SIG_IGN ||
2343-
(act->sa.sa_handler == SIG_DFL &&
2344-
sig_kernel_ignore(sig))) {
2345-
/*
2346-
* This is a fairly rare case, so we only take the
2347-
* tasklist_lock once we're sure we'll need it.
2348-
* Now we must do this little unlock and relock
2349-
* dance to maintain the lock hierarchy.
2350-
*/
2343+
(act->sa.sa_handler == SIG_DFL && sig_kernel_ignore(sig))) {
23512344
struct task_struct *t = current;
2352-
spin_unlock_irq(&t->sighand->siglock);
2353-
read_lock(&tasklist_lock);
2354-
spin_lock_irq(&t->sighand->siglock);
2355-
*k = *act;
23562345
sigemptyset(&mask);
23572346
sigaddset(&mask, sig);
23582347
rm_from_queue_full(&mask, &t->signal->shared_pending);
@@ -2361,12 +2350,7 @@ do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
23612350
recalc_sigpending_tsk(t);
23622351
t = next_thread(t);
23632352
} while (t != current);
2364-
spin_unlock_irq(&current->sighand->siglock);
2365-
read_unlock(&tasklist_lock);
2366-
return 0;
23672353
}
2368-
2369-
*k = *act;
23702354
}
23712355

23722356
spin_unlock_irq(&current->sighand->siglock);

0 commit comments

Comments
 (0)