Escalated to Bugzilla from IssueTracker
Used a test program pidseqchk.c to check the behaviour of the kernel. The program continuously fork()s itself until there is a sequence discontinuity or an error occurs, at which point it notes the extent of the continuous allocation and then tidies up and continues around the loop. Under the RHEL4-U4 kernel the gaps between 32768 & 65536 and above 98304 were observed with one particular exception. # uname -a Linux host-175.example.com 2.6.9-42.EL #1 Wed Jul 12 23:15:20 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux # echo 99999 >/proc/sys/kernel/pid_max # ulimit -u unlimited # ./pidseqchk fork failed: 11/Resource temporarily unavailable sequence break: 3688 - 11832 (new 11834) fork failed: 11/Resource temporarily unavailable sequence break: 11834 - 19978 (new 19980) fork failed: 11/Resource temporarily unavailable sequence break: 19980 - 28124 (new 28126) sequence break: 28126 - 32767 (new 65536) fork failed: 11/Resource temporarily unavailable sequence break: 65536 - 73680 (new 73682) fork failed: 11/Resource temporarily unavailable sequence break: 73682 - 81826 (new 81828) fork failed: 11/Resource temporarily unavailable sequence break: 81828 - 89972 (new 89974) fork failed: 11/Resource temporarily unavailable sequence break: 89974 - 98118 (new 98120) sequence break: 98120 - 98303 (new 131072) sequence break: 131072 - 131072 (new 300) sequence break: 300 - 305 (new 307) It is curious to note that the kernel does give a value greater than pid_max when creating pid 131072 which suggests that there is a fencepost issue somewhere. After much digging I managed to find a short thread on the kernel mailing list from 2004 http://marc.info/?t=107335880700001&r=1&w=2 which highlights the specific problem in the kernel/pid.c file within the allod_pidmap() routine whereby when pid crosses into the second (and subsequent even) page used for tracking pid use it then skips over the page. The particular patch was not adopted and the alloc_pidmap was re-written for the 2.6.10 kernel. <wli> [PATCH] pidhashing: rewrite alloc_pidmap() Rewrite alloc_pidmap() to clarify control flow by eliminating all usage of goto, honor pid_max and first available pid after last_pid semantics, make only a single pass over the used portion of the pid bitmap, and update copyrights to reflect ongoing maintenance by Ingo and myself.
Created attachment 315854 [details] pid sequence check program
Summary of LKML thread. the alloc_pidmap() routine in kernel/pid.c skips alternate pidmap pages. On entry to the alloc_pidmap() routine the pid value is set to last_pid+1. When this increments out of an existing page (32767->32768) the offset into the map page becomes 0. when it reaches the test of !offset before next_map: it enters the block and then moves to the next map.
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux maintenance release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux Update release for currently deployed products. This request is not yet committed for inclusion in an Update release.
Committed in 78.21.EL . RPMS are available at http://people.redhat.com/vgoyal/rhel4/
*** Bug 465371 has been marked as a duplicate of this bug. ***
*** Bug 431617 has been marked as a duplicate of this bug. ***
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHSA-2009-1024.html