RFR: 8225035: Thread stack size issue caused by large TLS size

Andrew Haley aph at redhat.com
Wed Jun 12 14:43:28 UTC 2019


On 6/12/19 3:32 PM, Florian Weimer wrote:
> I would say that static TLS has a fixed offset from the thread pointer,
> the same in all threads, while dynamic TLS can have varying offsets
> depending on the thread because a more complicated lookup sequence is
> used.

Quite, which is what my example showed.

> You can get fixed TLS offsets in DSOs, avoiding the indirection, by
> using the initial-exec TLS model, either via __attribute__ ((tls_model
> ("initial-exec"))) in the source code, or via -ftls-model=initial-exec
> on the command line.



> On some targets, there is a static version of initial-exec TLS,
> where the offset from the thread pointer is determined by the link
> editor and put directly into the instruction stream.  This only
> works for the main program, of course, because there can be only one
> object in the entire program which does that.  In DSOs, you always
> have to load the offset of a TLS variable at run time from a hidden
> global variable initialized by the dynamic loader.

... which generates

barf:
	movq	%fs:0, %rdx
	movq	boof at gottpoff(%rip), %rax
	addq	%rdx, %rax
	ret

... an example is worth a thousand words.

-- 
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671


More information about the hotspot-runtime-dev mailing list