Re: Stack consumption in NPTL
- From: Rainer Weikusat <rweikusat@xxxxxxxxxxx>
- Date: Fri, 07 Mar 2008 13:05:31 +0100
Chetan <chetanaru@xxxxxxxxx> writes:
We have an application which creates multiple threads and has some
logging mechanism. We observed that the application crashes when
using NPTL but works just fine with LinuxThreads. The stack trace
analysis revealed that the crash is due to smaller stack size. We
are setting the stack size to 16K through the program
using pthread_attr_setstacksize() function. Increasing the stack
size to 128K did not reproduce the crash.
Is there a particular why you are creating threads with less room for
stack growth than they need?
What should be the stack size for the threads in NPTL?
By default, NPTL will reserve 8M of virtual address space per
thread. Memory will be allocated to the stack of each thread as
needed, so, unless you are creating a large number of threads, why not
just stick with the default? Otherwise, why not be somewhat more
careful wrt to reducing the size? Unless you restructure the program,
it will not work with less stack than it needs, anyway.
Since the compiler hasn't changed, the amount of stack space used per
subroutine should be the same. Presumably, NPTL puts some amount of
'thread management data' onto the stack of each thread.
U. Drepper's 'outdated' NPTL design paper states that:
5.6 Memory Allocation
One of the goals for the library is to have low startup costs
for threads. The biggest problem time-wise outside the kernel
is the memory needed for the thread data structures,
thread-local storage, and the stack. Optimizing the memory
allocation is done in two steps:
· The necessary memory blocks are merged. I.e., the thread
data structures and the thread-local storage are placed on the
stack. The usable stack array starts just below (or above in case
of an upward growing stack) the memory needed for the two.
[p. 9, http://people.redhat.com/drepper/nptl-design.pdf]
which suggests that there actually has been such a change.
.
- References:
- Stack consumption in NPTL
- From: Chetan
- Stack consumption in NPTL
- Prev by Date: Re: Stack consumption in NPTL
- Next by Date: Re: Stack consumption in NPTL
- Previous by thread: Re: Stack consumption in NPTL
- Next by thread: Re: Stack consumption in NPTL
- Index(es):
Relevant Pages
|