fix ptrace slowness
authorMiklos Szeredi <mszeredi@suse.cz>
Mon, 23 Mar 2009 15:07:24 +0000 (16:07 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sat, 2 May 2009 17:24:58 +0000 (10:24 -0700)
commit953e45c45cf3daa1037fac03246e2fabc088ba0b
treed5de6e36e1e5951bb16fb72fe739041c0eaa0cd7
parent9460a617660c1d5f3d6fdf0f6163939a67ed7f9c
fix ptrace slowness

commit 53da1d9456fe7f87a920a78fdbdcf1225d197cb7 upstream.

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
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
kernel/signal.c