RFR: JDK-8294266: Add a way to pre-touch java thread stacks

Aleksey Shipilev shade at openjdk.org
Mon Nov 28 11:59:38 UTC 2022


On Mon, 28 Nov 2022 11:49:07 GMT, Andrew Haley <aph at openjdk.org> wrote:

> > > Drive-by comment: there is `os::pretouch_memory(void* start, void* end, size_t page_size)` ;)
> > 
> > 
> > Good point. Had to cast the volatile away though.
> 
> 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.

-------------

PR: https://git.openjdk.org/jdk/pull/10403


More information about the hotspot-dev mailing list