LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 4/6] signals: fold complete_signal() into send_signal/do_send_sigqueue
@ 2008-03-08 15:10 Oleg Nesterov
  2008-03-11  2:06 ` Roland McGrath
  0 siblings, 1 reply; 3+ messages in thread
From: Oleg Nesterov @ 2008-03-08 15:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Ingo Molnar, Pavel Emelyanov, Roland McGrath, linux-kernel

From: Pavel Emelyanov <xemul@openvz.org>

Factor out complete_signal() callsites. This change completely unifies the
helpers sending the specific/group signals.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- 25/kernel/signal.c~4_CS_FACTOR	2008-03-08 16:37:23.000000000 +0300
+++ 25/kernel/signal.c	2008-03-08 16:54:57.000000000 +0300
@@ -826,7 +826,8 @@ static int send_signal(int sig, struct s
 
 out_set:
 	sigaddset(&pending->signal, sig);
-	return 1;
+	complete_signal(sig, t, group);
+	return 0;
 }
 
 int print_fatal_signals;
@@ -861,17 +862,16 @@ static int __init setup_print_fatal_sign
 
 __setup("print-fatal-signals=", setup_print_fatal_signals);
 
+int
+__group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
+{
+	return send_signal(sig, info, p, 1);
+}
+
 static int
 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
 {
-	int ret;
-
-	ret = send_signal(sig, info, t, 0);
-	if (ret <= 0)
-		return ret;
-
-	complete_signal(sig, t, 0);
-	return 0;
+	return send_signal(sig, info, t, 0);
 }
 
 /*
@@ -914,24 +914,6 @@ force_sig_specific(int sig, struct task_
 	force_sig_info(sig, SEND_SIG_FORCED, t);
 }
 
-int
-__group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
-{
-	int ret;
-
-	/*
-	 * Put this signal on the shared-pending queue, or fail with EAGAIN.
-	 * We always use the shared queue for process-wide signals,
-	 * to avoid several races.
-	 */
-	ret = send_signal(sig, info, p, 1);
-	if (ret <= 0)
-		return ret;
-
-	complete_signal(sig, p, 1);
-	return 0;
-}
-
 /*
  * Nuke all other threads in the group.
  */
@@ -1263,6 +1245,7 @@ static int do_send_sigqueue(int sig, str
 {
 	struct sigpending *pending;
 
+	BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));
 	handle_stop_signal(sig, t);
 
 	if (unlikely(!list_empty(&q->list))) {
@@ -1283,6 +1266,7 @@ static int do_send_sigqueue(int sig, str
 	pending = group ? &t->signal->shared_pending : &t->pending;
 	list_add_tail(&q->list, &pending->list);
 	sigaddset(&pending->signal, sig);
+	complete_signal(sig, t, group);
 
 	return 0;
 }
@@ -1292,8 +1276,6 @@ int send_sigqueue(int sig, struct sigque
 	unsigned long flags;
 	int ret = -1;
 
-	BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));
-
 	/*
 	 * The rcu based delayed sighand destroy makes it possible to
 	 * run this without tasklist lock held. The task struct itself
@@ -1307,8 +1289,6 @@ int send_sigqueue(int sig, struct sigque
 
 	ret = do_send_sigqueue(sig, q, p, 0);
 
-	complete_signal(sig, p, 0);
-
 	unlock_task_sighand(p, &flags);
 out_err:
 	return ret;
@@ -1320,15 +1300,11 @@ send_group_sigqueue(int sig, struct sigq
 	unsigned long flags;
 	int ret;
 
-	BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));
-
 	/* Since it_lock is held, p->sighand cannot be NULL. */
 	spin_lock_irqsave(&p->sighand->siglock, flags);
 
 	ret = do_send_sigqueue(sig, q, p, 1);
 
-	complete_signal(sig, p, 1);
-
 	spin_unlock_irqrestore(&p->sighand->siglock, flags);
 
 	return ret;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 4/6] signals: fold complete_signal() into send_signal/do_send_sigqueue
  2008-03-08 15:10 [PATCH 4/6] signals: fold complete_signal() into send_signal/do_send_sigqueue Oleg Nesterov
@ 2008-03-11  2:06 ` Roland McGrath
  2008-03-11 17:56   ` Oleg Nesterov
  0 siblings, 1 reply; 3+ messages in thread
From: Roland McGrath @ 2008-03-11  2:06 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Andrew Morton, Ingo Molnar, Pavel Emelyanov, linux-kernel

This and 1-3/6 look OK to me.  But, since this one appears to be changing
the sense of the return value from send_signal, I think you should at least
take the opportunity to add a comment to send_signal saying clearly what
its return conventions are.


Thanks,
Roland

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 4/6] signals: fold complete_signal() into send_signal/do_send_sigqueue
  2008-03-11  2:06 ` Roland McGrath
@ 2008-03-11 17:56   ` Oleg Nesterov
  0 siblings, 0 replies; 3+ messages in thread
From: Oleg Nesterov @ 2008-03-11 17:56 UTC (permalink / raw)
  To: Roland McGrath; +Cc: Andrew Morton, Ingo Molnar, Pavel Emelyanov, linux-kernel

On 03/10, Roland McGrath wrote:
>
> This and 1-3/6 look OK to me.  But, since this one appears to be changing
> the sense of the return value from send_signal, I think you should at least
> take the opportunity to add a comment to send_signal saying clearly what
> its return conventions are.

Actually, this patch restores the meaning of the return value, it was temporary
changed by the previous cleanups in -mm tree.

With this patch send_signal() return either 0 or error, as it historically was.

Oleg.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-03-11 17:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-08 15:10 [PATCH 4/6] signals: fold complete_signal() into send_signal/do_send_sigqueue Oleg Nesterov
2008-03-11  2:06 ` Roland McGrath
2008-03-11 17:56   ` Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).