From: Tejun Heo <tj@kernel.org>
To: Oleg Nesterov <oleg@redhat.com>
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 6/9] job control: make task_clear_jobctl_pending() clear TRAPPING automatically
Date: Mon, 16 May 2011 15:24:00 +0200 [thread overview]
Message-ID: <20110516132400.GY23665@htj.dyndns.org> (raw)
In-Reply-To: <20110516122535.GD4898@redhat.com>
Hello,
On Mon, May 16, 2011 at 02:25:35PM +0200, Oleg Nesterov wrote:
> On 05/13, Tejun Heo wrote:
> >
> > @@ -264,6 +267,9 @@ void task_clear_jobctl_pending(struct task_struct *task, unsigned int mask)
> > mask |= JOBCTL_STOP_CONSUME | JOBCTL_STOP_DEQUEUED;
> >
> > task->jobctl &= ~mask;
> > +
> > + if (!(task->jobctl & JOBCTL_PENDING_MASK))
> > + task_clear_jobctl_trapping(task);
> > }
>
> So, SIGCONT clears JOBCTL_TRAPPING and wakes up the tracer.
If JOBCTL_TRAPPING is set && JOBCTL_STOP_PENDING was the only pending
condition.
> I can't really understand this without seeing the next changes, but
> it seems this makes some things worse, although I am not sure.
It's a safety mechanism. We shouldn't have TRAPPING set when no
stop/trap is pending and the above establishes that invariant and will
also be used to simplify exception cases where all pending conditions
are cleared (tracee being killed). It's conceptually much easier to
grasp that way - you clear all pending conditions when the task dies
and the mechanism to wait for trap transition is cleared together.
> For example. PTRACE_SEIZE should guarantee the tracee will trap and
> report. However, if the tracee is stopped during attach, we can race
> with SIGCONT. The previous version had the similar problem afaics, but
> it was easy (I think) to fix. Now that SIGCONT clears JOBCTL_TRAPPING
> we need more complications.
This problem doesn't exist anymore. SEIZE directly schedules
JOBCTL_TRAP_STOP instead of using JOBCTL_STOP_PENDING, so it actually
works exactly as it should.
1. If tracee was stopped and tracer attaches, tracee should re-trap
and tracer should wait for TRAPPING.
2. If tracee was not stopped and tracer attaches, tracee traps to
STOP.
3. If tracee was stopped and tracer attaches but SIGCONT is received
before TRAPPING is done, TRAPPING is cleared and tracer and tracee
are in the same conditions as #2, which is exactly how they should
be.
Thanks.
--
tejun
next prev parent reply other threads:[~2011-05-16 13:24 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
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 [this message]
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=20110516132400.GY23665@htj.dyndns.org \
--to=tj@kernel.org \
--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=oleg@redhat.com \
--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
all inboxes | Powered by JetHome®