public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@us.ibm.com>
To: mingo@elte.hu
Cc: linux-kernel@vger.kernel.org, oleg@tv-sign.ru,
	dipankar@in.ibm.com, suzannew@cs.pdx.edu, akpm@osdl.org
Subject: [PATCH] Simpler signal-exit concurrency handling
Date: Mon, 31 Oct 2005 22:04:06 -0800	[thread overview]
Message-ID: <20051101060405.GA4434@us.ibm.com> (raw)

Hello!

Some simplification in checking signal delivery against concurrent
exit.  Instead of using get_task_struct_rcu(), which increments
the task_struct reference count, check the reference count after
acquiring sighand lock.

Signed-off-by: <paulmck@us.ibm.com>

---

 signal.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff -urpNa linux-2.6.14-rc5-rt5/kernel/signal.c linux-2.6.14-rc5-rt5-ckhand/kernel/signal.c
--- linux-2.6.14-rc5-rt5/kernel/signal.c	2005-10-24 05:59:08.000000000 -0700
+++ linux-2.6.14-rc5-rt5-ckhand/kernel/signal.c	2005-10-31 15:46:14.000000000 -0800
@@ -1150,19 +1150,19 @@ int group_send_sig_info(int sig, struct 
 
 retry:
 	ret = check_kill_permission(sig, info, p);
-	if (!ret && sig && (sp = p->sighand)) {
-		if (!get_task_struct_rcu(p)) {
-			return -ESRCH;
-		}
+	if (!ret && sig && (sp = rcu_dereference(p->sighand))) {
 		spin_lock_irqsave(&sp->siglock, flags);
 		if (p->sighand != sp) {
 			spin_unlock_irqrestore(&sp->siglock, flags);
-			put_task_struct(p);
 			goto retry;
 		}
+		if ((atomic_read(&sp->count) == 0) ||
+		    (atomic_read(&p->usage) == 0)) {
+			spin_unlock_irqrestore(&sp->siglock, flags);
+			return -ESRCH;
+		}
 		ret = __group_send_sig_info(sig, info, p);
 		spin_unlock_irqrestore(&sp->siglock, flags);
-		put_task_struct(p);
 	}
 
 	return ret;

                 reply	other threads:[~2005-11-01  6:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051101060405.GA4434@us.ibm.com \
    --to=paulmck@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=dipankar@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=oleg@tv-sign.ru \
    --cc=suzannew@cs.pdx.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox