From: Oleg Nesterov <oleg@redhat.com>
To: Markus Metzger <markus.t.metzger@googlemail.com>
Cc: Ingo Molnar <mingo@elte.hu>,
"Metzger, Markus T" <markus.t.metzger@intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"hpa@zytor.com" <hpa@zytor.com>,
"roland@redhat.com" <roland@redhat.com>,
"eranian@googlemail.com" <eranian@googlemail.com>,
"Villacis, Juan" <juan.villacis@intel.com>,
"ak@linux.jf.intel.com" <ak@linux.jf.intel.com>
Subject: Re: [patch 3/14] x86, ptrace, bts: stop bts tracing early in do_exit
Date: Mon, 30 Mar 2009 03:22:04 +0200 [thread overview]
Message-ID: <20090330012204.GA2058@redhat.com> (raw)
In-Reply-To: <1238239912.6036.0.camel@raistlin>
On 03/28, Markus Metzger wrote:
>
> ds_release_bts(struct bts_tracer *tracer)
> {
> struct task_struct *task =
> tracer->ds.context->task;
>
> do {
> set_task_state(task, TASK_UNINTERRUPTIBLE);
Oh, this is not right,
> while (!wait_task_inactive(task, TASK_UNINTERRUPTIBLE));
and can't help to wait_task_inactive(). Again, unless this task
does a blocking call wait_task_inactive() can't force this task
to be deactivated. Even we set TASK_UNINTERRUPTIBLE.
> ds_suspend_bts(tracer);
> ds_free_bts(tracer);
>
> wake_up_process(task);
makes it TASK_RUNNING. This can't restores the proper ->state
if it was not running (say, TASK_STOPPED).
> }
>
> I guess it would not work in general, since task could already sleep
> on some event and be woken up after the do loop.
This too,
> I was thinking it might work for the exit race, since we don't sleep
> during exit,
We do. In the context of bts problems, we don't care if the task sleeps
after _free_tracee(). But this task can have tracees too, it can in turn
sleep in wait_task_inactive().
> Isn't this a general problem for ptrace?
>
> Ptrace uses a similar pattern in ptrace_check_attach().
> It stops the traced task, but that task might wake up immediately after
> that check. It might be scheduled in any time during a ptrace operation.
Yes. ptrace() can assume the tracee is TASK_TRACED, or it is dying/dead.
If you need to make sure it is still traced, you can re-check ->state
under ->siglock. Until you drop this lock, the tracee (if still traced)
can't escape from ptrace_stop/do_signal_stop, even if scheduled.
Oleg.
next prev parent reply other threads:[~2009-03-30 1:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-27 8:55 [patch 3/14] x86, ptrace, bts: stop bts tracing early in do_exit Markus Metzger
2009-03-27 14:34 ` Oleg Nesterov
2009-03-27 15:34 ` Metzger, Markus T
2009-03-27 17:24 ` Oleg Nesterov
2009-03-27 19:25 ` Markus Metzger
2009-03-28 11:31 ` Markus Metzger
2009-03-30 1:22 ` Oleg Nesterov [this message]
2009-03-30 6:55 ` Metzger, Markus T
2009-03-30 10:44 ` Andi Kleen
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=20090330012204.GA2058@redhat.com \
--to=oleg@redhat.com \
--cc=ak@linux.jf.intel.com \
--cc=eranian@googlemail.com \
--cc=hpa@zytor.com \
--cc=juan.villacis@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markus.t.metzger@googlemail.com \
--cc=markus.t.metzger@intel.com \
--cc=mingo@elte.hu \
--cc=roland@redhat.com \
--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 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.