public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kill_something_info: don't take tasklist_lock for pid==-1 case
@ 2008-03-25  4:27 Atsushi Tsuji
  2008-03-25 13:56 ` Oleg Nesterov
  0 siblings, 1 reply; 10+ messages in thread
From: Atsushi Tsuji @ 2008-03-25  4:27 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel

Hi Oleg,

Thanks for some patches about tasklist_lock. The avoidance of
tasklist_lock is very important for us.  And now, I found another
avoidable tasklist_lock, and made the patch. Could you please have a
look?

This patch avoid taking tasklist_lock in kill_something_info() when
the pid is -1. It can convert to rcu_read_lock() for this case because
group_send_sig_info() doesn't need tasklist_lock.

This patch is for 2.6.25-rc5-mm1.

Signed-off-by: Atsushi Tsuji <a-tsuji@bk.jp.nec.com>
---
diff --git a/kernel/signal.c b/kernel/signal.c
index 3edbfd4..a888c58 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1089,14 +1089,16 @@ static int kill_something_info(int sig, struct siginfo 
*info, int pid)
  		return ret;
  	}

-	read_lock(&tasklist_lock);
  	if (pid != -1) {
+		read_lock(&tasklist_lock);
  		ret = __kill_pgrp_info(sig, info,
  				pid ? find_vpid(-pid) : task_pgrp(current));
+		read_unlock(&tasklist_lock);
  	} else {
  		int retval = 0, count = 0;
  		struct task_struct * p;

+		rcu_read_lock();
  		for_each_process(p) {
  			if (p->pid > 1 && !same_thread_group(p, current)) {
  				int err = group_send_sig_info(sig, info, p);
@@ -1106,8 +1108,8 @@ static int kill_something_info(int sig, struct siginfo 
*info, int pid)
  			}
  		}
  		ret = count ? retval : -ESRCH;
+		rcu_read_unlock();
  	}
-	read_unlock(&tasklist_lock);

  	return ret;
  }

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

end of thread, other threads:[~2008-06-01 16:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-25  4:27 [PATCH] kill_something_info: don't take tasklist_lock for pid==-1 case Atsushi Tsuji
2008-03-25 13:56 ` Oleg Nesterov
2008-05-21  1:48   ` Atsushi Tsuji
2008-05-21  2:53     ` Eric W. Biederman
2008-05-21  3:47   ` Eric W. Biederman
2008-05-26  7:03     ` Atsushi TSUJI
2008-05-28 15:03       ` Eric W. Biederman
2008-05-31 16:55     ` Oleg Nesterov
2008-05-31 23:55       ` Eric W. Biederman
2008-06-01 16:29         ` Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox