RFR: 8229147: Linux os::create_thread() overcounts guardpage size with newer glibc (>=2.27)
Thomas Stuefe
stuefe at openjdk.org
Mon Apr 24 08:51:48 UTC 2023
On Sat, 22 Apr 2023 14:13:08 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> We can now detect whether glibc includes the guard pages as part of the requested stack size or not, and so only need to make adjustments when glibc requires it.
>>
>> The intent was to use a local variable as the "flag" but unfortunately it is also needed in os_posix.cpp so I had to make it part of the os::Linux API.
>>
>> See bug report (and related) for details.
>>
>> Testing:
>> - Manually checked log output for stack sizes and boundaries on systems with and without the glibc fix. (Again see JBS issue)
>> - Tiers 1-3 sanity
>> Thanks
>
> Looks mostly okay. I had to compare the glibc sources for 2.26 and 2.27 in order to understand what the patch does.
@tstuefe that is all true and correct, but what we don't know (without looking at the implementation) is what `__get_minstack` will do with the value in the attribute. I guess I need to find the old version of the code and see whether it does a raw read or adjusts it somehow based on pagesize.
HEAD
size_t
__pthread_get_minstack (const pthread_attr_t *attr)
{
return (GLRO(dl_pagesize) + __nptl_tls_static_size_for_stack ()
+ PTHREAD_STACK_MIN);
}
2.27
```
size_t
__pthread_get_minstack (const pthread_attr_t *attr)
{
return GLRO(dl_pagesize) + __static_tls_size + PTHREAD_STACK_MIN;
}
2.26
size_t
__pthread_get_minstack (const pthread_attr_t *attr)
{
struct pthread_attr *iattr = (struct pthread_attr *) attr;
return (GLRO(dl_pagesize) + __static_tls_size + PTHREAD_STACK_MIN
+ iattr->guardsize);
}
Old version just added the guard size, without alignment. So your trick should work.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13571#issuecomment-1519644927
More information about the hotspot-runtime-dev
mailing list