From 3d344595207775c86ad7a93f28b0315953ab5689 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Mon, 26 Jun 2006 00:26:01 -0700 Subject: [PATCH] --- yaml --- r: 30259 b: refs/heads/master c: a872ff0cb2218dc9688b990c5ccda064dc40946b h: refs/heads/master i: 30257: 9f4603c090b874e9f539f4778020c4e9bd2b28f4 30255: 0d8b704726047f4ce6323c491295ebee8223b275 v: v3 --- [refs] | 2 +- trunk/fs/proc/base.c | 38 +++++++++++++++++--------------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/[refs] b/[refs] index c3ca02919001..f1ec82dc8b70 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: cc288738c9ae3c64d3c50b86604044d1f6d22941 +refs/heads/master: a872ff0cb2218dc9688b990c5ccda064dc40946b diff --git a/trunk/fs/proc/base.c b/trunk/fs/proc/base.c index 6092a6e2c5a9..5ee46d3a5cac 100644 --- a/trunk/fs/proc/base.c +++ b/trunk/fs/proc/base.c @@ -2227,38 +2227,34 @@ int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir) static struct task_struct *first_tid(struct task_struct *leader, int tid, int nr) { - struct task_struct *pos = NULL; + struct task_struct *pos; rcu_read_lock(); /* Attempt to start with the pid of a thread */ if (tid && (nr > 0)) { pos = find_task_by_pid(tid); - if (pos && (pos->group_leader != leader)) - pos = NULL; - if (pos) - nr = 0; + if (pos && (pos->group_leader == leader)) + goto found; } /* If nr exceeds the number of threads there is nothing todo */ - if (nr) { - if (nr >= get_nr_threads(leader)) - goto done; - } + pos = NULL; + if (nr && nr >= get_nr_threads(leader)) + goto out; - /* If we haven't found our starting place yet start with the - * leader and walk nr threads forward. + /* If we haven't found our starting place yet start + * with the leader and walk nr threads forward. */ - if (!pos && (nr >= 0)) - pos = leader; - - for (; pos && pid_alive(pos); pos = next_thread(pos)) { - if (--nr > 0) - continue; - get_task_struct(pos); - goto done; + for (pos = leader; nr > 0; --nr) { + pos = next_thread(pos); + if (pos == leader) { + pos = NULL; + goto out; + } } - pos = NULL; -done: +found: + get_task_struct(pos); +out: rcu_read_unlock(); return pos; }