+ consolidate-checking-for-ignored-legacy-signals.patch added to -mm tree
[email protected]
tree noticeThe patch titled
signals: consolidate checking for ignored/legacy signals
has been added to the -mm tree. Its filename is
consolidate-checking-for-ignored-legacy-signals.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this
The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/
------------------------------------------------------
Subject: signals: consolidate checking for ignored/legacy signals
From: Pavel Emelyanov <[email protected]>
Two callers for send_signal() - the specific_send_sig_info and the __group_send_sig_info - both check for sig to be ignored or already queued.
Move these checks into send_signal() and make it return 1 to indicate that the signal is dropped, but there's no error in this.
Besides, merge comments and spell-check them.
---
kernel/signal.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-)
kernel/signal.c renamed from kernel/signal.c~consolidate-checking-for-ignored-legacy-signals +15 -22
@@ -668,6 +668,14 @@ static int send_signal(int sig, struct sstruct sigqueue * q =NULL ;/* +* Short-circuit ignored signals and support queuing +* exactly one non-rt signal, so that we can get more +* detailed information about the cause of the signal. +*/ +if (sig_ignored (t, sig) ||legacy_queue (signals, sig)) +return 1 ; + +/* * Deliver the signal to listening signalfds. This must be called * with the sighand lock held. */
@@ -766,21 +774,13 @@ specific_send_sig_info(int sig, struct sBUG_ON (!irqs_disabled ());assert_spin_locked (&t->sighand->siglock); -/* Short-circuit ignored signals. */ -if (sig_ignored (t, sig)) - goto out; - -/* Support queueing exactly one non-rt signal, so that we -can get more detailed information about the cause of -the signal. */ -if (legacy_queue (&t->pending, sig)) - goto out; - ret =send_signal (sig, info, t, &t->pending); +if (ret <0 ) +return ret; +if (!ret && !sigismember (&t->blocked, sig))signal_wake_up (t, sig ==SIGKILL ); -out: -return ret; +return 0 ; }/*
@@ -930,24 +930,17 @@ __group_send_sig_info(int sig, struct siassert_spin_locked (&p->sighand->siglock);handle_stop_signal (sig, p); -/* Short-circuit ignored signals. */ -if (sig_ignored (p, sig)) -return ret; - -if (legacy_queue (&p->signal->shared_pending, sig)) -/* This is a non-RT signal and we already have one queued. */ -return 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, &p->signal->shared_pending); -if (unlikely (ret)) +if (unlikely (ret <0 ))return ret; -__group_complete_signal (sig, p); +if (!ret) +__group_complete_signal (sig, p);return 0 ; }
_
Patches currently in -mm which might be from [email protected] are
origin.patch revert-proc-fix-the-threaded-proc-self.patch use-find_task_by_vpid-in-audit-code.patch ia64-fix-ptrace-inside-a-namespace.patch mips-use-find_task_by_vpid-in-system-calls.patch usbatm-switch-to-kthread-api-stop-using-kill_proc.patch deprecate-find_task_by_pid-kgdb.patch remove-unused-variable-from-send_signal.patch turn-legacy_queue-macro-into-static-inline-function.patch consolidate-checking-for-ignored-legacy-signals.patch use-find_task_by_vpid-in-taskstats.patch deprecate-find_task_by_pid.patch
reiser4.patch
PATCH 1/1 consolidate-checking-for-ignored-legacy-signals-simplify
Every user of send_signal() must check ret twice. Change the meaning of the returned value, so that ret <= 0 means we can just return, and ret == 1 means the signal was queued. Saves a couple of if's and imho makes the code more logical.
Also, remove now unneeded "ret = 0" initializions.
kernel/signal.c +8 -9
@@ -673,7 +673,7 @@ static int send_signal(int sig, struct s* detailed information about the cause of the signal. */ if (sig_ignored (t, sig) ||legacy_queue (signals, sig)) -return 1 ; +return 0 ;/* * Deliver the signal to listening signalfds. This must be called
@@ -731,7 +731,7 @@ static int send_signal(int sig, struct s out_set:sigaddset (&signals->signal, sig); -return 0 ; +return 1 ; }int print_fatal_signals;
@@ -769,16 +769,16 @@ __setup("print-fatal-signals=", setup_prstatic int specific_send_sig_info (int sig,struct siginfo *info,struct task_struct *t) { -int ret =0 ; +int ret;BUG_ON (!irqs_disabled ());assert_spin_locked (&t->sighand->siglock); ret =send_signal (sig, info, t, &t->pending); -if (ret <0 ) +if (ret <=0 )return ret; -if (!ret && !sigismember (&t->blocked, sig)) +if (!sigismember (&t->blocked, sig))signal_wake_up (t, sig ==SIGKILL );return 0 ; }
@@ -946,7 +946,7 @@ __group_complete_signal(int sig, structint __group_send_sig_info (int sig,struct siginfo *info,struct task_struct *p) { -int ret =0 ; +int ret;assert_spin_locked (&p->sighand->siglock);handle_stop_signal (sig, p);
@@ -957,11 +957,10 @@ __group_send_sig_info(int sig, struct si* to avoid several races. */ ret =send_signal (sig, info, p, &p->signal->shared_pending); -if (unlikely (ret <0 )) +if (ret <=0 )return ret; -if (!ret) -__group_complete_signal (sig, p); +__group_complete_signal (sig, p);return 0 ; }