public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] coredump: optimize ->mm users traversal
@ 2006-04-06 22:06 Oleg Nesterov
  2006-04-08  3:51 ` Roland McGrath
  0 siblings, 1 reply; 2+ messages in thread
From: Oleg Nesterov @ 2006-04-06 22:06 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric W. Biederman, Ingo Molnar, Paul E. McKenney, Roland McGrath,
	linux-kernel

zap_threads() iterates over all threads to find those ones which
share current->mm. All threads in the thread group share the same
->mm, so we can skip entire thread group if it has another ->mm.

This patch shifts the killing of thread group into the newly added
zap_process() function. This looks as unnecessary complication, but
it is used in further patches.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- rc1/fs/exec.c~1_ZAPT	2006-04-03 16:21:25.000000000 +0400
+++ rc1/fs/exec.c	2006-04-06 15:10:28.000000000 +0400
@@ -1384,6 +1384,22 @@ static void format_corename(char *corena
 	*out_ptr = 0;
 }
 
+static void zap_process(struct task_struct *start, int *ptraced)
+{
+	struct task_struct *t;
+
+	t = start;
+	do {
+		if (t != current && t->mm) {
+			t->mm->core_waiters++;
+			force_sig_specific(SIGKILL, t);
+			if (unlikely(t->ptrace) &&
+			    unlikely(t->parent->mm == t->mm))
+				*ptraced = 1;
+		}
+	} while ((t = next_thread(t)) != start);
+}
+
 static void zap_threads (struct mm_struct *mm)
 {
 	struct task_struct *g, *p;
@@ -1401,16 +1417,16 @@ static void zap_threads (struct mm_struc
 	}
 
 	read_lock(&tasklist_lock);
-	do_each_thread(g,p)
-		if (mm == p->mm && p != tsk) {
-			force_sig_specific(SIGKILL, p);
-			mm->core_waiters++;
-			if (unlikely(p->ptrace) &&
-			    unlikely(p->parent->mm == mm))
-				traced = 1;
-		}
-	while_each_thread(g,p);
-
+	for_each_process(g) {
+		p = g;
+		do {
+			if (p->mm) {
+				if (p->mm == mm)
+					zap_process(p, &traced);
+				break;
+			}
+		} while ((p = next_thread(p)) != g);
+	}
 	read_unlock(&tasklist_lock);
 
 	if (unlikely(traced)) {


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

* Re: [PATCH 1/4] coredump: optimize ->mm users traversal
  2006-04-06 22:06 [PATCH 1/4] coredump: optimize ->mm users traversal Oleg Nesterov
@ 2006-04-08  3:51 ` Roland McGrath
  0 siblings, 0 replies; 2+ messages in thread
From: Roland McGrath @ 2006-04-08  3:51 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Andrew Morton, Eric W. Biederman, Ingo Molnar, Paul E. McKenney,
	linux-kernel

This patch looks good to me.

Signed-off-by: Roland McGrath <roland@redhat.com>


Thanks,
Roland

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

end of thread, other threads:[~2006-04-08  3:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-06 22:06 [PATCH 1/4] coredump: optimize ->mm users traversal Oleg Nesterov
2006-04-08  3:51 ` Roland McGrath

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