From: Oleg Nesterov <oleg@redhat.com>
To: Tejun Heo <tj@kernel.org>
Cc: jan.kratochvil@redhat.com, vda.linux@googlemail.com,
linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
akpm@linux-foundation.org, indan@nul.nu, bdonlan@gmail.com
Subject: Re: [PATCH 4/9] ptrace: relocate set_current_state(TASK_TRACED) in ptrace_stop()
Date: Mon, 16 May 2011 17:51:58 +0200 [thread overview]
Message-ID: <20110516155158.GA15918@redhat.com> (raw)
In-Reply-To: <20110516131608.GX23665@htj.dyndns.org>
On 05/16, Tejun Heo wrote:
>
> Hey, Oleg.
>
> On Mon, May 16, 2011 at 01:57:11PM +0200, Oleg Nesterov wrote:
> > > and helps future updates to group stop participation.
> >
> > OK, so I assume we need this change.
>
> We don't necessarily need it but it makes things prettier later.
>
> > But the comment looks a bit confusing to me. This is fine, I almost never
> > read them ;) Just I'd like to ensure I din't miss something.
>
> Oleg, IIRC, those comments were taken from your email pointing out
> that set_current_state() needs to happen before clearing of TRAPPING,
> so, if you're confused, I'm confused too. :-)
So, we are both confused. Great!
> > > + * We're committing to trapping. TRACED should be visible before
> > > + * TRAPPING is cleared
> >
> > This looks as if you explain the barrier in set_current_state(). And,
> > btw, why can't we use __set_current_state() here ?
> >
> > And. not only TRACED, at least ->exit_code should be visible as well.
>
> The racy part was task_is_stopped_or_traced() in task_stopped_code()
> and the value of exit_code doesn't matter at that point.
Why exit_code doesn't matter? task_stopped_code() needs
task_is_stopped_or_traced() && exit_code != 0. Both changes should be
visible.
> So, we need
> at least smp_wmb() between __set_current_state() and clearing
> TRAPPING.
I don't think so. Please see below,
> > IOW. It is not that TRACED should be visible before jobctl &= ~JOBCTL_TRAPPING,
> > we should correctly update the tracee before __wake_up_sync_key(), and I assume
> > this is what the comment says.
> >
> > Correct?
>
> All we need to update on the tracee is tracee->state and
> ~JOBCTL_TRAPPING and __wake_up_sync_key() can be considered single
> operation.
Yes! IOW, it safe to reorder the memory operations which change ->state,
->exit_code, and ->jobctl. This only important thing is that we should not
wake up the tracer before we change them.
And if I remember correctly this was the problem, the early patches did
something like
task_clear_jobctl_trapping();
set_current_state(TASK_TRACED);
Oleg.
next prev parent reply other threads:[~2011-05-16 15:53 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-13 15:46 [PATCHSET ptrace] ptrace: prepare for PTRACE_SEIZE/INTERRUPT Tejun Heo
2011-05-13 15:46 ` [PATCH 1/9] job control: reorganize wait_task_stopped() Tejun Heo
2011-05-16 11:56 ` Oleg Nesterov
2011-05-13 15:46 ` [PATCH 2/9] job control: rename signal->group_stop and flags to jobctl and rearrange flags Tejun Heo
2011-05-13 15:46 ` [PATCH 3/9] ptrace: ptrace_check_attach(): rename @kill to @ignore_state and add comments Tejun Heo
2011-05-13 15:46 ` [PATCH 4/9] ptrace: relocate set_current_state(TASK_TRACED) in ptrace_stop() Tejun Heo
2011-05-16 11:57 ` Oleg Nesterov
2011-05-16 13:16 ` Tejun Heo
2011-05-16 15:51 ` Oleg Nesterov [this message]
2011-05-16 15:59 ` Tejun Heo
2011-05-16 16:34 ` Oleg Nesterov
2011-05-13 15:46 ` [PATCH 5/9] job control: introduce JOBCTL_PENDING_MASK and task_clear_jobctl_pending() Tejun Heo
2011-05-13 15:46 ` [PATCH 6/9] job control: make task_clear_jobctl_pending() clear TRAPPING automatically Tejun Heo
2011-05-16 12:25 ` Oleg Nesterov
2011-05-16 13:24 ` Tejun Heo
2011-05-16 16:00 ` Oleg Nesterov
2011-05-16 16:09 ` Tejun Heo
2011-05-13 15:46 ` [PATCH 7/9] ptrace: use bit_waitqueue for TRAPPING instead of wait_chldexit Tejun Heo
2011-05-13 15:46 ` [PATCH 8/9] ptrace: move JOBCTL_TRAPPING wait to wait(2) and ptrace_check_attach() Tejun Heo
2011-05-14 14:22 ` [PATCH UPDATED " Tejun Heo
2011-05-16 12:11 ` Oleg Nesterov
2011-05-16 13:36 ` Tejun Heo
2011-05-16 16:04 ` Oleg Nesterov
2011-05-13 15:46 ` [PATCH 9/9] ptrace: make TRAPPING wait interruptible Tejun Heo
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=20110516155158.GA15918@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=bdonlan@gmail.com \
--cc=indan@nul.nu \
--cc=jan.kratochvil@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=vda.linux@googlemail.com \
/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;
as well as URLs for NNTP newsgroup(s).