This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Fixed size of thread stacks in the nptl pthread implementation
- From: Siddhesh Poyarekar <siddhesh at redhat dot com>
- To: libc-alpha at sourceware dot org
- Cc: Jeff Law <law at redhat dot com>
- Date: Fri, 3 Feb 2012 15:38:32 +0530
- Subject: Fixed size of thread stacks in the nptl pthread implementation
Hi,
The memory allocated by libc for thread stacks in the kernel using an
mmap of a fixed size using the MAP_STACK flag (among others). There is
currently no way to identify these maps in proc/<pid>/maps since they
come up as anon maps. Also, these stacks are of a fixed size, which
looks like a limitation.
Is this limitation intentional? It looks like it could easily have
been overwritten by using MAP_GROWSDOWN flag in the mmap call. POSIX
defines the thread stacks as having a minimum size, but I could not
find anything about them being fixed.
I have written a patch for the kernel to mark maps created with
MAP_STACK with VM_STACK_FLAGS which includes the correct stack
permissions according to system settings as well as VM_GROWSDOWN or
VM_GROWSUP depending on the system:
https://lkml.org/lkml/2012/2/2/14
The intention was to have the maps marked correctly in
/proc/<pid>/maps but it also works towards unifying the way thread
stacks and the main thread stack behave and look. Among other things,
the major difference for glibc would be that the stack can grow
automatically like the main thread. Is there any reason why this
should not be implemented or would break things for glibc?
Thanks,
Siddhesh