[Gllug] Max number of pthreads in Linux ?

Nix nix at esperi.org.uk
Wed Mar 26 16:49:23 UTC 2008

On 26 Mar 2008, Daniel P. Berrange stated:

> On Wed, Mar 26, 2008 at 07:38:49AM +0100, salsaman at xs4all.nl wrote:
>> Hi all,
>> does anybody know the maximum number of threads libpthread will support on
>> Linux ? The only information I could find was in
> Since introduction of NPTL the number of threads is basically same as
> the number of processes - so, on the order of 32768   IIRC.

32768 is a dynamically boostable limit, of course: echo the new higher
value into /proc/sys/kernel/pid_max.

> Realistically you'll probably be limited by memory first - the default
> thread stack size is 10 MB. So on i386 you'll run out of address space
> for stacks around the 200 thread mark, unless you explicitly reduce the
> stack size.

Even if you limit that, you'll end up limited by available low memory
for (nonswappable) kernel stacks, with each thread having well over 6K
for kernel stack+task_struct, and more often nearly 10K, you soon find
yourself tying up hundreds of Mb.

`The rest is a tale of post and counter-post.' --- Ian Rawlings
                                                   describes USENET
Gllug mailing list  -  Gllug at gllug.org.uk

More information about the GLLUG mailing list