diff options
author | Oleg Nesterov <oleg@redhat.com> | 2011-04-27 19:50:21 +0200 |
---|---|---|
committer | Oleg Nesterov <oleg@redhat.com> | 2011-04-28 13:01:35 +0200 |
commit | fec9993db093acfc3999a364e31f8adae41fcb28 (patch) | |
tree | 6398e6f0d811128cb46c04ec631f3dcc6075728a /kernel/signal.c | |
parent | f646e227b88a164a841d6b6dd969d8a45272dd83 (diff) | |
download | op-kernel-dev-fec9993db093acfc3999a364e31f8adae41fcb28.zip op-kernel-dev-fec9993db093acfc3999a364e31f8adae41fcb28.tar.gz |
signal: retarget_shared_pending: optimize while_each_thread() loop
retarget_shared_pending() blindly does recalc_sigpending_and_wake() for
every sub-thread, this is suboptimal. We can check t->blocked and stop
looping once every bit in shared_pending has the new target.
Note: we do not take task_is_stopped_or_traced(t) into account, we are
not trying to speed up the signal delivery or to avoid the unnecessary
(but harmless) signal_wake_up(0) in this unlikely case.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Matt Fleming <matt.fleming@linux.intel.com>
Acked-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/signal.c')
-rw-r--r-- | kernel/signal.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/kernel/signal.c b/kernel/signal.c index 06214b5..707736e 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2200,8 +2200,8 @@ relock: /* * It could be that complete_signal() picked us to notify about the - * group-wide signal. Another thread should be notified now to take - * the signal since we will not. + * group-wide signal. Other threads should be notified now to take + * the shared signals in @which since we will not. */ static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which) { @@ -2214,8 +2214,19 @@ static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which) t = tsk; while_each_thread(tsk, t) { - if (!signal_pending(t) && !(t->flags & PF_EXITING)) - recalc_sigpending_and_wake(t); + if (t->flags & PF_EXITING) + continue; + + if (!has_pending_signals(&retarget, &t->blocked)) + continue; + /* Remove the signals this thread can handle. */ + sigandsets(&retarget, &retarget, &t->blocked); + + if (!signal_pending(t)) + signal_wake_up(t, 0); + + if (sigisemptyset(&retarget)) + break; } } |