[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1291654624-6230-14-git-send-email-tj@kernel.org>
Date: Mon, 6 Dec 2010 17:57:01 +0100
From: Tejun Heo <tj@...nel.org>
To: oleg@...hat.com, roland@...hat.com, linux-kernel@...r.kernel.org,
torvalds@...ux-foundation.org, akpm@...ux-foundation.org,
rjw@...k.pl, jan.kratochvil@...hat.com
Cc: Tejun Heo <tj@...nel.org>
Subject: [PATCH 13/16] ptrace: reorganize __ptrace_unlink() and ptrace_untrace()
* Collapse ptrace_untrace() into __ptrace_unlink().
* Always do the whole unlinking inside siglock.
* Untracing is done before unlinking.
This is to prepare for further changes. As the whole
unlinking/tracing is done inside both tasklist lock and siglock, the
reordering doesn't cause any visible behavior difference.
Signed-off-by: Tejun Heo <tj@...nel.org>
Cc: Oleg Nesterov <oleg@...hat.com>
Cc: Roland McGrath <roland@...hat.com>
---
kernel/ptrace.c | 40 ++++++++++++++++++----------------------
1 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 5191301..6ac12f4 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -38,45 +38,41 @@ void __ptrace_link(struct task_struct *child, struct task_struct *new_parent)
}
/*
- * Turn a tracing stop into a normal stop now, since with no tracer there
- * would be no way to wake it up with SIGCONT or SIGKILL. If there was a
- * signal sent that would resume the child, but didn't because it was in
- * TASK_TRACED, resume it now.
- * Requires that irqs be disabled.
+ * unptrace a task: move it back to its original parent and remove it
+ * from the ptrace list.
+ *
+ * Turn a tracing stop into a normal stop now, since with no tracer
+ * there would be no way to wake it up with SIGCONT or SIGKILL. If
+ * there was a signal sent that would resume the child, but didn't
+ * because it was in TASK_TRACED, resume it now. Requires that irqs
+ * be disabled.
+ *
+ * Must be called with the tasklist lock write-held.
*/
-static void ptrace_untrace(struct task_struct *child)
+void __ptrace_unlink(struct task_struct *child)
{
+ struct signal_struct *sig = child->signal;
+
+ BUG_ON(!child->ptrace);
+
spin_lock(&child->sighand->siglock);
+
if (task_is_traced(child)) {
/*
* If group stop is completed or in progress, it should
* participate in the group stop. Set GROUP_STOP_PENDING
* before kicking it.
*/
- if (child->signal->flags & SIGNAL_STOP_STOPPED ||
- child->signal->group_stop_count)
+ if (sig->flags & SIGNAL_STOP_STOPPED || sig->group_stop_count)
child->group_stop |= GROUP_STOP_PENDING;
signal_wake_up(child, 1);
}
- spin_unlock(&child->sighand->siglock);
-}
-
-/*
- * unptrace a task: move it back to its original parent and
- * remove it from the ptrace list.
- *
- * Must be called with the tasklist lock write-held.
- */
-void __ptrace_unlink(struct task_struct *child)
-{
- BUG_ON(!child->ptrace);
child->ptrace = 0;
child->parent = child->real_parent;
list_del_init(&child->ptrace_entry);
- if (task_is_traced(child))
- ptrace_untrace(child);
+ spin_unlock(&child->sighand->siglock);
}
static int ptrace_wait_trap(void *flags)
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists