public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
	mszeredi@suse.cz, miklos@szeredi.hu, stable@kernel.org,
	tglx@linutronix.de, mingo@elte.hu
Subject: [tip:sched/urgent] sched, ptrace: fix UML and ptrace slowness
Date: Mon, 23 Mar 2009 16:39:34 GMT	[thread overview]
Message-ID: <tip-84eef8ca758fa4a68c29f7d752376f6ca6872383@git.kernel.org> (raw)
In-Reply-To: <E1LllkK-0000zF-1h@pomaz-ex.szeredi.hu>

Commit-ID:  84eef8ca758fa4a68c29f7d752376f6ca6872383
Gitweb:     http://git.kernel.org/tip/84eef8ca758fa4a68c29f7d752376f6ca6872383
Author:     Miklos Szeredi <miklos@szeredi.hu>
AuthorDate: Mon, 23 Mar 2009 16:07:24 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 23 Mar 2009 17:37:38 +0100

sched, ptrace: fix UML and ptrace slowness

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: oleg@redhat.com
Cc: peterz@infradead.org
Cc: roland@redhat.com
Cc: efault@gmx.de
Cc: rjw@sisk.pl
Cc: jdike@addtoit.com
Cc: user-mode-linux-devel@lists.sourceforge.net
Cc: torvalds@linux-foundation.org
Cc: akpm@linux-foundation.org
Cc: <stable@kernel.org>
LKML-Reference: <E1LllkK-0000zF-1h@pomaz-ex.szeredi.hu>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 kernel/signal.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 2a74fe8..1c88144 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1575,7 +1575,15 @@ static void ptrace_stop(int exit_code, int clear_code, siginfo_t *info)
 	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 {
 		/*

  parent reply	other threads:[~2009-03-23 16:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Miklos Szeredi [this message]
2009-03-23 17:14   ` [tip:sched/urgent] sched, ptrace: fix UML and " Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-84eef8ca758fa4a68c29f7d752376f6ca6872383@git.kernel.org \
    --to=miklos@szeredi.hu \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=mszeredi@suse.cz \
    --cc=stable@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox