Re: [PATCH] simplify/fix first_tid()

From: Oleg Nesterov
Date: Mon Mar 20 2006 - 14:32:58 EST


"Eric W. Biederman" wrote:
>
> Oleg Nesterov <oleg@xxxxxxxxxx> writes:
>
> >> So we really still need the nr_threads test in there so we don't
> >> traverse the list twice everytime through readdir.
> >
> > How so? We don't do it twice?
>
> In general user space does. Because a read of 0 bytes signifies
> the end of a directory.
>
> So we have 2 trips through proc_task_readdir initiated by user
> space.

Oh, thanks, you are right.

[PATCH] simplify-fix-first_tid-fix

Restore a stupidly deleted optimization.

Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx>

--- MM/fs/proc/base.c~ 2006-03-21 01:08:10.000000000 +0300
+++ MM/fs/proc/base.c 2006-03-21 01:14:36.000000000 +0300
@@ -2190,6 +2190,11 @@ static struct task_struct *first_tid(str
goto found;
}

+ /* If nr exceeds the number of threads there is nothing todo */
+ 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.
*/
-
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/