ptrace: Participate in group stop from ptrace_stop() iff the task is trapping for...
authorTejun Heo <tj@kernel.org>
Wed, 23 Mar 2011 09:37:00 +0000 (10:37 +0100)
committerTejun Heo <tj@kernel.org>
Wed, 23 Mar 2011 09:37:00 +0000 (10:37 +0100)
Currently, ptrace_stop() unconditionally participates in group stop
bookkeeping.  This is unnecessary and inaccurate.  Make it only
participate if the task is trapping for group stop - ie. if @why is
CLD_STOPPED.  As ptrace_stop() currently is not used when trapping for
group stop, this equals to disabling group stop participation from
ptrace_stop().

A visible behavior change is increased likelihood of delayed group
stop completion if the thread group contains one or more ptraced
tasks.

This is to preapre for further cleanup of the interaction between
group stop and ptrace.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Roland McGrath <roland@redhat.com>
kernel/signal.c

index a2e7a6527d2471abae2e1f6f1c5cc9495d7d86ff..9f36dd2e8d5acd5ecb84f723b64100d0d87d2f17 100644 (file)
@@ -1694,10 +1694,13 @@ static void ptrace_stop(int exit_code, int why, int clear_code, siginfo_t *info)
        }
 
        /*
-        * If there is a group stop in progress,
-        * we must participate in the bookkeeping.
+        * If @why is CLD_STOPPED, we're trapping to participate in a group
+        * stop.  Do the bookkeeping.  Note that if SIGCONT was delievered
+        * while siglock was released for the arch hook, PENDING could be
+        * clear now.  We act as if SIGCONT is received after TASK_TRACED
+        * is entered - ignore it.
         */
-       if (current->group_stop & GROUP_STOP_PENDING)
+       if (why == CLD_STOPPED && (current->group_stop & GROUP_STOP_PENDING))
                task_participate_group_stop(current);
 
        current->last_siginfo = info;