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

From: Linus Torvalds (
Date: Wed Sep 18 2002 - 11:48:24 EST

On Wed, 18 Sep 2002, Rik van Riel wrote:

> On Wed, 18 Sep 2002, Linus Torvalds wrote:
> > 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.
> > + if (nr_threads > pid_max >> 4)
> > + pid_max <<= 1;
> ... but watch out for over/underflow. ;)

Actually, you can't overflow without having nr_threads be something like
27 bits, which means that you'd need to have 100 million threads active at
the same time.

Which, btw, is impossible anyway due to running out of memory to hold all
the thread data structures on a 32-bit architecture _long_ before you get
close to having a high enough nr_threads.

On a 64-bit architecture you can do it with enough memory, but even that
is a few years away (you'd need on the order of a couple of terabytes to
do it).

> It would also be nice if we had some known limit on pid_max (say 8
> million, fits in 7 digits).

Do the math. The above _will_ fit in 7 digits as long as you never have
more then about half a million threads active at the same time.

Which, practically speaking, means that we're done. Quite frankly, the
people who maintain machines that run millions of threads concurrently
care a hell of a lot more about the maching running _stable_ than about
"ps" being pretty.

The people who care about ps being pretty will probably never see more
than 5 digits.


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