I have two different debian 10 installations, both with 4core/8GB-RAM (name them A and B).

But the value of /proc/sys/kernel/threads-max is very different: A=63388 and B=7055.

The value of threads-max should be total virtual memory / stack size [1]. Value of stack size and virtual-memory is same in two installations (ulimit -s=8192, ulimit -v=unlimited), swap is turned off on both systems. Also the other sysctl related configs are similar in two VMs.

So, what is the cause of the threads-max difference on two systems?

PS1: The value of cat /proc/zoneinfo | grep spanned | awk '{totalpages=totalpages+$2} END {print totalpages}' is: A=2359295 and B=6029273

PS2: Kernel boot flags and /etc/initramfs-tools/modules are same in A/B. A is provisioned using vmware, and B is provisioned using proxmox.

PS3: I found that dmesg | grep Memory: differs in two VMs: (https://github.com/torvalds/linux/blob/v4.19/mm/page_alloc.c#L7060)

A| Memory: 8113684K/8388020K available (10252K kernel code, 1241K rwdata, 3320K rodata, 1592K init, 2272K bss, 274336K reserved, 0K cma-reserved)
B| Memory: 903068K/1048032K available (10252K kernel code, 1242K rwdata, 3328K rodata, 1600K init, 2260K bss, 144964K reserved, 0K cma-reserved)

and 8113684 / 903068 = 63388 / 7055 !!

  • Please run this command on both computers: cat /proc/zoneinfo | grep spanned | awk ‘{totalpages=totalpages+$2} END {print totalpages}’.
    – harrymc
    Apr 21, 2021 at 19:37
  • @harrymc I've updated the question Apr 22, 2021 at 3:55
  • Is it possible that threads-max was modified manually on A? Its value is too large.
    – harrymc
    Apr 22, 2021 at 8:47
  • No, It's the default. It is ~9x B (see my PS3) Apr 22, 2021 at 9:43

1 Answer 1


From the source of 4.19.170, in the file Documentation/sysctl/kernel.txt:


This value controls the maximum number of threads that can be created using fork().

During initialization the kernel sets this value such that even if the maximum number of threads is created, the thread structures occupy only a part (1/8th) of the available RAM pages.

The minimum value that can be written to threads-max is 20. The maximum value that can be written to threads-max is given by the constant FUTEX_TID_MASK (0x3fffffff). If a value outside of this range is written to threads-max an error EINVAL occurs.

The value written is checked against the available RAM pages. If the thread structures would occupy too much (more than 1/8th) of the available RAM pages threads-max is reduced accordingly.

This means that you can set this parameter either directly or using

# sysctl kernel.threads-max=255353

This value is different on the two systems because they have a different kernel version or the bootstrapping process is different or the system configuration is different. Also, they should have different values because as stated, the value is dependent on two other, configurable parameters and your systems are not identical.

  • I know the value can be changed with sysctl, but I seek the root cause of this difference. Apr 22, 2021 at 4:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .