[PATCH 1/6] signal: introduce retarget_shared_pending()

From: Oleg Nesterov
Date: Mon Apr 11 2011 - 13:21:38 EST


No functional changes. Move the notyfy-other-threads code from exit_signals()
to the new helper, retarget_shared_pending().

Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx>
---

kernel/signal.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)

--- sigprocmask/kernel/signal.c~1_add_retarget_helper 2011-04-10 18:24:18.000000000 +0200
+++ sigprocmask/kernel/signal.c 2011-04-10 19:33:45.000000000 +0200
@@ -2017,10 +2017,25 @@ relock:
return signr;
}

+/*
+ * 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.
+ */
+static void retarget_shared_pending(struct task_struct *tsk)
+{
+ struct task_struct *t;
+
+ t = tsk;
+ while_each_thread(tsk, t) {
+ if (!signal_pending(t) && !(t->flags & PF_EXITING))
+ recalc_sigpending_and_wake(t);
+ }
+}
+
void exit_signals(struct task_struct *tsk)
{
int group_stop = 0;
- struct task_struct *t;

if (thread_group_empty(tsk) || signal_group_exit(tsk->signal)) {
tsk->flags |= PF_EXITING;
@@ -2036,14 +2051,7 @@ void exit_signals(struct task_struct *ts
if (!signal_pending(tsk))
goto out;

- /*
- * It could be that __group_complete_signal() choose us to
- * notify about group-wide signal. Another thread should be
- * woken now to take the signal since we will not.
- */
- for (t = tsk; (t = next_thread(t)) != tsk; )
- if (!signal_pending(t) && !(t->flags & PF_EXITING))
- recalc_sigpending_and_wake(t);
+ retarget_shared_pending(tsk);

if (unlikely(tsk->signal->group_stop_count) &&
!--tsk->signal->group_stop_count) {

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/