public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: "Metzger, Markus T" <markus.t.metzger@intel.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"mingo@elte.hu" <mingo@elte.hu>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"markus.t.metzger@gmail.com" <markus.t.metzger@gmail.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: Fri, 27 Mar 2009 18:24:13 +0100	[thread overview]
Message-ID: <20090327172413.GC25762@redhat.com> (raw)
In-Reply-To: <928CFBE8E7CB0040959E56B4EA41A77E9266B6D4@irsmsx504.ger.corp.intel.com>

On 03/27, Metzger, Markus T wrote:
>
> >-----Original Message-----
> >From: Oleg Nesterov [mailto:oleg@redhat.com]
> >Sent: Friday, March 27, 2009 3:35 PM
>
> >> +static void ptrace_bts_exit(void)
> >> +{
> >> +	if (unlikely(!list_empty(&current->ptraced)))
> >> +		ptrace_bts_exit_tracer();
> >> +
> >> +	if (unlikely(current->bts))
> >> +		ptrace_bts_exit_tracee();
> >> +}
> >
> >Could you explain why do we need ptrace_bts_exit_tracee() ?
> >
> >If current is traced, the tracer should do ptrace_bts_release()
> >eventually, no?
>
> If current is traced and exits, it may be reaped by another thread that is not
> the tracer (that's actually your example you made in an earlier thread to
> describe the race between a normal detach and an exiting tracee).
>
> The ptrace_unlink() call to detach the tracer is executed with irq's disabled.
> I need irq's enabled (see the other discussion, to wait for the traced task).

OK,

> Therefore, I have the tracee disable bts tracing itself when it exits.
>
>
> >And if we really need to do ptrace_bts_exit_tracee(), then
> >"if (unlikely(current->bts))" check is racy. The tracer
> >can do PTRACE_BTS_CONFIG right after the check.
>
> The ptrace system call to do this would require the tracee to be stopped.

Yes, but this doesn't matter.

The tracer starts ptrace(PTRACE_BTS_CONFIG) and stops the tracee.
But when the tracer calls ptrace_bts_config() the tracee can be already
killed, and it can exit and bypass ptrace_bts_exit_tracee().

Oleg.


  reply	other threads:[~2009-03-27 17:28 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 [this message]
2009-03-27 19:25       ` Markus Metzger
2009-03-28 11:31       ` Markus Metzger
2009-03-30  1:22         ` Oleg Nesterov
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=20090327172413.GC25762@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@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox