Increase value for os::vm_allocation_granularity() on all platforms?

Thomas Stüfe thomas.stuefe at gmail.com
Sat Apr 25 16:58:25 UTC 2020


Hi all,

we have os::vm_page_size() and os::vm_allocation_granularity().

Both are the same on all platforms but Windows, where allocation
granularity (64K afaik) constitutes the alignment of the starting address
(note: not size!) of memory regions mapped with VirtualAlloc, which is used
for os::reserve_memory and friends.

os::vm_allocation_granularity() is not documented, so its meaning can only
be derived from its name and its windows implementation, and where it is
used. I always thought it to be the alignment to use for
os::reserve_memory() attach addresses. Maybe the size of allocations too,
that is unclear and Windows does not require that.

I do not develop on Windows. So errors stemming from confusing page size
and allocation granularity keep showing up only when I test my code on
Windows - when I am lucky, sometimes much later. Others have the same
problem, see e.g.: https://bugs.openjdk.java.net/browse/JDK-8242267.

I wonder whether it would make sense to artificially increase the value of
os::vm_allocation_granularity on all platforms. Lets say 4*page size. Maybe
only on platforms with 4K pages. Maybe only for debug builds. But the hope
is that this triggers bugs on the platform we develop instead late in
development on Windows.

What do you think, does this make sense?

Thank you,

Thomas


More information about the hotspot-runtime-dev mailing list