Commit 9590204d authored by Tony Luck's avatar Tony Luck

Pull optimize-ptrace-threads into release branch

parents 8496f2a4 4ac0068f
...@@ -589,6 +589,7 @@ find_thread_for_addr (struct task_struct *child, unsigned long addr) ...@@ -589,6 +589,7 @@ find_thread_for_addr (struct task_struct *child, unsigned long addr)
{ {
struct task_struct *g, *p; struct task_struct *g, *p;
struct mm_struct *mm; struct mm_struct *mm;
struct list_head *this, *next;
int mm_users; int mm_users;
if (!(mm = get_task_mm(child))) if (!(mm = get_task_mm(child)))
...@@ -600,28 +601,21 @@ find_thread_for_addr (struct task_struct *child, unsigned long addr) ...@@ -600,28 +601,21 @@ find_thread_for_addr (struct task_struct *child, unsigned long addr)
goto out; /* not multi-threaded */ goto out; /* not multi-threaded */
/* /*
* First, traverse the child's thread-list. Good for scalability with * Traverse the current process' children list. Every task that
* NPTL-threads. * one attaches to becomes a child. And it is only attached children
* of the debugger that are of interest (ptrace_check_attach checks
* for this).
*/ */
p = child; list_for_each_safe(this, next, &current->children) {
do { p = list_entry(this, struct task_struct, sibling);
if (thread_matches(p, addr)) { if (p->mm != mm)
child = p;
goto out;
}
if (mm_users-- <= 1)
goto out;
} while ((p = next_thread(p)) != child);
do_each_thread(g, p) {
if (child->mm != mm)
continue; continue;
if (thread_matches(p, addr)) { if (thread_matches(p, addr)) {
child = p; child = p;
goto out; goto out;
} }
} while_each_thread(g, p); }
out: out:
mmput(mm); mmput(mm);
return child; return child;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment