RFR: 8225035: Thread stack size issue caused by large TLS size
Thomas Stüfe
thomas.stuefe at gmail.com
Wed Jun 19 07:03:20 UTC 2019
Hi Jiangli and everyone,
On Tue, Jun 18, 2019 at 12:41 AM Jiangli Zhou <jianglizhou at google.com>
wrote:
> Hi Andrew and Florian,
>
> With the stack size needs to be aligned at page boundary, it seems that
> the effect of using large page size is the same for the following two
> approaches:
>
> 1. Using a JVM knob which specifies a minimum stack size for stack
> size adjustment (suggested by Florian)
> 2. Using the value obtained from __pthread_get_minstack for stack size
> adjustment
>
> Are you sure? The snippet Florian posted seemed to indicate that the page
size factors into the result of __pthread_minstack. Something along the
line of "tls_size + x", where x depends on page size? If this is true, for
larger page sizes x would dwarf tls_size, which was my original fear - that
the size __pthread_get_minstack returns would be unnecessarily large on
those platforms.
Note that I am currently in vacation and have no means to check this.
The difference is that the second approach gets the adjustment value
> without guessing, which seems to be more user friendly. What are your
> thoughts on that? If there is anything that I'm missing, please correct.
>
> After thinking more, it seems that the simple approach with an on/off
> switch (suggested by David initially) that adjusts all threads' stack size
> (for the on-stack TLS blocks) when the switch is enabled probably is
> better. Any objections?
>
> Thanks a lot for all the feedback and suggestions!!
>
> Best regards,
>
> Jiangli
>
I can see the merits of both solutions but lean toward (1), for similar
reasons Florian and others gave:
+ it would work for hypothetical non-TLS related cases
+ it is simple(r) to understand
+ it does not rely on the workings of an undocumented glibc function. I
still have not understood what __pthread_get_minstack really returns - some
sort of minimum stack size, yes, but what does that guarantee, exactly?
Open Question: would that a Linux only switch? If we move away from the
its-for-TLS reasoning, maybe this should be made platform independent?
Disadvantages of (1): we now have a second thread size switch beside Xss,
which can be confusing and needs explaining.
-Xss defines thread stack size unless it gets overruled by an explicit
size passed to the j.l.Thread constructor or unless it is an internal JVM
thread. The new -XX:MinimumStackSize switch would work for all threads. If
both are specified and -Xss < -XX:MinimumStackSize, latter overrides former
which may be surprising.
Cheers, Thomas
More information about the hotspot-runtime-dev
mailing list