RFR: 8225035: Thread stack size issue caused by large TLS size
Thomas Stüfe
thomas.stuefe at gmail.com
Thu Jun 27 07:53:59 UTC 2019
On Thu, Jun 27, 2019 at 9:13 AM Florian Weimer <fweimer at redhat.com> wrote:
> * Jiangli Zhou:
>
> > Hi Florian and Thomas,
> >
> > Thank you both for the quick turnaround! I've incorporated the
> > suggestions from you and updated the webrev below. Hopefully that I've
> > captured all of those without missing any. Please let me know if
> > there's anything that I missed.
> >
> > http://cr.openjdk.java.net/~jiangli/8225035/webrev.02/
>
> I think
>
> stack_adjust_size += guard_size;
>
> is redundant with the get_minstack-based adjustment because it is either
> included in it directly in the get_minstack value, or indirectly in the
> updated stack size computation in glibc (where it adds the guard size
> internally).
Please do not change this!
To me and I guess many others it is very important that nothing at all
changes if this workaround is off.
I also would prefer the code to stay reasonably simple (as far as this is
still possible).
OTOH, I can accept that with this switch on - which is a new thing users
may experiment with - we may increase the stack size more than strictly
necessary to live with TLS. It is all a mystery number anyway since
pthread_get_minstack is undocumented.
In the end, increasing stack size only affects virtual size, not rss (at
least on the platforms I work on).
> (The guard size adjustment was removed from
> __pthread_get_minstack because it happens elsewhere in glibc.) For this
> to work across different glibc versions, you need to set the guard size
> first in the attribute (before the stack size).
>
__pthread_get_minstack also returns quite a bit more than the static TLS
> size. I think you should subtract os::vm_page_size() and
> PTHREAD_MIN_STACK from it to get the actual value.
>
> I suspect this new flag is is working well because it effectively adds
> 20 KiB to all requested stack sizes (page size plus PTHREAD_MIN_STACK).
> The static TLS size adjustment may not matter at all. On older glibcs,
> the number is even higher because your code adds the guard size twice
> (once in __pthread_get_minstack, once in the Hotspot code).
>
>
Which, again, would be an argument for a much simpler "-XX:MinStackSize"
option...
> Thanks,
> Florian
>
Cheers, Thomas
More information about the hotspot-runtime-dev
mailing list