Re: [patch] lockless, scalable get_pid(), for_each_process() elimination, 2.5.35-BK

From: Linus Torvalds (
Date: Wed Sep 18 2002 - 11:15:20 EST

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.


--- 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) {
+		if (nr_threads > pid_max >> 4)
+			pid_max <<= 1;
 		next_safe = pid_max;

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to More majordomo info at Please read the FAQ at

This archive was generated by hypermail 2b29 : Mon Sep 23 2002 - 22:00:23 EST