Re: [patch] lockless, scalable get_pid(), for_each_process()

Linus Torvalds (torvalds@transmeta.com)
Wed, 18 Sep 2002 09:15:20 -0700 (PDT)


On Wed, 18 Sep 2002, Andries Brouwer wrote:
>
> Please leave pid_max large.

I have to agree.

There is no goodness in making life complicated, and then putting a lot of
effort in solving that complexity with other complexity.

I would suggest something like this:
- make pid_max start out at 32k or whatever, to make "ps" look nice if
nothing else.
- every time we have _any_ trouble at all with looking up a new pid, we
double pid_max.

And it's really easy to recognize trouble with something truly trivial
like the appended.

Give me one reason for why these two added lines aren't better than all
the complexity we've discussed? I can pretty much _guarantee_ that it's
faster, and it sure as hell is simpler. And all traditional uses that has
less than a few thousand threads at most will never see the larger pids,
so people can stare at "ps" output without going blind - the big pids
start showing up only on boxes that might actually _need_ them.

Linus

----
--- 1.77/kernel/fork.c Sun Sep 15 11:01:39 2002
+++ edited/fork.c Wed Sep 18 09:11:43 2002
@@ -175,6 +175,8 @@

if (last_pid >= next_safe) {
inside:
+ if (nr_threads > pid_max >> 4)
+ pid_max <<= 1;
next_safe = pid_max;
read_lock(&tasklist_lock);
repeat:

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/