lkml.org 
[lkml]   [2005]   [Nov]   [1]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
DateMon, 31 Oct 2005 22:04:06 -0800
From"Paul E. McKenney" <>
Subject[PATCH] Simpler signal-exit concurrency handling
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;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-11-01 07:06    [from the cache]
©2003-2008