Re: [PATCH 4/9] ptrace: relocate set_current_state(TASK_TRACED) inptrace_stop()
From: Oleg Nesterov
Date: Mon May 16 2011 - 07:59:03 EST
On 05/13, Tejun Heo wrote:
>
> In ptrace_stop(), after arch hook is done, the task state and jobctl
> bits are updated while holding siglock. The ordering requirement
> there is that TASK_TRACED is set before JOBCTL_TRAPPING is cleared to
> prevent ptracer waiting on TRAPPING doesn't end up waking up TRACED is
> actually set and sees TASK_RUNNING in wait(2).
>
> Move set_current_state(TASK_TRACED) to the top of the block and
> reorganize comments. This makes the ordering more obvious
> (TASK_TRACED before other updates)
I am ab bit confused... please see below.
> and helps future updates to group
> stop participation.
OK, so I assume we need this change.
> This patch doesn't cause any functional change.
Agreed, so the patch looks fine.
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.
> @@ -1733,6 +1733,18 @@ static void ptrace_stop(int exit_code, int why, int clear_code, siginfo_t *info)
> }
>
> /*
> + * 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.
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?
Oleg.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/