pthreads and kernel - change MAP_STACK operation
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 3 May 2019 02:48:53 +0000 (19:48 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 3 May 2019 04:33:59 +0000 (21:33 -0700)
commit4837705ef8eed5e115acd4998b8f162b32e6a6f9
treed3cdbb18852fcf6d34d9a64020f84552ef468756
parenta39ca3da410e881afdb4b06a3bea5e02df6a6a69
pthreads and kernel - change MAP_STACK operation

* Only allow new mmap()'s to intrude on ungrown MAP_STACK areas when
  MAP_TRYFIXED is specified.  This was not working as intended before.
  Adjust the manual page to be more clear.

* Make kern.maxssiz (the maximum user stack size) visible via sysctl.

* Add kern.maxthrssiz, indicating the approximate space for placement
  of pthread stacks.  This defaults to 128GB.

* The old libthread_xu stack code did use TRYFIXED and will work
  with the kernel changes, but change how it works to not assume
  that the user stack should suddenly be limited to the pthread stack
  size (~2MB).

  Just use a normal mmap() now without TRYFIXED and a hint based on
  kern.maxthrssiz (defaults to 512GB), calculating a starting address
  hint that is (_usrstack - maxssiz - maxthrssiz).

* Adjust procfs to report MAP_STACK segments as 'STK'.
lib/libc/sys/mmap.2
lib/libthread_xu/thread/thr_stack.c
sys/kern/subr_param.c
sys/platform/pc64/include/vmparam.h
sys/platform/vkernel64/include/vmparam.h
sys/vfs/procfs/procfs_map.c
sys/vm/vm_map.c