Re: [Q] cannot fork w/ 1000s of procs (but still mem avail.)

From: Andries.Brouwer@cwi.nl
Date: Wed Oct 10 2001 - 15:54:22 EST


    hopefully a simple question to answer: I get "cannot fork" messages on my
    machine running some 20000 processes and threads (1 master proc, 3 threads)
    where each (master) process opens a socket and does IP traffic over it.
    Although there is plenty of memory left (4GB box, 2GB used, 0 swap), I get
    "cannot fork - out of memory" when trying to increase the number of procs.
    (If none of the procs does IP, I can start more [of course?!].)
    Anything I can do to increase the number of active processes using IP? Any
    kernel paramter, limit, sizing?

You run out of process numbers, I suppose.
pid is 15 bits only - look at getpid() in fork.c.
It is very easy to make it 31 bits instead, and one of my machines
has been running a system with 31 bit pids for a long time.

(Note, I am not talking about sizeof(pid_t) but just about code like

        if((++last_pid) & 0xffff8000) {
                last_pid = 300; /* Skip daemons etc. */
                goto inside;
        }

that must be removed.)

I sent Linus a patch once or twice, will include it below if I can
find it.

Andries

Yes, found it [hand-edited to remove unrelated stuff].
I have not checked whether it still applies and still is correct.

==================================================================



This archive was generated by hypermail 2b29 : Mon Oct 15 2001 - 21:00:34 EST