public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] fix ptrace slowness
@ 2009-03-23 15:07 Miklos Szeredi
  2009-03-23 15:19 ` Ingo Molnar
  2009-03-23 16:39 ` [tip:sched/urgent] sched, ptrace: fix UML and " Miklos Szeredi
  0 siblings, 2 replies; 9+ messages in thread
From: Miklos Szeredi @ 2009-03-23 15:07 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, oleg, peterz, roland, efault, rjw, jdike,
	user-mode-linux-devel, torvalds, akpm, stable

This one incorporates comments from Oleg and Ingo.  Please apply to
2.6.29 and 2.6.2[78]-stable trees.

Thanks,
Miklos
----

From: Miklos Szeredi <mszeredi@suse.cz>

This patch fixes bug #12208:

  Bug-Entry       : http://bugzilla.kernel.org/show_bug.cgi?id=12208
  Subject         : uml is very slow on 2.6.28 host

This turned out to be not a scheduler regression, but an already
existing problem in ptrace being triggered by subtle scheduler
changes.

The problem is this:

 - task A is ptracing task B
 - task B stops on a trace event
 - task A is woken up and preempts task B
 - task A calls ptrace on task B, which does ptrace_check_attach()
 - this calls wait_task_inactive(), which sees that task B is still on the runq
 - task A goes to sleep for a jiffy
 - ...

Since UML does lots of the above sequences, those jiffies quickly add
up to make it slow as hell.

This patch solves this by not rescheduling in read_unlock() after
ptrace_stop() has woken up the tracer.

Thanks to Oleg Nesterov and Ingo Molnar for the feedback.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
CC: stable@kernel.org
---
 kernel/signal.c |    8 ++++++++
 1 file changed, 8 insertions(+)

Index: linux.git/kernel/signal.c
===================================================================
--- linux.git.orig/kernel/signal.c	2009-03-20 09:41:04.000000000 +0100
+++ linux.git/kernel/signal.c	2009-03-23 15:40:57.000000000 +0100
@@ -1575,7 +1575,15 @@ static void ptrace_stop(int exit_code, i
 	read_lock(&tasklist_lock);
 	if (may_ptrace_stop()) {
 		do_notify_parent_cldstop(current, CLD_TRAPPED);
+		/*
+		 * Don't want to allow preemption here, because
+		 * sys_ptrace() needs this task to be inactive.
+		 *
+		 * XXX: implement read_unlock_no_resched().
+		 */
+		preempt_disable();
 		read_unlock(&tasklist_lock);
+		preempt_enable_no_resched();
 		schedule();
 	} else {
 		/*

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

end of thread, other threads:[~2009-03-23 19:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-23 15:07 [patch] fix ptrace slowness Miklos Szeredi
2009-03-23 15:19 ` Ingo Molnar
2009-03-23 15:53   ` Oleg Nesterov
2009-03-23 16:13     ` Ingo Molnar
2009-03-23 16:17   ` Miklos Szeredi
2009-03-23 16:38     ` Ingo Molnar
2009-03-23 19:08     ` Michael Riepe
2009-03-23 16:39 ` [tip:sched/urgent] sched, ptrace: fix UML and " Miklos Szeredi
2009-03-23 17:14   ` Ingo Molnar

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