The following command computes size of the stack for each running process on a Linux machine.
# find /proc -maxdepth 1 -type d -regex '/proc/[0-9]*' -exec cat '{}'/maps \; | grep stack | cut -d' ' -f1 | gawk --non-decimal-data 'BEGIN{FS="-"} {printf "%d\n", (("0x" $2) - ("0x" $1))/1024}' | sort
In almost all the cases size of the stack is 132KiB. Why is this number so special? Is this the minimum possible size of the stack?
The kernel sets new process stacks to 128kB in
setup_arg_pages():When you add a single 4kB guard page, that comes to 132kB. If the process has never used more than this much stack, it won’t have been expanded past this size.