Linux /var/log/messages show the following info and the host hung:
automount: expire_proc: expire thread create for /misc failed
https://access.redhat.com/solutions/147923 Why does a server crash with automount failing to create threads ? The issue is related to the maximum number of processes respectively the kernel parameter kernel.pid_max
The following is the explanation of pid_max:
/proc/sys/kernel/pid_max (since Linux 2.5.34) This file specifies the value at which PIDs wrap around (i.e., the value in this file is one greater than the maximum PID). The default value for this file, 32768, results in the same range of PIDs as on earlier kernels. On 32-bit platforms, 32768 is the maximum value for pid_max. On 64-bit systems, pid_max can be set to any value up to 2^22 (PID_MAX_LIMIT, approximately 4 million).
From our observation, it was threads number that increased, not process number. Does pid_max have effect on threads as well?
https://en.wikipedia.org/wiki/Thread_(computing) 1:1 (kernel-level threading) Threads created by the user in a 1:1 correspondence with schedulable entities in the kernel are the simplest possible threading implementation. OS/2 and Win32 used this approach from the start, while on Linux the usual C library implements this approach (via the NPTL or older LinuxThreads). This approach is also used by Solaris, NetBSD, FreeBSD, OS X, and iOS.
Effectively, pid-max puts a limit on kernel scheduleable entities, which corresponds to either user process or threads. In addition, it seems that Linux does not have a separate threads per process limit.
After resolving the above questions, we can now answer these two questions:
What is the maximum threads that one can create on Linux host?
What is the maximum threads within a user process on Linux?
Essentially they are the same question and the answer is (to my best knowledge but not verified):
MIN(threads-max, pid-max, nproc - number of simultaneous processes)
In addition, it seems that threads-max is effective for total threads of all users and it only controls the number of threads, no processes.
how to determine the max user process value?
What causes stale NFS file handles?
Linux NFS Overview, FAQ and HOWTO Documents
What are Linux Processes, Threads, Light Weight Processes, and Process State