Re: [PATCH 11/11] ptrace: implement group stop notification for ptracer

From: Denys Vlasenko
Date: Tue May 10 2011 - 18:37:42 EST


On Sunday 08 May 2011 17:49, Tejun Heo wrote:
> Currently there's no way for ptracer to find out whether group stop
> that tracee was in finished other than polling with PTRACE_GETSIGINFO.
> Also, tracer can't detect new group stop started by an untraced thread
> if tracee is already trapped. This patch implements group stop
> notification for ptracer using INTERRUPT traps.

Group stop notification already is performed by current kernels.
What we don't have is "group cont notification".

> When group stop state of a seized tracee changes, JOBCTL_TRAP_NOTIFY
> is set, which triggers INTERRUPT trap but is sticky until the next
> PTRACE_GETSIGINFO.

Why INTERRUPT trap? For group stops, we already have perfectly working
way to detect such a stop.

Can we just add a "group cont" notification which looks like
a waitpid result with WIFCONTINUED(waitpid_status) == 1 to the tracer?


> -EINVAL return from GETSIGINFO also clears the sticky trap. This is
> because -EINVAL clearly indicates that tracee is in group stop. To
> avoid unnecessarily taking INTERRUPT trap on the way to group stop, if
> JOBCTL_STOP_PENDING is set, INTERRUPT trap is not taken.

Exactly.


> Re-trapping is used only for group stop and INTERRUPT traps. If
> tracer wants to get notified about group stop, it either leaves tracee
> in the initial group stop trap or puts it into INTERRUPT trap. When
> INTERRUPT trap is scheduled while tracee is already in a trap,

Sane tracer has no need to do PTRACE_INTERRUPT on a tracee
which is already stopped (for whatever reason): it already knows
it's stopped, and why. PTRACE_INTERRUPT is useful to cleanly stop
_running_ tracees.


--
vda
--
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/