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 !!