8176768: hotspot ignores PTHREAD_STACK_MIN when creating new threads

Use PTHREAD_STACK_MIN as a minimum, plus other stack size cleanup

Reviewed-by: dholmes, stuefe, dcubed
This commit is contained in:
Chris Plummer 2017-03-23 11:10:55 -07:00
parent 99d6ff5c76
commit 17a8069db3
8 changed files with 108 additions and 19 deletions

View file

@ -723,9 +723,16 @@ bool os::create_thread(Thread* thread, ThreadType thr_type,
// the size of the guard pages to the stack size, instead Linux
// takes the space out of 'stacksize'. Thus we adapt the requested
// stack_size by the size of the guard pages to mimick proper
// behaviour.
stack_size = align_size_up(stack_size + os::Linux::default_guard_size(thr_type), vm_page_size());
pthread_attr_setstacksize(&attr, stack_size);
// behaviour. However, be careful not to end up with a size
// of zero due to overflow. Don't add the guard page in that case.
size_t guard_size = os::Linux::default_guard_size(thr_type);
if (stack_size <= SIZE_MAX - guard_size) {
stack_size += guard_size;
}
assert(is_size_aligned(stack_size, os::vm_page_size()), "stack_size not aligned");
int status = pthread_attr_setstacksize(&attr, stack_size);
assert_status(status == 0, status, "pthread_attr_setstacksize");
// Configure glibc guard page.
pthread_attr_setguardsize(&attr, os::Linux::default_guard_size(thr_type));