aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/signal.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2011-04-27 13:50:21 -0400
committerOleg Nesterov <oleg@redhat.com>2011-04-28 07:01:35 -0400
commitfec9993db093acfc3999a364e31f8adae41fcb28 (patch)
tree6398e6f0d811128cb46c04ec631f3dcc6075728a /kernel/signal.c
parentf646e227b88a164a841d6b6dd969d8a45272dd83 (diff)
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.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/kernel/signal.c b/kernel/signal.c
index 06214b55dc5e..707736e64e0e 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2200,8 +2200,8 @@ relock:
2200 2200
2201/* 2201/*
2202 * It could be that complete_signal() picked us to notify about the 2202 * It could be that complete_signal() picked us to notify about the
2203 * group-wide signal. Another thread should be notified now to take 2203 * group-wide signal. Other threads should be notified now to take
2204 * the signal since we will not. 2204 * the shared signals in @which since we will not.
2205 */ 2205 */
2206static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which) 2206static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which)
2207{ 2207{
@@ -2214,8 +2214,19 @@ static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which)
2214 2214
2215 t = tsk; 2215 t = tsk;
2216 while_each_thread(tsk, t) { 2216 while_each_thread(tsk, t) {
2217 if (!signal_pending(t) && !(t->flags & PF_EXITING)) 2217 if (t->flags & PF_EXITING)
2218 recalc_sigpending_and_wake(t); 2218 continue;
2219
2220 if (!has_pending_signals(&retarget, &t->blocked))
2221 continue;
2222 /* Remove the signals this thread can handle. */
2223 sigandsets(&retarget, &retarget, &t->blocked);
2224
2225 if (!signal_pending(t))
2226 signal_wake_up(t, 0);
2227
2228 if (sigisemptyset(&retarget))
2229 break;
2219 } 2230 }
2220} 2231}
2221 2232