RFR: JDK-8294266: Add a way to pre-touch java thread stacks
Thomas Stuefe
stuefe at openjdk.org
Mon Nov 28 16:08:00 UTC 2022
On Mon, 28 Nov 2022 11:57:24 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> > Be careful with that. On some OSes, touching more than N pages below the currently lowest-mapped stack page will segfault. Therefore you must touch from the top down.
>
> See `os::map_stack_shadow_pages()` for this.
>
> I think the pre-touching like this should be done as "extended" "preemptive" stack bang up to `stack_shadow_safe_limit`. `os::pretouch_memory` is fine for heap memory, but for thread stacks I think we need to hook into the usual stack overflow machinery.
Oh sure, I can touch in reverse order. But I wonder if that is really needed. I used alloca() to reserve the stack space, and it should take care of OS-side stack banging for me. On Windows it does. So in theory it should be functionally equivalent to `os::map_stack_shadow_pages()`.
-------------
PR: https://git.openjdk.org/jdk/pull/10403
More information about the hotspot-dev
mailing list