lkml.org 
[lkml]   [2011]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/9] ptrace: relocate set_current_state(TASK_TRACED) in ptrace_stop()
On 05/16, Tejun Heo wrote:
>
> Hello,
>
> On Mon, May 16, 2011 at 05:51:58PM +0200, Oleg Nesterov wrote:
> > > 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.
>
> Because the actual exit_code is checked only after grabbing siglock.

OK, this is true after the next 8/9 patch.

> As long as task_is_stopped_or_traced() is true, ptracer will grab
> siglock

Hmm. No? task_is_stopped_or_traced() is also checked under ->siglock?

Confused.

> > > 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);
>
> Right, try_to_wake_up() already contains smp_wmb().

Well, I do not think try_to_wake_up()->smp_wmb() is needed in this case,
wait_queue_head_t->lock helps. This wmb() is needed to ensure we do not
change (or even read) task->state before the preceding LOAD's completes.
It is not needed for wait_event-like code.

> We'll be fine
> with __set_current_state(). Can we do it in a later patch?

Sure, this is minor and needs a separate patch anyway.

Oleg.



\
 
 \ /
  Last update: 2011-05-16 18:39    [W:0.041 / U:4.852 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site