All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Love <rml@tech9.net>
To: linux-kernel@vger.kernel.org
Cc: george@mvista.com
Subject: [PATCH][RFC] preemptive kernel: ptrace fix
Date: 22 Sep 2001 23:52:12 -0400	[thread overview]
Message-ID: <1001217135.1390.19.camel@phantasy> (raw)

I noticed (actually, I had a thought ptrace wouldnt work under
preemption) that strace sometimes locks under the preemptible kernel,
although is killable by CTRL-C.

The following is from arch/i386/kernel/ptrace.c :: syscall_trace:

1	current->state = TASK_STOPPED;
2	notify_parent(current, SIGCHLD);
3	schedule();

What if, between line one and two, preemption occurs?  Now the task
state is TASK_STOPPED, and thus will never be rescheduled.  I presume
this is the problem.  The attached patch fixes this.

Running multiple straces in a tight loop for over an hour shows me the
problem is fixed.  Its obvious the above is a problem anyhow.

However, doing an `strace strace whatever' (ie, stracing strace), it
still enters a stopped state about 20% of the time (before the patch, it
locked almost 100%).  I can't figure out why.  Comments?

Yes, stracing strace is contorted and I don't care, but something else
is obviously wrong -- you can do so on a non-preemption machine.


diff -urN linux-2.4.9-ac14-preempt/arch/i386/kernel/ptrace.c linux/arch/i386/kernel/ptrace.c > patch-rml-2.4.9-ac14-preempt-strace-fix-1
--- linux-2.4.9-ac14-preempt/arch/i386/kernel/ptrace.c	Sat Sep 22 23:20:41 2001+++ linux/arch/i386/kernel/ptrace.c	Sat Sep 22 23:42:11 2001
@@ -455,9 +455,11 @@
 	   between a syscall stop and SIGTRAP delivery */
 	current->exit_code = SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
 					? 0x80 : 0);
+	ctx_sw_off();
 	current->state = TASK_STOPPED;
 	notify_parent(current, SIGCHLD);
 	schedule();
+	ctx_sw_on();
 	/*
 	 * this isn't the same as continuing with a signal, but it will do
 	 * for normal use.  strace only continues with a signal if the


-- 
Robert M. Love
rml at ufl.edu
rml at tech9.net


             reply	other threads:[~2001-09-23  3:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-23  3:52 Robert Love [this message]
2001-09-23  5:18 ` [PATCH][RFC] preemptive kernel: ptrace fix Robert Love

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=1001217135.1390.19.camel@phantasy \
    --to=rml@tech9.net \
    --cc=george@mvista.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.